WebKitTools:
[WebKit-https.git] / LayoutTests / fast / loader / local-CSS-from-local.html
1 <html>
2 <head>
3     <script>
4         function test() {
5             if (window.layoutTestController) {
6                 layoutTestController.dumpAsText();
7                 layoutTestController.waitUntilDone();
8             }
9
10             var localStyleSheetLocation = "file:///tmp/LayoutTests/http/tests/security/resources/cssStyle.css";
11             if (window.layoutTestController)
12                 localStyleSheetLocation = layoutTestController.pathToLocalResource(localStyleSheetLocation);
13
14             var localLinkElement = document.createElement("link");
15             localLinkElement.setAttribute("type", "text/css");
16             localLinkElement.setAttribute("rel", "stylesheet");
17             localLinkElement.setAttribute("href", localStyleSheetLocation);
18
19             document.documentElement.firstChild.appendChild(localLinkElement);
20
21             // Unfortunately link tags do not have load events, so we cannot simply make a load handler.
22             window.setTimeout(backgroundCheck, 1);
23             window.setTimeout(function() {
24                 if (window.layoutTestController)
25                     layoutTestController.notifyDone();
26             }, 5000);
27         }
28
29         function backgroundCheck() {
30             var result = document.getElementById("result");
31             var myBody = document.getElementById("myBody");
32             var style = document.defaultView.getComputedStyle(myBody, null);
33             var bgColor = style.getPropertyValue("background-color");
34             if (bgColor[4] == 2) {
35                 result.innerHTML = "Test Passed. Local CSS remotely loaded";
36                 if (window.layoutTestController)
37                     layoutTestController.notifyDone();
38             } else {
39                 result.innerHTML = "Test Failed: Local CSS not remotely loaded.";
40                 window.setTimeout(backgroundCheck, 1);
41             }
42         }
43
44     </script>
45 </head>
46 <body id="myBody" onload="test()">
47     <div id="div0">
48         This test is to see if a local file can include a local CSS style.
49         <br/>
50         Currently this test cannot be run manually on Windows because we do not have
51         a function like pathToLocalResource() outside of DRT.
52         <br/>
53         <br/>
54         If the background is yellow then the CSS was loaded.
55     </div>
56     <br/>
57     <div id="result">
58         Test not run correctly.
59     </div>
60 </body>
61 </html>