OLD | NEW |
| (Empty) |
1 #library('InnerFrameTest'); | |
2 #import('../../../../lib/unittest/unittest.dart'); | |
3 #import('../../../../lib/unittest/dom_config.dart'); | |
4 #import('dart:dom'); | |
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.ownerDocument; | |
16 var div = parentDocument.createElement("div"); | |
17 div.id = "illegalFrameElement"; | |
18 parentDocument.body.appendChild(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.createElement("div"); | |
29 div.id = "illegalTop"; | |
30 parentDocument.body.appendChild(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 useDomConfiguration(); | |
41 | |
42 final iframe = document.createElement('iframe'); | |
43 iframe.src = window.location.href; | |
44 | |
45 asyncTest('prepare', 1, () { | |
46 iframe.addEventListener('load', (e) => callbackDone(), false); | |
47 document.body.appendChild(iframe); | |
48 }); | |
49 | |
50 test('frameElement', () { | |
51 var div = document.getElementById('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.getElementById('illegalTop'); | |
59 | |
60 // Ensure that this parent frame was not modified by its child. | |
61 Expect.isNull(div); | |
62 }); | |
63 } | |
OLD | NEW |