Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / security / javascriptURL / javascriptURL-execution-context-frame-location-htmldom-uncaught.html
1 <html>
2 <head>
3     <script>
4         if (window.testRunner) {
5             testRunner.dumpAsText();
6             testRunner.dumpChildFramesAsText();
7             testRunner.waitUntilDone();
8         }
9
10         window.addEventListener('message', function() {
11             runTest();
12             if (window.testRunner)
13                 testRunner.notifyDone();
14         });
15
16         window.onerror = function (msg) {
17             var jsErrorMessage = 'Uncaught SecurityError: Failed to set the \'location\' property on \'HTMLFrameElement\': Blocked a frame with origin "http://127.0.0.1:8000" from accessing a cross-origin frame.';
18             if (msg == jsErrorMessage) 
19                 console.log("PASS: Exception was '" + msg + "'.");
20             else
21                 console.log("FAIL: Exception should have been '" + jsErrorMessage + "', was '" + msg + "'.");
22
23             if (window.testRunner)
24                 setTimeout(testRunner.notifyDone.bind(testRunner), 0);
25
26             return false; // Don't handle the exception to ensure it shows up in the console.
27         };
28
29         function runTest() {
30             var frame = document.getElementById('aFrame');
31             frame.location = 'javascript:"FAIL: this should not have been loaded."';
32         }
33     </script>
34 </head>
35 <frameset rows="10%,*">
36     <frame id='main' name='main' src="data:text/html,<p>This test passes as long as the onerror handler logs PASS to the console, and the uncaught exception reported to the console has unsanitized detail.</p>">
37     <frame id='aFrame' name="aFrame" src='http://localhost:8000/security/resources/cross-frame-iframe.html'>
38 </frameset>
39 </html>