Chromium Code Reviews| Index: LayoutTests/dart/multi-wrapper-test.html |
| diff --git a/LayoutTests/dart/multi-wrapper-test.html b/LayoutTests/dart/multi-wrapper-test.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..56b301c96748ba52002ca7bc351f35e6cfc273e2 |
| --- /dev/null |
| +++ b/LayoutTests/dart/multi-wrapper-test.html |
| @@ -0,0 +1,92 @@ |
| +<html> |
| +<body> |
| + |
| +<script> |
| +if (window.testRunner) { |
| + window.testRunner.dumpAsText(); |
| + window.testRunner.waitUntilDone(); |
| +} |
| +</script> |
| + |
| +<div id="dart"> |
| +import 'dart:js'; |
| +import 'dart:html'; |
| + |
| +var retainDocument; |
| +var retainCustom; |
| +var retainCustomWithCallback; |
| + |
| +void main() { |
| + retainDocument = document; |
| + retainCustom = querySelector('#custom'); |
| + retainCustomWithCallback = querySelector('#callback'); |
| + window.postMessage('hello', '*', []); |
| +} |
| +</div> |
| + |
| +<x-custom id="custom"></x-custom> |
| +<x-callback id="callback"></x-callback> |
| + |
| +<script type="application/dart"> |
| +import 'dart:html'; |
| +import 'dart:isolate'; |
| +import 'dart:js'; |
| + |
| +class XCustom extends HtmlElement { |
| + static final tag = 'x-custom'; |
| + factory XCustom() => new Element.tag(tag); |
| + XCustom.created() : super.created(); |
| + String toString() => "XCustom"; |
| +} |
| + |
| +class XCustomWithCallback extends HtmlElement { |
| + static final tag = 'x-callback'; |
| + factory XCustomWithCallback() => new Element.tag(tag); |
| + XCustomWithCallback.created() : super.created() { |
| + print("During upgrade: ${querySelector('#callback')}"); |
| + } |
| + String toString() => "XCustomWithCallback"; |
| +} |
| + |
| +var hellos = 0; |
| +void main() { |
| + window.onMessage.listen((Event event) { |
| + if (event.data == 'hello') { |
| + hellos++; |
| + print("Hello World $hellos"); |
| + if (hellos == 3) { |
| + var custom = querySelector('#custom'); |
|
vsm
2014/06/06 13:39:45
Perhaps query this also before you launch the dom
rmacnak
2014/06/06 21:26:30
Added.
|
| + print("Before upgrade: $custom"); |
| + var upgrader = document.createElementUpgrader(XCustom); |
| + upgrader.upgrade(custom); |
| + custom = querySelector('#custom'); |
| + print("After upgrade: $custom"); |
| + |
| + var callback = querySelector('#callback'); |
| + print("Before upgrade: $callback"); |
| + upgrader = document.createElementUpgrader(XCustomWithCallback); |
| + upgrader.upgrade(callback); |
| + callback = querySelector('#callback'); |
| + print("After upgrade: $callback"); |
| + |
| + context['testRunner'].callMethod('notifyDone', []); |
| + } |
| + } |
| + }); |
| + |
| + var code = querySelector('#dart'); |
| + var dataUri = 'data:application/dart;base64,${window.btoa(code.text)}'; |
| + try { |
| + Future<Isolate> isolate1 = spawnDomUri(Uri.parse(dataUri), [], null); |
| + Future<Isolate> isolate2 = spawnDomUri(Uri.parse(dataUri), [], null); |
| + Future<Isolate> isolate3 = spawnDomUri(Uri.parse(dataUri), [], null); |
| + } catch (e) { |
| + print("Spawn failed: $e"); |
| + context['testRunner'].callMethod('notifyDone', []); |
| + } |
| + code.remove(); |
| +} |
| +</script> |
| + |
| +</body> |
| +</html> |