OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta name="dart.unittest" content="full-stack-traces"> |
| 3 <title> element_upgrade_test </title> |
| 4 <style> |
| 5 .unittest-table { font-family:monospace; border:1px; } |
| 6 .unittest-pass { background: #6b3;} |
| 7 .unittest-fail { background: #d55;} |
| 8 .unittest-error { background: #a11;} |
| 9 </style> |
| 10 <script src="/packages/web_components/webcomponents.js"></script> |
| 11 <script src="/packages/web_components/dart_support.js"></script> |
| 12 |
| 13 <body> |
| 14 <h1> Running element_upgrade_test </h1> |
| 15 |
| 16 <script> |
| 17 var Foo = function() {}; |
| 18 Foo.prototype = Object.create(HTMLElement.prototype); |
| 19 Foo.prototype.createdCallback = function() { |
| 20 this.fooCreated = true; |
| 21 this.textContent = 'constructed'; |
| 22 |
| 23 // Tell the Dart side that this was created. |
| 24 // For testing purposes, for real code this would use a different mechanism. |
| 25 window.upgradeListener(this); |
| 26 }; |
| 27 |
| 28 Foo.prototype.doSomething = function() { |
| 29 this.textContent = 'didSomething'; |
| 30 return 'didSomething'; |
| 31 }; |
| 32 |
| 33 Foo = document.registerElement('x-foo', Foo); |
| 34 |
| 35 function validateIsFoo(element) { |
| 36 if (!(element instanceof Foo)) { |
| 37 throw Error('Element is not a Foo'); |
| 38 } |
| 39 |
| 40 if (!element.fooCreated) { |
| 41 throw Error('Expected fooCreated to be set'); |
| 42 } |
| 43 } |
| 44 </script> |
| 45 |
| 46 <script type="text/javascript" |
| 47 src="/root_dart/tools/testing/dart/test_controller.js"></script> |
| 48 <script type="text/javascript" |
| 49 src="/packages/browser/interop.js"></script> |
| 50 %TEST_SCRIPTS% |
| 51 </body> |
OLD | NEW |