<!DOCTYPE HTML> <html> <!-- Copyright (c) 2012 The Chromium Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> <head> <title>UI tests</title> <script src="base.js"></script> <script> base.require('unittest'); base.require('ui'); </script> </head> <body> <script> 'use strict'; var TestElement = base.ui.define('div'); TestElement.prototype = { __proto__: HTMLDivElement.prototype, decorate: function() { if (!this.decorateCallCount) this.decorateCallCount = 0; this.decorateCallCount++; } }; function testDecorateOnceViaNew() { var testElement = new TestElement(); assertEquals(1, testElement.decorateCallCount); } function testDecorateOnceDirectly() { var testElement = document.createElement('div'); base.ui.decorate(testElement, TestElement); assertEquals(1, testElement.decorateCallCount); } </script> </body> </html>