| OLD | NEW |
| 1 library InnerFrameTest; | 1 library InnerFrameTest; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 | 5 |
| 6 main() { | 6 main() { |
| 7 if (window != window.top) { | 7 if (window != window.top) { |
| 8 // Child frame. | 8 // Child frame. |
| 9 | 9 |
| 10 // The child's frame should not be able to access its parent's | 10 // The child's frame should not be able to access its parent's |
| 11 // document. | 11 // document. |
| 12 | 12 |
| 13 window.on.message.add((Event e) { | 13 window.onMessage.listen((Event e) { |
| 14 switch (e.data) { | 14 switch (e.data) { |
| 15 case 'frameElement': { | 15 case 'frameElement': { |
| 16 // Check window.frameElement. | 16 // Check window.frameElement. |
| 17 try { | 17 try { |
| 18 var parentDocument = window.frameElement.document; | 18 var parentDocument = window.frameElement.document; |
| 19 var div = parentDocument.$dom_createElement("div"); | 19 var div = parentDocument.$dom_createElement("div"); |
| 20 div.id = "illegalFrameElement"; | 20 div.id = "illegalFrameElement"; |
| 21 parentDocument.body.nodes.add(div); | 21 parentDocument.body.nodes.add(div); |
| 22 expect(false, isTrue, reason: 'Should not reach here.'); | 22 expect(false, isTrue, reason: 'Should not reach here.'); |
| 23 } on NoSuchMethodError catch (e) { | 23 } on NoSuchMethodError catch (e) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Parent / test frame | 69 // Parent / test frame |
| 70 useHtmlConfiguration(); | 70 useHtmlConfiguration(); |
| 71 | 71 |
| 72 final iframe = new Element.tag('iframe'); | 72 final iframe = new Element.tag('iframe'); |
| 73 iframe.src = window.location.href; | 73 iframe.src = window.location.href; |
| 74 var child; | 74 var child; |
| 75 | 75 |
| 76 test('prepare', () { | 76 test('prepare', () { |
| 77 iframe.on.load.add(expectAsync1((e) { child = iframe.contentWindow;})); | 77 iframe.onLoad.listen(expectAsync1((e) { child = iframe.contentWindow;})); |
| 78 document.body.nodes.add(iframe); | 78 document.body.nodes.add(iframe); |
| 79 }); | 79 }); |
| 80 | 80 |
| 81 final validate = (testName, verify) { | 81 final validate = (testName, verify) { |
| 82 final expectedVerify = expectAsync0(verify); | 82 final expectedVerify = expectAsync0(verify); |
| 83 window.on.message.add((e) { | 83 window.onMessage.listen((e) { |
| 84 guardAsync(() { | 84 guardAsync(() { |
| 85 if (e.data == 'pass_$testName') { | 85 if (e.data == 'pass_$testName') { |
| 86 expectedVerify(); | 86 expectedVerify(); |
| 87 } | 87 } |
| 88 expect(e.data, isNot(equals('fail_$testName'))); | 88 expect(e.data, isNot(equals('fail_$testName'))); |
| 89 }); | 89 }); |
| 90 }); | 90 }); |
| 91 child.postMessage(testName, '*'); | 91 child.postMessage(testName, '*'); |
| 92 }; | 92 }; |
| 93 | 93 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 111 | 111 |
| 112 test('parent', () { | 112 test('parent', () { |
| 113 validate('parent', () { | 113 validate('parent', () { |
| 114 var div = document.query('#illegalParent'); | 114 var div = document.query('#illegalParent'); |
| 115 | 115 |
| 116 // Ensure that this parent frame was not modified by its child. | 116 // Ensure that this parent frame was not modified by its child. |
| 117 expect(div, isNull); | 117 expect(div, isNull); |
| 118 }); | 118 }); |
| 119 }); | 119 }); |
| 120 } | 120 } |
| OLD | NEW |