| OLD | NEW |
| (Empty) |
| 1 <html> | |
| 2 <body> | |
| 3 <script type='application/javascript' src='../../../../../dart/client/testing/un
ittest/test_controller.js'></script> | |
| 4 <script type=application/dart> | |
| 5 #import('../../../../../dart/client/testing/unittest/unittest.dart'); | |
| 6 #import('dart:dom'); | |
| 7 | |
| 8 main() { | |
| 9 forLayoutTests(); | |
| 10 | |
| 11 final sameOriginIFrame = document.createElement('iframe'); | |
| 12 sameOriginIFrame.src = 'resources/cross-frame-access-iframe.html'; | |
| 13 | |
| 14 final crossOriginIFrame = document.createElement('iframe'); | |
| 15 crossOriginIFrame.src = 'data:text/html, <p>test iframe</p>'; | |
| 16 | |
| 17 asyncTest('WaitForFramesLoad', 2, () { | |
| 18 frameLoaded(Event e) { callbackDone(); } | |
| 19 sameOriginIFrame.addEventListener('load', frameLoaded, true); | |
| 20 document.body.appendChild(sameOriginIFrame); | |
| 21 crossOriginIFrame.addEventListener('load', frameLoaded, true); | |
| 22 document.body.appendChild(crossOriginIFrame); | |
| 23 }); | |
| 24 | |
| 25 test('DOMWindow', () { | |
| 26 testDOMWindow(sameOriginIFrame.contentWindow); | |
| 27 testDOMWindow(crossOriginIFrame.contentWindow); | |
| 28 }); | |
| 29 | |
| 30 test('History', () { | |
| 31 testHistory(sameOriginIFrame.contentWindow.history); | |
| 32 testHistory(crossOriginIFrame.contentWindow.history); | |
| 33 }); | |
| 34 | |
| 35 asyncTest('Location', 2, () { | |
| 36 testLocation(sameOriginIFrame.contentWindow.location); | |
| 37 testLocation(crossOriginIFrame.contentWindow.location); | |
| 38 }); | |
| 39 } | |
| 40 | |
| 41 testDOMWindow(DOMWindow targetWindow) { | |
| 42 // Not allowed methods. | |
| 43 expectThrow(() => targetWindow.alert('test')); | |
| 44 expectThrow(() => targetWindow.addEventListener('load', (Event e) {}, true)); | |
| 45 expectThrow(() => targetWindow.find('test', true, true, true, true, true, true
)); | |
| 46 | |
| 47 // Not allowed properties. | |
| 48 expectThrow(() => targetWindow.contentDocument); | |
| 49 expectThrow(() => targetWindow.localStorage); | |
| 50 expectThrow(() => targetWindow.console); | |
| 51 | |
| 52 // Allowed methods. | |
| 53 targetWindow.focus(); | |
| 54 targetWindow.blur(); | |
| 55 targetWindow.close(); | |
| 56 | |
| 57 // Allowed properties. | |
| 58 expect(targetWindow.location).isNotNull(); | |
| 59 expect(targetWindow.history).isNotNull(); | |
| 60 expect(targetWindow.parent).isNotNull(); | |
| 61 } | |
| 62 | |
| 63 testHistory(History history) { | |
| 64 // Not allowed properties. | |
| 65 expectThrow(() => history.length); | |
| 66 | |
| 67 // Not allowed methods. | |
| 68 window.history.pushState('test', 'test', 'test'); | |
| 69 expectThrow(() => history.pushState('test', 'test', 'test')); | |
| 70 window.history.replaceState('test', 'test', 'test'); | |
| 71 expectThrow(() => history.replaceState('test', 'test', 'test')); | |
| 72 | |
| 73 // Allowed method. | |
| 74 history.back(); | |
| 75 history.forward(); | |
| 76 history.go(-1); | |
| 77 } | |
| 78 | |
| 79 testLocation(Location location) { | |
| 80 // Not allowed properties. | |
| 81 expectThrow(() => location.href); | |
| 82 expectThrow(() => location.protocol); | |
| 83 expectThrow(() => location.host = 'test'); | |
| 84 expectThrow(() => location.origin); | |
| 85 | |
| 86 // Not allowed methods. | |
| 87 expectThrow(() => location.assign('http://www.webkit.org')); | |
| 88 expectThrow(() => location.reload()); | |
| 89 expectThrow(() => location.getParameter('test')); | |
| 90 | |
| 91 // Allowed properties. | |
| 92 window.addEventListener('message', (Event e) { | |
| 93 expect(e.data).equals('navigated'); | |
| 94 window.setTimeout(callbackDone, 0); | |
| 95 }); | |
| 96 location.href = 'data:text/html, <script>parent.postMessage("navigated", "*")<
' + '/script>'; | |
| 97 } | |
| 98 </script> | |
| 99 | |
| 100 </body> | |
| 101 </html> | |
| OLD | NEW |