WebKitTools:
[WebKit-https.git] / LayoutTests / fast / loader / local-CSS-from-local.html
index 5f14bfb56fbf1e14ac0584b004ebb14b5d5680fa..1f8f866c950fd47d275334357194cf0e72d45d65 100644 (file)
@@ -1,31 +1,59 @@
 <html>
 <head>
-    <link rel="stylesheet" type="text/css" href="file:///tmp/LayoutTests/http/tests/security/resources/cssStyle.css" />
     <script>
-        if (window.layoutTestController) {
-            layoutTestController.dumpAsText();
+        function test() {
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.waitUntilDone();
+            }
+
+            var localStyleSheetLocation = "file:///tmp/LayoutTests/http/tests/security/resources/cssStyle.css";
+            if (window.layoutTestController)
+                localStyleSheetLocation = layoutTestController.pathToLocalResource(localStyleSheetLocation);
+
+            var localLinkElement = document.createElement("link");
+            localLinkElement.setAttribute("type", "text/css");
+            localLinkElement.setAttribute("rel", "stylesheet");
+            localLinkElement.setAttribute("href", localStyleSheetLocation);
+
+            document.documentElement.firstChild.appendChild(localLinkElement);
+
+            // Unfortunately link tags do not have load events, so we cannot simply make a load handler.
+            window.setTimeout(backgroundCheck, 1);
+            window.setTimeout(function() {
+                if (window.layoutTestController)
+                    layoutTestController.notifyDone();
+            }, 5000);
         }
-    
+
         function backgroundCheck() {
             var result = document.getElementById("result");
             var myBody = document.getElementById("myBody");
             var style = document.defaultView.getComputedStyle(myBody, null);
             var bgColor = style.getPropertyValue("background-color");
             if (bgColor[4] == 2) {
-                result.innerHTML = "Test Passed.";
+                result.innerHTML = "Test Passed. Local CSS remotely loaded";
+                if (window.layoutTestController)
+                    layoutTestController.notifyDone();
             } else {
                 result.innerHTML = "Test Failed: Local CSS not remotely loaded.";
+                window.setTimeout(backgroundCheck, 1);
             }
         }
+
     </script>
 </head>
-<body id="myBody" onload="backgroundCheck()">
+<body id="myBody" onload="test()">
     <div id="div0">
         This test is to see if a local file can include a local CSS style.
         <br/>
+        Currently this test cannot be run manually on Windows because we do not have
+        a function like pathToLocalResource() outside of DRT.
+        <br/>
+        <br/>
         If the background is yellow then the CSS was loaded.
     </div>
-    </br>
+    <br/>
     <div id="result">
         Test not run correctly.
     </div>