WebKitTools:
authorkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Dec 2007 19:07:39 +0000 (19:07 +0000)
committerkmccullough@apple.com <kmccullough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Dec 2007 19:07:39 +0000 (19:07 +0000)
        Reviewed by Alice and Sam.

        - <rdar://5621435> Need a way to specify local resources (being loaded
        from HTTP tests) on Windows.
        - Implemented pathToLocalResource which exposes the functionality of
        converting a given unix path to the correct location on Windows.

        * DumpRenderTree/LayoutTestController.cpp:
        (pathToLocalResourceCallback):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
        (LayoutTestController::pathToLocalResource):
        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
        (LayoutTestController::pathToLocalResource):

LayoutTests:

        Reviewed by Alice and Sam.

        - <rdar://5621435> Need a way to specify local resources (being loaded
        from HTTP tests) on Windows.
        - Updated the following tests to use the new layoutTestController
        function, pathToLocalResource to get a Windows viable path (when on
        Windows) to the local resources they are attempting to access.
        - Also clarified and updated some results.

        * fast/dom/frame-loading-via-document-write.html:
        * fast/loader/local-CSS-from-local-expected.txt:
        * fast/loader/local-CSS-from-local.html:
        * fast/loader/local-JavaScript-from-local-expected.txt:
        * fast/loader/local-JavaScript-from-local.html:
        * fast/loader/local-iFrame-source-from-local-expected.txt:
        * fast/loader/local-iFrame-source-from-local.html:
        * fast/loader/local-image-from-local-expected.txt:
        * fast/loader/local-image-from-local.html:
        * http/tests/security/frame-loading-via-document-write.html:
        * http/tests/security/local-CSS-from-remote-expected.txt:
        * http/tests/security/local-CSS-from-remote.html:
        * http/tests/security/local-JavaScript-from-remote-expected.txt:
        * http/tests/security/local-JavaScript-from-remote.html:
        * http/tests/security/local-iFrame-from-remote-expected.txt:
        * http/tests/security/local-iFrame-from-remote.html:
        * http/tests/security/local-image-from-remote-expected.txt:
        * http/tests/security/local-image-from-remote.html:
        * http/tests/security/local-user-CSS-from-remote.html:
        * platform/mac/fast/dom/frame-loading-via-document-write-expected.txt:
        * platform/win/Skipped:
        * platform/win/http: Added.
        * platform/win/http/tests: Added.
        * platform/win/http/tests/security: Added.
        * platform/win/http/tests/security/frame-loading-via-document-write-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28690 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/frame-loading-via-document-write.html
LayoutTests/fast/loader/local-CSS-from-local-expected.txt
LayoutTests/fast/loader/local-CSS-from-local.html
LayoutTests/fast/loader/local-JavaScript-from-local-expected.txt
LayoutTests/fast/loader/local-JavaScript-from-local.html
LayoutTests/fast/loader/local-iFrame-source-from-local-expected.txt
LayoutTests/fast/loader/local-iFrame-source-from-local.html
LayoutTests/fast/loader/local-image-from-local-expected.txt
LayoutTests/fast/loader/local-image-from-local.html
LayoutTests/http/tests/security/frame-loading-via-document-write.html
LayoutTests/http/tests/security/local-CSS-from-remote-expected.txt
LayoutTests/http/tests/security/local-CSS-from-remote.html
LayoutTests/http/tests/security/local-JavaScript-from-remote-expected.txt
LayoutTests/http/tests/security/local-JavaScript-from-remote.html
LayoutTests/http/tests/security/local-iFrame-from-remote-expected.txt
LayoutTests/http/tests/security/local-iFrame-from-remote.html
LayoutTests/http/tests/security/local-image-from-remote-expected.txt
LayoutTests/http/tests/security/local-image-from-remote.html
LayoutTests/http/tests/security/local-user-CSS-from-remote.html
LayoutTests/platform/mac/fast/dom/frame-loading-via-document-write-expected.txt
LayoutTests/platform/win/Skipped
LayoutTests/platform/win/http/tests/security/frame-loading-via-document-write-expected.txt [new file with mode: 0644]
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/LayoutTestController.cpp
WebKitTools/DumpRenderTree/LayoutTestController.h
WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp

index f914642..7132daa 100644 (file)
@@ -1,3 +1,40 @@
+2007-12-13  Kevin McCullough  <kmccullough@apple.com>
+
+        Reviewed by Alice and Sam.
+
+        - <rdar://5621435> Need a way to specify local resources (being loaded
+        from HTTP tests) on Windows.
+        - Updated the following tests to use the new layoutTestController
+        function, pathToLocalResource to get a Windows viable path (when on
+        Windows) to the local resources they are attempting to access.
+        - Also clarified and updated some results.
+
+        * fast/dom/frame-loading-via-document-write.html:
+        * fast/loader/local-CSS-from-local-expected.txt:
+        * fast/loader/local-CSS-from-local.html:
+        * fast/loader/local-JavaScript-from-local-expected.txt:
+        * fast/loader/local-JavaScript-from-local.html:
+        * fast/loader/local-iFrame-source-from-local-expected.txt:
+        * fast/loader/local-iFrame-source-from-local.html:
+        * fast/loader/local-image-from-local-expected.txt:
+        * fast/loader/local-image-from-local.html:
+        * http/tests/security/frame-loading-via-document-write.html:
+        * http/tests/security/local-CSS-from-remote-expected.txt:
+        * http/tests/security/local-CSS-from-remote.html:
+        * http/tests/security/local-JavaScript-from-remote-expected.txt:
+        * http/tests/security/local-JavaScript-from-remote.html:
+        * http/tests/security/local-iFrame-from-remote-expected.txt:
+        * http/tests/security/local-iFrame-from-remote.html:
+        * http/tests/security/local-image-from-remote-expected.txt:
+        * http/tests/security/local-image-from-remote.html:
+        * http/tests/security/local-user-CSS-from-remote.html:
+        * platform/mac/fast/dom/frame-loading-via-document-write-expected.txt:
+        * platform/win/Skipped:
+        * platform/win/http: Added.
+        * platform/win/http/tests: Added.
+        * platform/win/http/tests/security: Added.
+        * platform/win/http/tests/security/frame-loading-via-document-write-expected.txt: Added.
+
 2007-12-13  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Adam Roben.
index 46d2cad..f14d44b 100644 (file)
@@ -6,8 +6,11 @@
 
 function buildFrameset()
 {
-    if (window.layoutTestController)
+    if (window.layoutTestController) {
         layoutTestController.waitUntilDone();
+        layoutTestController.dumpAsText();
+        layoutTestController.dumpChildFramesAsText();
+    }
 
     var outHTML="<frameset rows=\"33%, 33%, 33%\">"+
                 "<frame src=\"\" name=\"topRow\">"+
@@ -29,10 +32,14 @@ function buildFrameset()
     frames['topRow'].document. write(outHTML);
     frames['topRow'].document.close();
 
+    var localImageLocation = "file:////tmp/LayoutTests/fast/dom/resources/abe.png";
+    if (window.layoutTestController)
+        localImageLocation = layoutTestController.pathToLocalResource(localImageLocation);
+
     outHTML = "<html><head><scr" + "ipt language=\"JavaScript\" src=\"resources/frame-loading-via-document-write.js\">"+
               "</scr" + "ipt></head><body onLoad=\"didImageLoad()\"><table><tr><td>"+
               "<div id=\"result\"></div>"+
-              "<img src=\"file:////tmp/LayoutTests/fast/dom/resources/abe.png\" id=\"myImg\">"+
+              "<img src=\"" + localImageLocation + "\" id=\"myImg\">"+
               "</td></tr></table></body></html>";
 
     frames['middleRow'].document.open("text/html","replace");
index 0eb761a..d45a2e6 100644 (file)
@@ -1,4 +1,6 @@
 This test is to see if a local file can include a local CSS style. 
+Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. 
+
 If the background is yellow then the CSS was loaded.
 
-Test Passed.
+Test Passed. Local CSS remotely loaded
index 5f14bfb..1f8f866 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>
index 143eba6..d07d733 100644 (file)
@@ -1,3 +1,4 @@
-This test is to see if a local file can run a local script.
+This test is to see if a local file can run a local script. 
+Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. 
 
-Test Passed.
+Test Passed. Local script loaded and run.
index f8cc2c4..ff7f7c1 100644 (file)
@@ -1,25 +1,41 @@
 <html>
 <head>
-        <script>
-            var secretness = 0;
-        </script>
-        <script src="file:///tmp/LayoutTests/http/tests/security/resources/localScript.js"></script>
-        <script>
-            function test() {
-                if (window.layoutTestController)
-                    layoutTestController.dumpAsText();
+<script>
+    var secretness = 0;
 
-                    var tag = document.getElementById("result");
-                    if (secretness == 13)
-                        tag.innerHTML = "Test Passed.";
-                    else
-                        tag.innerHTML = "Test Failed: Local script not run by local file.";
-            }
-        </script>
+    function test() {
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+
+        var localScriptLocation = "file:///tmp/LayoutTests/http/tests/security/resources/localScript.js";
+        if (window.layoutTestController)
+            localScriptLocation = layoutTestController.pathToLocalResource(localScriptLocation);
+
+        var localScriptElement = document.createElement("script");
+        localScriptElement.setAttribute("src", localScriptLocation);
+        localScriptElement.addEventListener("load", function() {
+            var tag = document.getElementById("result");
+            if (secretness == 13)
+                tag.innerHTML = "Test Passed. Local script loaded and run.";
+            else
+                tag.innerHTML = "Test Failed. Local script loaded, but not successfully run.";
+        });
+        localScriptElement.addEventListener("error", function() {
+            var tag = document.getElementById("result");
+            tag.innerHTML = "Test Failed: Local script not loaded.";
+        });
+
+        document.body.appendChild(localScriptElement)
+    }
+</script>
 </head>
 <body onload="test()">
     <div id="div0">
         This test is to see if a local file can run a local script.
+        <br/>
+        Currently this test cannot be run manually on Windows because we do not have
+        a function like pathToLocalResource() outside of DRT.
+        <br/>
     </div>
     </br>
     <div id="result">
index 9080b41..69c347f 100644 (file)
@@ -1,4 +1,5 @@
-This test is to see if a local file can include a local page in an iFrame.
+This test is to see if a local file can include a local page in an iFrame. 
+Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. 
 
-Test Passed.
+Test Passed. Local page loaded locally into iFrame.
 
index ee359c1..d533a4b 100644 (file)
@@ -1,33 +1,41 @@
 <html>
 <head>
     <script>
-        if (window.layoutTestController) {
-            layoutTestController.dumpAsText();
-        }
-    
         function iFrameTest() {
             if (window.layoutTestController)
                 layoutTestController.dumpAsText();
 
+            var localPageLocation = "file:///tmp/LayoutTests/http/tests/security/resources/localPage.html";
+            if (window.layoutTestController)
+                localPageLocation = layoutTestController.pathToLocalResource(localPageLocation);
+
+            var localIframeElement = document.createElement("iFrame");
+            localIframeElement.setAttribute("id", "myFrame");
+            localIframeElement.setAttribute("src", localPageLocation);
+
+            document.body.appendChild(localIframeElement);
+    
             var result = document.getElementById("result");
 
             var myFrameDocument = document.getElementById("myFrame").contentDocument;
-            if (myFrameDocument) {
-                result.innerHTML = "Test Passed.";
-            } else {
+            if (myFrameDocument)
+                result.innerHTML = "Test Passed. Local page loaded locally into iFrame.";
+            else
                 result.innerHTML = "Test Failed: Local page not locally loaded into iFrame.";
-            }
         }
     </script>
 </head>
-<body>
+<body onload="iFrameTest()">
     <div id="div0">
         This test is to see if a local file can include a local page in an iFrame.
+        <br/>
+        Currently this test cannot be run manually on Windows because we do not have
+        a function like pathToLocalResource() outside of DRT.
+        <br/>
     </div>
     </br>
     <div id="result">
         Test not run correctly.
     </div>
-    <iFrame id="myFrame" onload="iFrameTest()" src="file:///tmp/LayoutTests/http/tests/security/resources/localPage.html" />
 </body>
 </html>
index 5fed28f..de49ae0 100644 (file)
@@ -1,5 +1,6 @@
-This test is to see if a remote file can include a local image.
+This test is to see if a remote file can include a local image. 
+Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. 
 
-Test Passed.
+Test Passed. Local image loaded.
 
 
index e53e3dd..583e12a 100644 (file)
@@ -4,6 +4,16 @@
         if (window.layoutTestController)
             layoutTestController.dumpAsText();
 
+        var localImageLocation = "file:///tmp/LayoutTests/http/tests/security/resources/compass.jpg";
+        if (window.layoutTestController)
+            localImageLocation = layoutTestController.pathToLocalResource(localImageLocation);
+
+        var localImageElement = document.createElement("img");
+        localImageElement.setAttribute("id", "myImg");
+        localImageElement.setAttribute("src", localImageLocation);
+        localImageElement.setAttribute("onError", "imgError()");
+        localImageElement.setAttribute("onLoad", "imgLoad()");
+
         function imgError() {
             var result = document.getElementById("result");
             result.innerHTML = "Test Failed: Image Load Error.";
 
         function imgLoad() {
             var result = document.getElementById("result");
-            result.innerHTML = "Test Passed.";
+            result.innerHTML = "Test Passed. Local image loaded.";
         }
     </script>
 </head>
-<body>
+<body onload="document.body.appendChild(localImageElement)">
     <div id="div0">
         This test is to see if a remote file can include a local image.
+        <br/>
+        Currently this test cannot be run manually on Windows because we do not have
+        a function like pathToLocalResource() outside of DRT.
+        <br/>
     </div>
     </br>
     <div id="result">
         Test has not run.
     </div>
     </br>
-    <img id="myImg" src="file:///tmp/LayoutTests/http/tests/security/resources/compass.jpg" onError="imgError()" onLoad="imgLoad()"/>
 </body>
 </html>
index 27976b0..4745e53 100644 (file)
@@ -1,12 +1,16 @@
 <html>
 <head>
+<title/>
 
 <script language="JavaScript">
 
 function buildFrameset()
 {
-    if (window.layoutTestController)
+    if (window.layoutTestController) {
         layoutTestController.waitUntilDone();
+        layoutTestController.dumpAsText();
+        layoutTestController.dumpChildFramesAsText();
+    }
 
     var outHTML="<frameset rows=\"33%, 33%, 33%\">"+
                 "<frame src=\"\" name=\"topRow\">"+
@@ -25,18 +29,22 @@ function buildFrameset()
 
     frames['topRow'].document.open("text/html","replace");
     frames['topRow'].document.charset=document.charset;
-    frames['topRow'].document. write(outHTML);
+    frames['topRow'].document.write(outHTML);
     frames['topRow'].document.close();
 
+    var localImageLocation = "file:////tmp/LayoutTests/fast/dom/resources/abe.png";
+    if (window.layoutTestController)
+        localImageLocation = layoutTestController.pathToLocalResource(localImageLocation);
+
     outHTML = "<html><head><scr" + "ipt language=\"JavaScript\" src=\"resources/frame-loading-via-document-write.js\">"+
               "</scr" + "ipt></head><body onLoad=\"didImageLoad()\"><table><tr><td>"+
               "<div id=\"result\"></div>"+
-              "<img src=\"file:////tmp/LayoutTests/fast/dom/resources/abe.png\" id=\"myImg\">"+
+              "<img src=\"" + localImageLocation + "\" id=\"myImg\">"+
               "</td></tr></table></body></html>";
 
     frames['middleRow'].document.open("text/html","replace");
     frames['middleRow'].document.charset=document.charset;
-    frames['middleRow'].document. write(outHTML);
+    frames['middleRow'].document.write(outHTML);
     frames['middleRow'].document.close();
 
     outHTML = "<html><head><scr" + "ipt language=\"JavaScript\" src=\"resources/frame-loading-via-document-write.js\">"+
@@ -47,7 +55,7 @@ function buildFrameset()
 
     frames['bottomRow'].document.open("text/html","replace");
     frames['bottomRow'].document.charset=document.charset;
-    frames['bottomRow'].document. write(outHTML);
+    frames['bottomRow'].document.write(outHTML);
     frames['bottomRow'].document.close();
 }
 
index 84fe30a..938f135 100644 (file)
@@ -1,5 +1,7 @@
-CONSOLE MESSAGE: line 0: Not allowed to load local resource: file:///tmp/LayoutTests/http/tests/security/resources/cssStyle.css
+CONSOLE MESSAGE: line 0: Not allowed to load local resource: file://C:/cygwin/home/PyongHopscotch/WebKit/OpenSource/LayoutTests/http/tests/security/resources/cssStyle.css
 This test is to see if a remote file can include a local CSS style. 
+Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. 
+
 If the background is yellow then the CSS was loaded.
 
-Test Passed.
+Test Passed: Local CSS not remotely loaded.
index 341b1d0..b7061e8 100644 (file)
@@ -1,28 +1,55 @@
 <html>
 <head>
-    <link rel="stylesheet" type="text/css" href="file:///tmp/LayoutTests/http/tests/security/resources/cssStyle.css" />
-    <script>
+<script>
+    function test() {
         if (window.layoutTestController) {
             layoutTestController.dumpAsText();
+            layoutTestController.waitUntilDone();
         }
 
-        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 Failed: Local CSS remotely loaded.";
-            } else {
-                result.innerHTML = "Test Passed.";
-            }
+        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 Failed: Local CSS remotely loaded.";
+            window.setTimeout(backgroundCheck, 1);
+        } else {
+            result.innerHTML = "Test Passed: Local CSS not remotely loaded.";
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
         }
-    </script>
+    }
+</script>
 </head>
-<body id="myBody" onload="backgroundCheck()">
+<body id="myBody" onload="test()">
     <div id="other">
         This test is to see if a remote 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>
index a3e0685..bba963c 100644 (file)
@@ -1,4 +1,5 @@
-CONSOLE MESSAGE: line 0: Not allowed to load local resource: file:///tmp/LayoutTests/http/tests/security/resources/localScript.js
-This test is to see if a remote file can run a local script.
+CONSOLE MESSAGE: line 0: Not allowed to load local resource: file://C:/cygwin/home/PyongHopscotch/WebKit/OpenSource/LayoutTests/http/tests/security/resources/localScript.js
+This test is to see if a remote file can run a local script. 
+Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. 
 
-Test Passed.
+Test Passed: Local script not loaded.
index bf5673d..231258e 100644 (file)
@@ -1,27 +1,44 @@
 <html>
 <head>
-        <script>
-            var secretness = 0;
-        </script>
-        <script src="file:///tmp/LayoutTests/http/tests/security/resources/localScript.js"></script>
-        <script>
-            function test() {
-                if (window.layoutTestController)
-                    layoutTestController.dumpAsText();
+    <script>
+        var secretness = 0;
 
+        function test() {
+            if (window.layoutTestController)
+                layoutTestController.dumpAsText();
+
+            var localScriptLocation = "file:///tmp/LayoutTests/http/tests/security/resources/localScript.js";
+            if (window.layoutTestController)
+                localScriptLocation = layoutTestController.pathToLocalResource(localScriptLocation);
+
+            var localScriptElement = document.createElement("script");
+            localScriptElement.setAttribute("src", localScriptLocation);
+            localScriptElement.addEventListener("load", function() {
                 var tag = document.getElementById("result");
                 if (secretness == 13)
-                    tag.innerHTML = "Test Failed: Local script run remotely.";
+                    tag.innerHTML = "Test Failed. Local script loaded and run.";
                 else
-                    tag.innerHTML = "Test Passed.";
-            }
-        </script>
+                    tag.innerHTML = "Test Failed. Local script loaded, but not successfully run.";
+            });
+
+            localScriptElement.addEventListener("error", function() {
+                var tag = document.getElementById("result");
+                tag.innerHTML = "Test Passed: Local script not loaded.";
+            });
+
+            document.body.appendChild(localScriptElement)
+        }
+    </script>
 </head>
 <body onload="test()">
     <div id="div0">
         This test is to see if a remote file can run a local script.
+        <br/>
+        Currently this test cannot be run manually on Windows because we do not have
+        a function like pathToLocalResource() outside of DRT.
+        <br/>
     </div>
-    </br>
+    <br>
     <div id="result">
         Test not run correctly.
     </div>
index e042de4..51443a2 100644 (file)
@@ -1,5 +1,6 @@
-CONSOLE MESSAGE: line 0: Not allowed to load local resource: file:///tmp/LayoutTests/http/tests/security/resources/localPage.html
-This test is to see if a remote file can include a local page in an iFrame.
+CONSOLE MESSAGE: line 0: Not allowed to load local resource: file://C:/cygwin/home/PyongHopscotch/WebKit/OpenSource/LayoutTests/http/tests/security/resources/localPage.html
+This test is to see if a remote file can include a local page in an iFrame. 
+Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. 
 
-Test Passed.
+Test Passed. Local page not remotely loaded into iFrame.
 
index 340a6cd..437857c 100644 (file)
@@ -1,31 +1,40 @@
 <html>
 <head>
     <script>
-        if (window.layoutTestController) {
+        if (window.layoutTestController)
             layoutTestController.dumpAsText();
-        }
-    
+
+        var localPageLocation = "file:///tmp/LayoutTests/http/tests/security/resources/localPage.html";
+        if (window.layoutTestController)
+            localPageLocation = layoutTestController.pathToLocalResource(localPageLocation);
+
+        var localIframeElement = document.createElement("iFrame");
+        localIframeElement.setAttribute("id", "myFrame");
+        localIframeElement.setAttribute("src", localPageLocation);
+
         function iFrameTest() {
-            var result = document.getElementById("result");
+            document.body.appendChild(localIframeElement);
 
+            var result = document.getElementById("result");
             var myFrameDocument = document.getElementById("myFrame").contentDocument;
-            if (myFrameDocument) {
+            if (myFrameDocument)
                 result.innerHTML = "Test Failed: Local page remotely loaded into iFrame.";
-            } else {
-                result.innerHTML = "Test Passed.";
-            }
-            
+            else
+                result.innerHTML = "Test Passed. Local page not remotely loaded into iFrame.";
         }
     </script>
 </head>
 <body onload="iFrameTest()">
     <div id="div0">
         This test is to see if a remote file can include a local page in an iFrame.
+        <br/>
+        Currently this test cannot be run manually on Windows because we do not have
+        a function like pathToLocalResource() outside of DRT.
+        <br/>
     </div>
     </br>
     <div id="result">
         Test not run correctly.
     </div>
-    <iFrame id="myFrame" src="file:///tmp/LayoutTests/http/tests/security/resources/localPage.html" />
 </body>
 </html>
index e8e3263..a9e88a5 100644 (file)
@@ -1,6 +1,7 @@
-CONSOLE MESSAGE: line 0: Not allowed to load local resource: file:///tmp/LayoutTests/http/tests/security/resources/compass.jpg
-This test is to see if a remote file can include a local image.
+CONSOLE MESSAGE: line 0: Not allowed to load local resource: file://C:/cygwin/home/PyongHopscotch/WebKit/OpenSource/LayoutTests/http/tests/security/resources/compass.jpg
+This test is to see if a remote file can include a local image. 
+Currently this test cannot be run manually on Windows because we do not have a function like pathToLocalResource() outside of DRT. 
 
-Test Passed.
+Test Passed. Local image not loaded remotely.
 
 
index 610eb22..59f0592 100644 (file)
@@ -1,31 +1,44 @@
 <html>
 <head>
-    <script>        
-        if (window.layoutTestController)
-            layoutTestController.dumpAsText();
-        
-        function imageTest() {
-            var result = document.getElementById("result");
 
-            var myImg = document.getElementById("myImg");
-            if (myImg.height == 0 && myImg.width == 0) {
-                result.innerHTML = "Test Passed.";
-            } else {
-                result.innerHTML = "Test Failed: Local image loaded remotely.";
-            }
-            
-        }
-    </script>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+
+    var localImageLocation = "file:///tmp/LayoutTests/http/tests/security/resources/compass.jpg";
+    if (window.layoutTestController)
+        localImageLocation = layoutTestController.pathToLocalResource(localImageLocation);
+
+    var localImageElement = document.createElement("img");
+    localImageElement.setAttribute("id", "myImg");
+    localImageElement.setAttribute("src", localImageLocation);
+
+    function imageTest() {
+        document.body.appendChild(localImageElement);
+
+        var result = document.getElementById("result");
+        var myImg = document.getElementById("myImg");
+
+        if (myImg.height == 0 && myImg.width == 0)
+            result.innerHTML = "Test Passed. Local image not loaded remotely.";
+        else
+            result.innerHTML = "Test Failed: Local image loaded remotely.";
+    }
+</script>
+
 </head>
 <body onLoad="imageTest()">
     <div id="div0">
         This test is to see if a remote file can include a local image.
+        <br/>
+        Currently this test cannot be run manually on Windows because we do not have
+        a function like pathToLocalResource() outside of DRT.
+        <br/>
     </div>
     </br>
     <div id="result">
         Test has not run.
     </div>
     </br>
-    <img id="myImg" src="file:///tmp/LayoutTests/http/tests/security/resources/compass.jpg" />
 </body>
 </html>
index 48b0b01..60c5699 100644 (file)
@@ -1,51 +1,50 @@
 <html>
-    <head>
-        <title>User Stylesheet Test</title>
-        <script type="text/javascript">
-            if (window.layoutTestController) {
-                layoutTestController.dumpAsText();
+<head>
+<title>User Stylesheet Test</title>
+<script type="text/javascript">
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
 
-                // This won't work outside of DRT!
-                if (window.location.hash == '') {
-                    layoutTestController.waitUntilDone();
-                    layoutTestController.setUserStyleSheetLocation("file:///tmp/LayoutTests/http/tests/security/resources/cssStyle.css");
-                    layoutTestController.setUserStyleSheetEnabled(true);
-                    location += '?#done';
-                }
-            }
+        // This won't work outside of DRT!
+        if (window.location.hash == '') {
+            layoutTestController.waitUntilDone();
+            layoutTestController.setUserStyleSheetLocation("file:///tmp/LayoutTests/http/tests/security/resources/cssStyle.css");
+            layoutTestController.setUserStyleSheetEnabled(true);
+            location += '?#done';
+        }
+    }
 
-            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: Local user stylesheet loaded.";
-                } else {
-                    result.innerHTML = "Test Failed: Local user stylesheet not loaded into remote document.";
-                }
+    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: Local user stylesheet loaded.";
+        } else {
+            result.innerHTML = "Test Failed: Local user stylesheet not loaded into remote document.";
+        }
 
-                if (window.layoutTestController) {
-                    layoutTestController.setUserStyleSheetEnabled(false);
-                    layoutTestController.notifyDone();
-                }
-
-            }
-        </script>
-    </head>
-    <body id="myBody" onload="backgroundCheck()">
-        <div id="other">
-            This test is to see if a remote file can include a local user stylesheet.
-            <br />
-            To run this test manually you must set your user style sheet in your Safari preferences
-            to LayoutTests/http/tests/security/resources/cssStyle.css
-            <br/>
-            If the background is yellow then the user stylesheet was loaded.
-        </div>
-        </br>
-        <div id="result">
-            Test not run correctly.
-        </div>
-    </body>
+        if (window.layoutTestController) {
+            layoutTestController.setUserStyleSheetEnabled(false);
+            layoutTestController.notifyDone();
+        }
+    }
+</script>
+</head>
+<body id="myBody" onload="backgroundCheck()">
+    <div id="other">
+        This test is to see if a remote file can include a local user stylesheet.
+        <br />
+        To run this test manually you must set your user style sheet in your Safari preferences
+        to LayoutTests/http/tests/security/resources/cssStyle.css
+        <br/>
+        If the background is yellow then the user stylesheet was loaded.
+    </div>
+    </br>
+    <div id="result">
+        Test not run correctly.
+    </div>
+</body>
 </html>
index 11c3297..5b69cb1 100644 (file)
@@ -1,54 +1,21 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderFrameSet {FRAMESET} at (0,0) size 800x600
-      RenderFrame {FRAME} at (0,0) size 800x196
-        layer at (0,0) size 800x196
-          RenderView at (0,0) size 800x196
-        layer at (0,0) size 800x196
-          RenderBlock {HTML} at (0,0) size 800x196
-            RenderBody {BODY} at (8,8) size 784x180
-              RenderBlock {DIV} at (0,0) size 784x54
-                RenderInline {SPAN} at (0,0) size 221x18
-                  RenderText {#text} at (0,0) size 221x18
-                    text run at (0,0) width 221: "This page was successfully loaded."
-                  RenderBR {BR} at (221,14) size 0x0
-                RenderInline {SPAN} at (0,0) size 120x18
-                  RenderText {#text} at (0,18) size 120x18
-                    text run at (0,18) width 120: "My protocol is file:"
-                  RenderBR {BR} at (120,32) size 0x0
-                RenderInline {SPAN} at (0,0) size 125x18
-                  RenderText {#text} at (0,36) size 125x18
-                    text run at (0,36) width 125: "My referrer is blank"
-                  RenderBR {BR} at (125,50) size 0x0
-      RenderFrame {FRAME} at (0,202) size 800x196
-        layer at (0,0) size 800x196
-          RenderView at (0,0) size 800x196
-        layer at (0,0) size 800x147
-          RenderBlock {HTML} at (0,0) size 800x147
-            RenderBody {BODY} at (8,8) size 784x131
-              RenderTable {TABLE} at (0,0) size 95x131
-                RenderTableSection {TBODY} at (0,0) size 95x131
-                  RenderTableRow {TR} at (0,2) size 95x127
-                    RenderTableCell {TD} at (2,2) size 91x127 [r=0 c=0 rs=1 cs=1]
-                      RenderBlock {DIV} at (1,1) size 89x18
-                        RenderText {#text} at (0,0) size 89x18
-                          text run at (0,0) width 89: "Image loaded."
-                      RenderBlock (anonymous) at (1,19) size 89x107
-                        RenderImage {IMG} at (0,0) size 76x103
-      RenderFrame {FRAME} at (0,404) size 800x196
-        layer at (0,0) size 800x196
-          RenderView at (0,0) size 800x196
-        layer at (0,0) size 800x147
-          RenderBlock {HTML} at (0,0) size 800x147
-            RenderBody {BODY} at (8,8) size 784x131
-              RenderTable {TABLE} at (0,0) size 95x131
-                RenderTableSection {TBODY} at (0,0) size 95x131
-                  RenderTableRow {TR} at (0,2) size 95x127
-                    RenderTableCell {TD} at (2,2) size 91x127 [r=0 c=0 rs=1 cs=1]
-                      RenderBlock {DIV} at (1,1) size 89x18
-                        RenderText {#text} at (0,0) size 89x18
-                          text run at (0,0) width 89: "Image loaded."
-                      RenderBlock (anonymous) at (1,19) size 89x107
-                        RenderImage {IMG} at (0,0) size 76x103
+
+
+--------
+Frame: 'topRow'
+--------
+This page was successfully loaded.
+My protocol is file:
+My referrer is blank
+
+
+--------
+Frame: 'middleRow'
+--------
+Image loaded.
+
+
+--------
+Frame: 'bottomRow'
+--------
+Image loaded.
+
index e35cb99..8cdc3f2 100644 (file)
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 
+# Access violation when trying to run local script. <rdar://5631705>
+fast/dom/frame-loading-via-document-write.html
+fast/loader/local-iFrame-source-from-local.html
+fast/loader/local-image-from-local.html
+fast/loader/local-CSS-from-local.html
+fast/loader/local-JavaScript-from-local.html
+http/tests/security/local-JavaScript-from-remote.html
+http/tests/security/local-iFrame-from-remote.html
+http/tests/security/local-CSS-from-remote.html
+http/tests/security/local-user-CSS-from-remote.html
+http/tests/security/frame-loading-via-document-write.html
+http/tests/security/local-image-from-remote.html
+
 # Should be moved to platform/mac <rdar://5621425>
 http/tests/misc/willCacheResponse-delegate-callback.html
 
@@ -293,19 +306,6 @@ fast/js/kde/Number.html
 #<rdar://problem/5224271> Some LayoutTests fail when not run by themselves.
 http/tests/navigation/anchor-frames.html
 
-# Symlinks arn't working correctly. <rdar://problem/5128536>
-fast/dom/frame-loading-via-document-write.html
-fast/loader/local-CSS-from-local.html
-fast/loader/local-JavaScript-from-local.html
-fast/loader/local-iFrame-source-from-local.html
-fast/loader/local-image-from-local.html
-
-# Need a way to specify local resources from http tests that works on Windows <rdar://5621435>
-http/tests/security/frame-loading-via-document-write.html
-http/tests/security/local-CSS-from-remote.html
-http/tests/security/local-JavaScript-from-remote.html
-http/tests/security/local-image-from-remote.html
-
 # No built-in plugin in DRT <rdar://problem/5074411>
 plugins/call-as-function-test.html
 plugins/get-url-that-the-resource-load-delegate-will-disallow.html
diff --git a/LayoutTests/platform/win/http/tests/security/frame-loading-via-document-write-expected.txt b/LayoutTests/platform/win/http/tests/security/frame-loading-via-document-write-expected.txt
new file mode 100644 (file)
index 0000000..af6938b
--- /dev/null
@@ -0,0 +1,22 @@
+CONSOLE MESSAGE: line 0: Not allowed to load local resource: file://C:/cygwin/home/PyongHopscotch/WebKit/OpenSource/LayoutTests/fast/dom/resources/abe.png
+
+
+--------
+Frame: 'topRow'
+--------
+This page was successfully loaded.
+My protocol is http:
+My referrer is blank
+
+
+--------
+Frame: 'middleRow'
+--------
+Image NOT loaded.
+
+
+--------
+Frame: 'bottomRow'
+--------
+Image loaded.
+
index 0e8c891..381bc6a 100644 (file)
@@ -1,3 +1,21 @@
+2007-12-12  Kevin McCullough  <kmccullough@apple.com>
+
+        Reviewed by Alice and Sam.
+
+        - <rdar://5621435> Need a way to specify local resources (being loaded
+        from HTTP tests) on Windows.
+        - Implemented pathToLocalResource which exposes the functionality of
+        converting a given unix path to the correct location on Windows.
+
+        * DumpRenderTree/LayoutTestController.cpp:
+        (pathToLocalResourceCallback):
+        (LayoutTestController::staticFunctions):
+        * DumpRenderTree/LayoutTestController.h:
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+        (LayoutTestController::pathToLocalResource):
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::pathToLocalResource):
+
 2007-12-11  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam.
index 9271cba..3557026 100644 (file)
@@ -136,6 +136,18 @@ static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef fun
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef pathToLocalResourceCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    JSRetainPtr<JSStringRef> localPath = JSValueToStringCopy(context, arguments[0], exception);
+    ASSERT(!*exception);
+
+    return JSValueMakeString(context, controller->pathToLocalResource(context, localPath.get()));
+}
+
 static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
@@ -560,6 +572,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index 9ad07c9..10e13b7 100644 (file)
@@ -46,6 +46,7 @@ public:
     void display();
     void keepWebHistory();
     void notifyDone();
+    JSStringRef pathToLocalResource(JSContextRef, JSStringRef url);
     void queueBackNavigation(int howFarBackward);
     void queueForwardNavigation(int howFarForward);
     void queueLoad(JSStringRef url, JSStringRef target);
index a40458e..33d0b4b 100644 (file)
@@ -115,6 +115,11 @@ void LayoutTestController::notifyDone()
     m_waitToDump = false;
 }
 
+JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
+{
+    return url; // Do nothing on mac.
+}
+
 void LayoutTestController::queueBackNavigation(int howFarBack)
 {
     WorkQueue::shared()->queue(new BackItem(howFarBack));
index 1fc9431..9de2002 100644 (file)
@@ -53,6 +53,8 @@
 using std::string;
 using std::wstring;
 
+static bool resolveCygwinPath(const wstring& cygwinPath, wstring& windowsPath);
+
 LayoutTestController::~LayoutTestController()
 {
     COMPtr<IWebView> webView;
@@ -145,6 +147,15 @@ void LayoutTestController::notifyDone()
     m_waitToDump = false;
 }
 
+JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
+{
+    wstring localPath;
+    if (!resolveCygwinPath(wstring(JSStringGetCharactersPtr(url), JSStringGetLength(url)), localPath))
+        return 0;
+
+    return JSStringCreateWithCharacters(localPath.c_str(), localPath.length());
+}
+
 void LayoutTestController::queueBackNavigation(int howFarBack)
 {
     // Same as on mac.  This can be shared.
@@ -353,7 +364,9 @@ static bool followShortcuts(wstring& path)
 
 static bool resolveCygwinPath(const wstring& cygwinPath, wstring& windowsPath)
 {
-    if (cygwinPath[0] != '/')
+    wstring fileProtocol = L"file://";
+    bool isFileProtocol = cygwinPath.find(fileProtocol) != string::npos;
+    if (cygwinPath[isFileProtocol ? 7 : 0] != '/')  // ensure path is absolute
         return false;
 
     // Get the Root path.
@@ -367,7 +380,7 @@ static bool resolveCygwinPath(const wstring& cygwinPath, wstring& windowsPath)
 
     windowsPath = wstring(rootPath, rootPathSize);
 
-    int oldPos = 1;
+    int oldPos = isFileProtocol ? 8 : 1;
     while (1) {
         int newPos = cygwinPath.find('/', oldPos);
 
@@ -392,6 +405,10 @@ static bool resolveCygwinPath(const wstring& cygwinPath, wstring& windowsPath)
 
         oldPos = newPos + 1;
     }
+
+    if (isFileProtocol)
+        windowsPath = fileProtocol + windowsPath;
+
     return true;
 }