Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <script src="/js-test-resources/js-test.js"></script> | 3 <script src="/js-test-resources/js-test.js"></script> |
| 4 <body> | 4 <body> |
| 5 <p id="description"></p> | 5 <p id="description"></p> |
| 6 <p id="console"></p> | 6 <p id="console"></p> |
| 7 <iframe src="data:text/html,"></iframe> | 7 <iframe src="data:text/html," onload="onFrameLoad()"></iframe> |
| 8 <script> | 8 <script> |
| 9 // We should change the iframe src only after it finishes loading to avoid | |
| 10 // timing bugs due to PlzNavigate or cases where the browser handles all | |
| 11 // navigations. | |
| 12 var srcChanged = false; | |
|
ananta
2017/01/14 02:24:55
Should this function be moved to js-test.js or ano
Nate Chapin
2017/01/18 22:14:11
I don't feel strongly, do you see other tests that
| |
| 13 function onFrameLoad() { | |
| 14 if (window.testRunner && !srcChanged) { | |
| 15 testRunner.setIsolatedWorldSecurityOrigin(2, 'chrome-extension://123'); | |
| 16 var iframe = document.getElementsByTagName('iframe')[0]; | |
| 17 iframe.focus(); | |
| 18 iframe.src = 'http://subdomain.example.test:8000/security/resources/cross-fr ame-iframe-for-parent-isolated-world.html'; | |
| 19 } | |
| 20 } | |
| 21 | |
| 9 window.jsTestIsAsync = true; | 22 window.jsTestIsAsync = true; |
| 10 if (document.location.hostname == '127.0.0.1') { | 23 if (document.location.hostname == '127.0.0.1') { |
| 11 document.location.hostname = 'subdomain.example.test'; | 24 document.location.hostname = 'subdomain.example.test'; |
| 12 } else { | 25 } else { |
| 13 description('Tests that isolated worlds do not allow cross-origin frame acce ss'); | 26 description('Tests that isolated worlds do not allow cross-origin frame acce ss'); |
| 14 | 27 |
| 15 if (window.testRunner) { | 28 if (window.testRunner) { |
| 16 window.addEventListener('message', function(event) { | 29 window.addEventListener('message', function(event) { |
| 17 var message = JSON.parse(event.data); | 30 var message = JSON.parse(event.data); |
| 18 switch (message.type) { | 31 switch (message.type) { |
| 19 case 'debug': | 32 case 'debug': |
| 20 debug(message.message); | 33 debug(message.message); |
| 21 break; | 34 break; |
| 22 case 'finish': | 35 case 'finish': |
| 23 finishJSTest(); | 36 finishJSTest(); |
| 24 break; | 37 break; |
| 25 } | 38 } |
| 26 }); | 39 }); |
| 27 | 40 |
| 28 testRunner.setIsolatedWorldSecurityOrigin(2, 'chrome-extension://123'); | |
| 29 var iframe = document.getElementsByTagName('iframe')[0]; | |
| 30 iframe.focus(); | |
| 31 document.domain = 'example.test'; | 41 document.domain = 'example.test'; |
| 32 iframe.src = 'http://subdomain.example.test:8000/security/resources/cros s-frame-iframe-for-parent-isolated-world.html'; | |
| 33 } else { | 42 } else { |
| 34 testFailed('Test depends on LayoutTestController and must be run by DRT' ); | 43 testFailed('Test depends on LayoutTestController and must be run by DRT' ); |
| 35 } | 44 } |
| 36 } | 45 } |
| 37 </script> | 46 </script> |
| 38 </body> | 47 </body> |
| 39 </html> | 48 </html> |
| OLD | NEW |