Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: security/cross-frame-access.html

Issue 12221052: Remove use of deprecated test methods (asynctTest/callbackDone/expectThrows). Base URL: http://src.chromium.org/multivm/trunk/webkit/LayoutTests/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dom/Workers.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <body> 2 <body>
3 <script type='application/javascript' src='../../../../../dart/pkg/unittest/test _controller.js'></script> 3 <script type='application/javascript' src='../../../../../dart/pkg/unittest/test _controller.js'></script>
4 <script type=application/dart> 4 <script type=application/dart>
5 #import('../../../../../dart/pkg/unittest/lib/unittest.dart'); 5 #import('../../../../../dart/pkg/unittest/lib/unittest.dart');
6 #import('../../../../../dart/pkg/unittest/lib/html_config.dart'); 6 #import('../../../../../dart/pkg/unittest/lib/html_config.dart');
7 #import('dart:html'); 7 #import('dart:html');
8 8
9 main() { 9 main() {
10 useHtmlConfiguration(true); 10 useHtmlConfiguration(true);
11 11
12 final sameOriginIFrame = new Element.tag('iframe'); 12 final sameOriginIFrame = new Element.tag('iframe');
13 sameOriginIFrame.src = 'resources/cross-frame-access-iframe.html'; 13 sameOriginIFrame.src = 'resources/cross-frame-access-iframe.html';
14 14
15 final crossOriginIFrame = new Element.tag('iframe'); 15 final crossOriginIFrame = new Element.tag('iframe');
16 crossOriginIFrame.src = 'data:text/html, <p>test iframe</p>'; 16 crossOriginIFrame.src = 'data:text/html, <p>test iframe</p>';
17 17
18 asyncTest('WaitForFramesLoad', 2, () { 18 test('WaitForFramesLoad', () {
19 frameLoaded(Event e) { callbackDone(); } 19 var frameLoaded = expectAsync1((Event e) { }, count:2);
20 sameOriginIFrame.onLoad.listen(frameLoaded); 20 sameOriginIFrame.onLoad.listen(frameLoaded);
21 document.body.nodes.add(sameOriginIFrame); 21 document.body.nodes.add(sameOriginIFrame);
22 crossOriginIFrame.onLoad.listen(frameLoaded); 22 crossOriginIFrame.onLoad.listen(frameLoaded);
23 document.body.nodes.add(crossOriginIFrame); 23 document.body.nodes.add(crossOriginIFrame);
24 }); 24 });
25 25
26 test('Window', () { 26 test('Window', () {
27 testWindow(sameOriginIFrame.contentWindow); 27 testWindow(sameOriginIFrame.contentWindow);
28 testWindow(crossOriginIFrame.contentWindow); 28 testWindow(crossOriginIFrame.contentWindow);
29 }); 29 });
30 30
31 test('History', () { 31 test('History', () {
32 testHistory(sameOriginIFrame.contentWindow.history); 32 testHistory(sameOriginIFrame.contentWindow.history);
33 testHistory(crossOriginIFrame.contentWindow.history); 33 testHistory(crossOriginIFrame.contentWindow.history);
34 }); 34 });
35 35
36 asyncTest('Location', 2, () { 36 test('Location', () {
37 testLocation(sameOriginIFrame.contentWindow.location); 37 testLocation(sameOriginIFrame.contentWindow.location);
38 testLocation(crossOriginIFrame.contentWindow.location); 38 testLocation(crossOriginIFrame.contentWindow.location);
39 }); 39 });
40 40
41 test('IFrameElement', () { 41 test('IFrameElement', () {
42 testIFrameElement(sameOriginIFrame); 42 testIFrameElement(sameOriginIFrame);
43 testIFrameElement(crossOriginIFrame); 43 testIFrameElement(crossOriginIFrame);
44 }); 44 });
45 } 45 }
46 46
47 testWindow(WindowBase targetWindow) { 47 testWindow(WindowBase targetWindow) {
48 // Not allowed methods. 48 // Not allowed methods.
49 expectThrow(() => targetWindow.alert('test')); 49 expect(() => targetWindow.alert('test'), throws);
50 expectThrow(() => targetWindow.onLoad.listen((Event e) {})); 50 expect(() => targetWindow.onLoad.listen((Event e) {}), throws);
51 expectThrow(() => targetWindow.find('test', true, true, true, true, true, true )); 51 expect(() =>
52 targetWindow.find('test', true, true, true, true, true, true), throws);
52 53
53 // Not allowed properties. 54 // Not allowed properties.
54 expectThrow(() => targetWindow.contentDocument); 55 expect(() => targetWindow.contentDocument, throws);
55 expectThrow(() => targetWindow.frameElement); 56 expect(() => targetWindow.frameElement, throws);
56 expectThrow(() => targetWindow.localStorage); 57 expect(() => targetWindow.localStorage, throws);
57 expectThrow(() => targetWindow.console); 58 expect(() => targetWindow.console, throws);
58 59
59 // Allowed methods. 60 // Allowed methods.
60 targetWindow.close(); 61 targetWindow.close();
61 62
62 // Allowed properties. 63 // Allowed properties.
63 expect(targetWindow.location, isNotNull); 64 expect(targetWindow.location, isNotNull);
64 expect(targetWindow.history, isNotNull); 65 expect(targetWindow.history, isNotNull);
65 expect(targetWindow.parent, isNotNull); 66 expect(targetWindow.parent, isNotNull);
66 } 67 }
67 68
68 testHistory(HistoryBase history) { 69 testHistory(HistoryBase history) {
69 // Not allowed properties. 70 // Not allowed properties.
70 expectThrow(() => history.length); 71 expect(() => history.length, throws);
71 72
72 // Not allowed methods. 73 // Not allowed methods.
73 window.history.pushState('test', 'test', 'test'); 74 window.history.pushState('test', 'test', 'test');
74 expectThrow(() => history.pushState('test', 'test', 'test')); 75 expect(() => history.pushState('test', 'test', 'test'), throws);
75 window.history.replaceState('test', 'test', 'test'); 76 window.history.replaceState('test', 'test', 'test');
76 expectThrow(() => history.replaceState('test', 'test', 'test')); 77 expect(() => history.replaceState('test', 'test', 'test'), throws);
77 78
78 // Allowed method. 79 // Allowed method.
79 history.back(); 80 history.back();
80 history.forward(); 81 history.forward();
81 history.go(-1); 82 history.go(-1);
82 } 83 }
83 84
84 testLocation(LocationBase location) { 85 testLocation(LocationBase location) {
85 // Not allowed properties. 86 // Not allowed properties.
86 expectThrow(() => location.href); 87 expect(() => location.href, throws);
87 expectThrow(() => location.protocol); 88 expect(() => location.protocol, throws);
88 expectThrow(() => location.host = 'test'); 89 expect(() => location.host = 'test', throws);
89 expectThrow(() => location.origin); 90 expect(() => location.origin, throws);
90 91
91 // Not allowed methods. 92 // Not allowed methods.
92 expectThrow(() => location.assign('http://www.webkit.org')); 93 expect(() => location.assign('http://www.webkit.org'), throws);
93 expectThrow(() => location.reload()); 94 expect(() => location.reload(), throws);
94 expectThrow(() => location.getParameter('test')); 95 expect(() => location.getParameter('test'), throws);
95 96
96 // Allowed properties. 97 // Allowed properties.
97 window.onMessage.listen((Event e) { 98 window.onMessage.listen(expectAsync1((Event e) {
98 expect(e.data, equals('navigated')); 99 expect(e.data, equals('navigated'));
99 window.setTimeout(callbackDone, 0); 100 window.setTimeout(expectAsync0((){}), 0);
100 }); 101 }));
101 location.href = 'data:text/html, <script>parent.postMessage("navigated", "*")< ${"/script>"}'; 102 location.href = 'data:text/html, <script>parent.postMessage("navigated", "*")< ${"/script>"}';
102 } 103 }
103 104
104 testIFrameElement(IFrameElement iframe) { 105 testIFrameElement(IFrameElement iframe) {
105 expectThrow(() => iframe.contentDocument); 106 expect(() => iframe.contentDocument, throws);
106 expectThrow(() => iframe.getSVGDocument()); 107 expect(() => iframe.getSVGDocument(), throws);
107 } 108 }
108 </script> 109 </script>
109 110
110 </body> 111 </body>
111 </html> 112 </html>
OLDNEW
« no previous file with comments | « dom/Workers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698