WebKitTools:
[WebKit-https.git] / LayoutTests / http / tests / security / local-JavaScript-from-remote.html
1 <html>
2 <head>
3     <script>
4         var secretness = 0;
5
6         function test() {
7             if (window.layoutTestController)
8                 layoutTestController.dumpAsText();
9
10             var localScriptLocation = "file:///tmp/LayoutTests/http/tests/security/resources/localScript.js";
11             if (window.layoutTestController)
12                 localScriptLocation = layoutTestController.pathToLocalResource(localScriptLocation);
13
14             var localScriptElement = document.createElement("script");
15             localScriptElement.setAttribute("src", localScriptLocation);
16             localScriptElement.addEventListener("load", function() {
17                 var tag = document.getElementById("result");
18                 if (secretness == 13)
19                     tag.innerHTML = "Test Failed. Local script loaded and run.";
20                 else
21                     tag.innerHTML = "Test Failed. Local script loaded, but not successfully run.";
22             });
23
24             localScriptElement.addEventListener("error", function() {
25                 var tag = document.getElementById("result");
26                 tag.innerHTML = "Test Passed: Local script not loaded.";
27             });
28
29             document.body.appendChild(localScriptElement)
30         }
31     </script>
32 </head>
33 <body onload="test()">
34     <div id="div0">
35         This test is to see if a remote file can run a local script.
36         <br/>
37         Currently this test cannot be run manually on Windows because we do not have
38         a function like pathToLocalResource() outside of DRT.
39         <br/>
40     </div>
41     <br>
42     <div id="result">
43         Test not run correctly.
44     </div>
45 </body>
46 </html>