Chromium Code Reviews| Index: tests/html/custom/element_upgrade_test.html |
| diff --git a/tests/html/custom/element_upgrade_test.html b/tests/html/custom/element_upgrade_test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..498a47bb2daadb72fa7670d5de24b3d2dfe0b678 |
| --- /dev/null |
| +++ b/tests/html/custom/element_upgrade_test.html |
| @@ -0,0 +1,51 @@ |
| +<!DOCTYPE html> |
| +<meta name="dart.unittest" content="full-stack-traces"> |
| +<title> element_upgrade_test </title> |
| +<style> |
| + .unittest-table { font-family:monospace; border:1px; } |
| + .unittest-pass { background: #6b3;} |
| + .unittest-fail { background: #d55;} |
| + .unittest-error { background: #a11;} |
| +</style> |
| +<script src="/packages/web_components/platform.concat.js"></script> |
| +<script src="/packages/web_components/dart_support.js"></script> |
| + |
| +<body> |
| + <h1> Running element_upgrade_test </h1> |
| + |
| +<script> |
| +var Foo = function() {}; |
| +Foo.prototype = Object.create(HTMLElement.prototype); |
| +Foo.prototype.createdCallback = function() { |
| + this.fooCreated = true; |
| + this.textContent = 'constructed'; |
| + |
| + // Tell the Dart side that this was created. |
| + // For testing purposes, for real code this would use a different mechanism. |
| + window.upgradeListener(this); |
| +}; |
| + |
| +Foo.prototype.doSomething = function() { |
| + this.textContent = 'didSomething'; |
| + return 'didSomething'; |
| +}; |
| + |
| +Foo = document.registerElement('x-foo', Foo); |
| + |
| +function validateIsFoo(element) { |
| + if (!(element instanceof Foo)) { |
| + throw Error('Element is not a Foo'); |
| + } |
| + |
| + if (!element.fooCreated) { |
| + throw Error('Expected fooCreated to be set'); |
| + } |
| +} |
| +</script> |
| + |
| + <script type="text/javascript" |
| + src="/root_dart/tools/testing/dart/test_controller.js"></script> |
| + <script type="text/javascript" |
| + src="/packages/browser/interop.js"></script> |
|
blois
2014/04/15 19:29:12
Added interop.js
|
| + %TEST_SCRIPTS% |
| +</body> |