| OLD | NEW |
| (Empty) | |
| 1 #library('InnerFrameTest'); |
| 2 #import('../../lib/unittest/unittest.dart'); |
| 3 #import('../../lib/unittest/html_config.dart'); |
| 4 #import('dart:html'); |
| 5 |
| 6 main() { |
| 7 if (window != window.top) { |
| 8 // Child frame. |
| 9 |
| 10 // The child's frame should not be able to access its parent's |
| 11 // document. |
| 12 |
| 13 // Check window.frameElement. |
| 14 try { |
| 15 var parentDocument = window.frameElement.document; |
| 16 var div = parentDocument.$dom_createElement("div"); |
| 17 div.id = "illegalFrameElement"; |
| 18 parentDocument.body.nodes.add(div); |
| 19 Expect.fail('Should not reach here.'); |
| 20 } catch (NoSuchMethodException e) { |
| 21 // Expected. |
| 22 } |
| 23 |
| 24 // Check window.top. |
| 25 try { |
| 26 final top = window.top; |
| 27 var parentDocument = top.document; |
| 28 var div = parentDocument.$dom_createElement("div"); |
| 29 div.id = "illegalTop"; |
| 30 parentDocument.body.nodes.add(div); |
| 31 Expect.fail('Should not reach here.'); |
| 32 } catch (var e) { |
| 33 // Expected. |
| 34 // TODO(vsm): Enforce this is a NoSuchMethodException. |
| 35 } |
| 36 return; |
| 37 } |
| 38 |
| 39 // Parent / test frame |
| 40 useHtmlConfiguration(); |
| 41 |
| 42 final iframe = new Element.tag('iframe'); |
| 43 iframe.src = window.location.href; |
| 44 |
| 45 asyncTest('prepare', 1, () { |
| 46 iframe.on.load.add((e) => callbackDone()); |
| 47 document.body.nodes.add(iframe); |
| 48 }); |
| 49 |
| 50 test('frameElement', () { |
| 51 var div = document.query('#illegalFrameElement'); |
| 52 |
| 53 // Ensure that this parent frame was not modified by its child. |
| 54 Expect.isNull(div); |
| 55 }); |
| 56 |
| 57 test('top', () { |
| 58 var div = document.query('#illegalTop'); |
| 59 |
| 60 // Ensure that this parent frame was not modified by its child. |
| 61 Expect.isNull(div); |
| 62 }); |
| 63 } |
| OLD | NEW |