Jamie Gennis | 2da489c | 2012-09-19 18:06:29 -0700 | [diff] [blame] | 1 | <!DOCTYPE HTML> |
| 2 | <html> |
| 3 | <!-- |
| 4 | Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 5 | Use of this source code is governed by a BSD-style license that can be |
| 6 | found in the LICENSE file. |
| 7 | --> |
| 8 | <head> |
| 9 | <title>UI tests</title> |
| 10 | <script src="base.js"></script> |
| 11 | <script> |
| 12 | base.require('unittest'); |
| 13 | base.require('ui'); |
| 14 | </script> |
| 15 | </head> |
| 16 | <body> |
| 17 | <script> |
| 18 | 'use strict'; |
| 19 | |
Jeff Brown | 88448d9 | 2013-03-27 17:00:08 -0700 | [diff] [blame^] | 20 | var TestElement = tracing.ui.define('div'); |
Jamie Gennis | 2da489c | 2012-09-19 18:06:29 -0700 | [diff] [blame] | 21 | TestElement.prototype = { |
| 22 | __proto__: HTMLDivElement.prototype, |
| 23 | |
| 24 | decorate: function() { |
| 25 | if (!this.decorateCallCount) |
| 26 | this.decorateCallCount = 0; |
| 27 | this.decorateCallCount++; |
| 28 | } |
| 29 | }; |
| 30 | |
| 31 | function testDecorateOnceViaNew() { |
| 32 | var testElement = new TestElement(); |
| 33 | assertEquals(1, testElement.decorateCallCount); |
| 34 | } |
| 35 | |
| 36 | function testDecorateOnceDirectly() { |
| 37 | var testElement = document.createElement('div'); |
Jeff Brown | 88448d9 | 2013-03-27 17:00:08 -0700 | [diff] [blame^] | 38 | tracing.ui.decorate(testElement, TestElement); |
Jamie Gennis | 2da489c | 2012-09-19 18:06:29 -0700 | [diff] [blame] | 39 | assertEquals(1, testElement.decorateCallCount); |
| 40 | } |
| 41 | </script> |
| 42 | </body> |
| 43 | </html> |