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 var retainThrow; |
| 19 |
| 20 void main() { |
| 21 retainDocument = document; |
| 22 retainCustom = querySelector('#custom'); |
| 23 retainCustomWithCallback = querySelector('#callback'); |
| 24 retainThrow = querySelector('#throw'); |
| 25 window.postMessage('hello', '*', []); |
| 26 } |
| 27 </div> |
| 28 |
| 29 <x-custom id="custom"></x-custom> |
| 30 <x-callback id="callback"></x-callback> |
| 31 <x-throw id="throw"></x-throw> |
| 32 |
| 33 <script type="application/dart"> |
| 34 import 'dart:html'; |
| 35 import 'dart:isolate'; |
| 36 import 'dart:js'; |
| 37 |
| 38 class XCustom extends HtmlElement { |
| 39 static final tag = 'x-custom'; |
| 40 factory XCustom() => new Element.tag(tag); |
| 41 XCustom.created() : super.created(); |
| 42 String toString() => "XCustom"; |
| 43 } |
| 44 |
| 45 class XCustomWithCallback extends HtmlElement { |
| 46 static final tag = 'x-callback'; |
| 47 factory XCustomWithCallback() => new Element.tag(tag); |
| 48 XCustomWithCallback.created() : super.created() { |
| 49 print("During upgrade: ${querySelector('#callback')}"); |
| 50 } |
| 51 String toString() => "XCustomWithCallback"; |
| 52 } |
| 53 |
| 54 class XThrow extends HtmlElement { |
| 55 static final tag = 'x-throw'; |
| 56 factory XThrow() => new Element.tag(tag); |
| 57 XThrow.created() : super.created() { |
| 58 throw new Exception("XThrow throws"); |
| 59 } |
| 60 } |
| 61 |
| 62 var earlyCustom; |
| 63 var hellos = 0; |
| 64 void main() { |
| 65 window.onMessage.listen((Event event) { |
| 66 if (event.data == 'hello') { |
| 67 hellos++; |
| 68 print("Hello World $hellos"); |
| 69 if (hellos == 3) { |
| 70 var custom = querySelector('#custom'); |
| 71 print("Same wrapper after spawning: ${identical(custom, earlyCustom)}"); |
| 72 print("Before upgrade: $custom"); |
| 73 var upgrader = document.createElementUpgrader(XCustom); |
| 74 upgrader.upgrade(custom); |
| 75 custom = querySelector('#custom'); |
| 76 print("After upgrade: $custom"); |
| 77 |
| 78 var callback = querySelector('#callback'); |
| 79 print("Before upgrade: $callback"); |
| 80 upgrader = document.createElementUpgrader(XCustomWithCallback); |
| 81 upgrader.upgrade(callback); |
| 82 callback = querySelector('#callback'); |
| 83 print("After upgrade: $callback"); |
| 84 |
| 85 document.registerElement(XThrow.tag, XThrow); |
| 86 print(querySelector('#throw')); |
| 87 |
| 88 context['testRunner'].callMethod('notifyDone', []); |
| 89 } |
| 90 } |
| 91 }); |
| 92 |
| 93 earlyCustom = querySelector('#custom'); |
| 94 var code = querySelector('#dart'); |
| 95 var dataUri = 'data:application/dart;base64,${window.btoa(code.text)}'; |
| 96 try { |
| 97 Future<Isolate> isolate1 = spawnDomUri(Uri.parse(dataUri), [], null); |
| 98 Future<Isolate> isolate2 = spawnDomUri(Uri.parse(dataUri), [], null); |
| 99 Future<Isolate> isolate3 = spawnDomUri(Uri.parse(dataUri), [], null); |
| 100 } catch (e) { |
| 101 print("Spawn failed: $e"); |
| 102 context['testRunner'].callMethod('notifyDone', []); |
| 103 } |
| 104 code.remove(); |
| 105 } |
| 106 </script> |
| 107 |
| 108 </body> |
| 109 </html> |
OLD | NEW |