OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <body> |
| 3 |
| 4 <div id='foo'></div> |
| 5 |
| 6 <script type="application/dart"> |
| 7 import 'dart:html'; |
| 8 |
| 9 void main() { |
| 10 log("window.document is Document: ${document is Document}"); |
| 11 // FIXME: move into separate HTMLDocument test. |
| 12 Element foo = document.query('#foo'); |
| 13 log("window.document.query('#foo') is DivElement: ${foo is DivElement}"); |
| 14 Element missing = document.query('#missing_id'); |
| 15 log("window.document.query('#missing_id'): $missing"); |
| 16 bool closed = window.closed; |
| 17 log("window.closed: $closed"); |
| 18 window.name = "WindowAttr"; |
| 19 String name = window.name; |
| 20 log("window.name: '$name'"); |
| 21 mustThrow("window.name = 239", () { window.name = 239; }); |
| 22 // Note: later we may rethink it and treat null as allowed value. |
| 23 mustThrow("window.name = null", () { window.name = null; }); |
| 24 mustThrow("window.onload = 239", () { window.onload = 239; }); |
| 25 log("PASS"); |
| 26 } |
| 27 |
| 28 void mustThrow(String snippet, void code()) { |
| 29 // FIXME: re-enable when we don't immediately output exceptions into stdout. |
| 30 return; |
| 31 try { |
| 32 code(); |
| 33 log("FAILED: $snippet should have thrown"); |
| 34 } catch(e) { |
| 35 log("$snippet threw $e"); |
| 36 } |
| 37 } |
| 38 |
| 39 void log(String msg) { |
| 40 Element element = new Element.tag('div'); |
| 41 element.innerHtml = msg; |
| 42 document.body.nodes.add(element); |
| 43 } |
| 44 </script> |
| 45 |
| 46 <script> |
| 47 if (window.testRunner) |
| 48 window.testRunner.dumpAsText(); |
| 49 </script> |
| 50 |
| 51 </body> |
| 52 </html> |
OLD | NEW |