Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <body> | |
| 3 | |
| 4 <script> | |
| 5 if (window.testRunner) { | |
| 6 window.testRunner.dumpAsText(); | |
| 7 window.testRunner.waitUntilDone(); | |
| 8 } | |
| 9 </script> | |
| 10 | |
| 11 <div id="dart"> | |
| 12 import 'dart:js'; | |
| 13 import 'dart:html'; | |
| 14 | |
| 15 var retainDocument; | |
| 16 var retainCustom; | |
| 17 var retainCustomWithCallback; | |
| 18 | |
| 19 void main() { | |
| 20 retainDocument = document; | |
| 21 retainCustom = querySelector('#custom'); | |
| 22 retainCustomWithCallback = querySelector('#callback'); | |
| 23 window.postMessage('hello', '*', []); | |
| 24 } | |
| 25 </div> | |
| 26 | |
| 27 <x-custom id="custom"></x-custom> | |
| 28 <x-callback id="callback"></x-callback> | |
| 29 | |
| 30 <script type="application/dart"> | |
| 31 import 'dart:html'; | |
| 32 import 'dart:isolate'; | |
| 33 import 'dart:js'; | |
| 34 | |
| 35 class XCustom extends HtmlElement { | |
| 36 static final tag = 'x-custom'; | |
| 37 factory XCustom() => new Element.tag(tag); | |
| 38 XCustom.created() : super.created(); | |
| 39 String toString() => "XCustom"; | |
| 40 } | |
| 41 | |
| 42 class XCustomWithCallback extends HtmlElement { | |
| 43 static final tag = 'x-callback'; | |
| 44 factory XCustomWithCallback() => new Element.tag(tag); | |
| 45 XCustomWithCallback.created() : super.created() { | |
| 46 print("During upgrade: ${querySelector('#callback')}"); | |
| 47 } | |
| 48 String toString() => "XCustomWithCallback"; | |
| 49 } | |
| 50 | |
| 51 var hellos = 0; | |
| 52 void main() { | |
| 53 window.onMessage.listen((Event event) { | |
| 54 if (event.data == 'hello') { | |
| 55 hellos++; | |
| 56 print("Hello World $hellos"); | |
| 57 if (hellos == 3) { | |
| 58 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.
| |
| 59 print("Before upgrade: $custom"); | |
| 60 var upgrader = document.createElementUpgrader(XCustom); | |
| 61 upgrader.upgrade(custom); | |
| 62 custom = querySelector('#custom'); | |
| 63 print("After upgrade: $custom"); | |
| 64 | |
| 65 var callback = querySelector('#callback'); | |
| 66 print("Before upgrade: $callback"); | |
| 67 upgrader = document.createElementUpgrader(XCustomWithCallback); | |
| 68 upgrader.upgrade(callback); | |
| 69 callback = querySelector('#callback'); | |
| 70 print("After upgrade: $callback"); | |
| 71 | |
| 72 context['testRunner'].callMethod('notifyDone', []); | |
| 73 } | |
| 74 } | |
| 75 }); | |
| 76 | |
| 77 var code = querySelector('#dart'); | |
| 78 var dataUri = 'data:application/dart;base64,${window.btoa(code.text)}'; | |
| 79 try { | |
| 80 Future<Isolate> isolate1 = spawnDomUri(Uri.parse(dataUri), [], null); | |
| 81 Future<Isolate> isolate2 = spawnDomUri(Uri.parse(dataUri), [], null); | |
| 82 Future<Isolate> isolate3 = spawnDomUri(Uri.parse(dataUri), [], null); | |
| 83 } catch (e) { | |
| 84 print("Spawn failed: $e"); | |
| 85 context['testRunner'].callMethod('notifyDone', []); | |
| 86 } | |
| 87 code.remove(); | |
| 88 } | |
| 89 </script> | |
| 90 | |
| 91 </body> | |
| 92 </html> | |
| OLD | NEW |