LayoutTests:
authorbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Feb 2007 10:38:05 +0000 (10:38 +0000)
committerbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Feb 2007 10:38:05 +0000 (10:38 +0000)
        Reviewed by Maciej

        <rdar://problem/4965133> WebKit sends file:// url referrers

        Added a new category of http tests - "local" where the test is run as a local file but
        the test involves remote resources from the httpd.
        This test had to be done with cached subresources to tickle the code path that was failing before,
        hence the bizarre different-sized images instead of simple success/failure text

        * http/tests/local/file-url-sent-as-referer-expected.txt: Added.
        * http/tests/local/file-url-sent-as-referer.html: Added - document.writes an img source
          that ends up testing the http-referer

        * http/tests/security/resources/green250x50.png: Added.
        * http/tests/security/resources/red200x100.png: Added.

        * http/tests/security/resources/showRefererImage.php: Added - By scanning the referrer,
          sends back either the success or failure image

WebCore:

        Reviewed by Maciej

        <rdar://problem/4965133> WebKit sends file:// url referrers

        * loader/SubresourceLoader.cpp:
        (WebCore::SubresourceLoader::create): In SubresourceLoader::create(), we make a copy of the original request
        to use for the load.  We then call FrameLoader::canLoad() which tells us if we should hide the referer.  Before
        this fix if it said to hide the referrer, we would simply not apply a new referrer to our copy of the request.
        But if the original request already had a referrer, so did our copy.  We simply have to clear the referrer from
        the copied request.

WebKitTools:

        Reviewed by Maciej

        <rdar://problem/4965133> WebKit sends file:// url referrers

        * Scripts/run-webkit-tests: Enhanced the http tests so that we can run layout tests
          on local files, but have an httpd for remote resources

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

LayoutTests/ChangeLog
LayoutTests/http/tests/local/file-url-sent-as-referer-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/local/file-url-sent-as-referer.html [new file with mode: 0644]
LayoutTests/http/tests/security/resources/green250x50.png [new file with mode: 0644]
LayoutTests/http/tests/security/resources/red200x100.png [new file with mode: 0644]
LayoutTests/http/tests/security/resources/showRefererImage.php [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/SubresourceLoader.cpp
WebCore/platform/network/ResourceRequest.h
WebKitTools/ChangeLog
WebKitTools/Scripts/run-webkit-tests

index e0dc7fc..5f40cc9 100644 (file)
@@ -1,3 +1,24 @@
+2007-02-10  Brady Eidson <beidson@apple.com>
+
+        Reviewed by Maciej
+
+        <rdar://problem/4965133> WebKit sends file:// url referrers
+
+        Added a new category of http tests - "local" where the test is run as a local file but
+        the test involves remote resources from the httpd.
+        This test had to be done with cached subresources to tickle the code path that was failing before,
+        hence the bizarre different-sized images instead of simple success/failure text  
+
+        * http/tests/local/file-url-sent-as-referer-expected.txt: Added.
+        * http/tests/local/file-url-sent-as-referer.html: Added - document.writes an img source
+          that ends up testing the http-referer
+
+        * http/tests/security/resources/green250x50.png: Added.
+        * http/tests/security/resources/red200x100.png: Added.
+
+        * http/tests/security/resources/showRefererImage.php: Added - By scanning the referrer,
+          sends back either the success or failure image
+
 2007-02-10  Maciej Stachowiak  <mjs@apple.com>
 
         - add missing result and update tests to work right from DumpRenderTree
diff --git a/LayoutTests/http/tests/local/file-url-sent-as-referer-expected.txt b/LayoutTests/http/tests/local/file-url-sent-as-referer-expected.txt
new file mode 100644 (file)
index 0000000..ba26020
--- /dev/null
@@ -0,0 +1,22 @@
+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
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBR {BR} at (0,0) size 0x18
+      RenderText {#text} at (0,18) size 499x18
+        text run at (0,18) width 499: "This is a test to see if a file:// url is sent out as the referrer for a subresource load"
+      RenderBR {BR} at (499,32) size 0x0
+      RenderPartObject {IFRAME} at (0,36) size 300x150
+        layer at (0,0) size 300x150
+          RenderView at (0,0) size 300x150
+        layer at (0,0) size 300x70
+          RenderBlock {HTML} at (0,0) size 300x70
+            RenderBody {BODY} at (8,8) size 284x54
+              RenderImage {IMG} at (0,0) size 250x50
+      RenderText {#text} at (300,172) size 4x18
+        text run at (300,172) width 4: " "
+      RenderBR {BR} at (304,186) size 0x0
+      RenderText {#text} at (0,190) size 389x18
+        text run at (0,190) width 389: "The above image will tell you success or failure - green or red"
+      RenderBR {BR} at (389,204) size 0x0
diff --git a/LayoutTests/http/tests/local/file-url-sent-as-referer.html b/LayoutTests/http/tests/local/file-url-sent-as-referer.html
new file mode 100644 (file)
index 0000000..248b0ca
--- /dev/null
@@ -0,0 +1,19 @@
+<html>
+<head>
+    <script>  
+        if (window.layoutTestController)
+            layoutTestController.dump();
+        
+        function getImage()
+        {
+            var frameObj = document.getElementById("myFrame");
+            frameObj.contentWindow.document.write("<img src=\"http://127.0.0.1:8000/security/resources/showRefererImage.php\"/>");
+        }
+    </script>
+</head>
+<body>
+<br>This is a test to see if a file:// url is sent out as the referrer for a subresource load<br>
+<iframe id="myFrame" src="about:blank" onLoad="getImage();"></iframe>
+<br>The above image will tell you success or failure - green or red<br>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/security/resources/green250x50.png b/LayoutTests/http/tests/security/resources/green250x50.png
new file mode 100644 (file)
index 0000000..07974a6
Binary files /dev/null and b/LayoutTests/http/tests/security/resources/green250x50.png differ
diff --git a/LayoutTests/http/tests/security/resources/red200x100.png b/LayoutTests/http/tests/security/resources/red200x100.png
new file mode 100644 (file)
index 0000000..e395924
Binary files /dev/null and b/LayoutTests/http/tests/security/resources/red200x100.png differ
diff --git a/LayoutTests/http/tests/security/resources/showRefererImage.php b/LayoutTests/http/tests/security/resources/showRefererImage.php
new file mode 100644 (file)
index 0000000..9d3258d
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+$refer = $_SERVER['HTTP_REFERER']; 
+if ($refer && stristr($refer, "file:") == 0)
+    header('Location: http://127.0.0.1:8000/security/resources/red200x100.png');
+else 
+    header('Location: http://127.0.0.1:8000/security/resources/green250x50.png');
+?>
\ No newline at end of file
index 5e96fb9..eaf1fb5 100644 (file)
@@ -1,3 +1,16 @@
+2007-02-09  Brady Eidson <beidson@apple.com>
+
+        Reviewed by Maciej
+
+        <rdar://problem/4965133> WebKit sends file:// url referrers
+
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::create): In SubresourceLoader::create(), we make a copy of the original request
+        to use for the load.  We then call FrameLoader::canLoad() which tells us if we should hide the referer.  Before 
+        this fix if it said to hide the referrer, we would simply not apply a new referrer to our copy of the request.
+        But if the original request already had a referrer, so did our copy.  We simply have to clear the referrer from
+        the copied request.
+
 2007-02-10  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by me, patch from Ian Eng (cleaned up by me some).
index 7bea4df..d1b4431 100644 (file)
@@ -97,7 +97,9 @@ PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, Subresourc
     // FIXME: is that really the rule we want for subresources?
     bool hideReferrer;
     fl->canLoad(request.url(), fl->outgoingReferrer(), hideReferrer);
-    if (!hideReferrer && !request.httpReferrer())
+    if (hideReferrer)
+        newRequest.clearHTTPReferrer();
+    else if (!request.httpReferrer())
         newRequest.setHTTPReferrer(fl->outgoingReferrer());
 
     // Use the original request's cache policy for two reasons:
index 75301d7..cf7d40e 100644 (file)
@@ -129,6 +129,7 @@ namespace WebCore {
         
         String httpReferrer() const { return httpHeaderField("Referer"); }
         void setHTTPReferrer(const String& httpReferrer) { setHTTPHeaderField("Referer", httpReferrer); }
+        void clearHTTPReferrer() { m_httpHeaderFields.remove("Referer"); }
         
         String httpUserAgent() const { return httpHeaderField("User-Agent"); }
         void setHTTPUserAgent(const String& httpUserAgent) { setHTTPHeaderField("User-Agent", httpUserAgent); }
index d202978..28653ec 100644 (file)
@@ -1,3 +1,12 @@
+2007-02-10  Brady Eidson <beidson@apple.com>
+
+        Reviewed by Maciej
+
+        <rdar://problem/4965133> WebKit sends file:// url referrers
+
+        * Scripts/run-webkit-tests: Enhanced the http tests so that we can run layout tests
+          on local files, but have an httpd for remote resources
+
 2007-02-08  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Beth Dakin.
index d769721..8902579 100755 (executable)
@@ -374,10 +374,21 @@ for my $test (@tests) {
         print OUT "$testPath\n";
     } else {
         openHTTPDIfNeeded();
-        
-        my $path = canonpath($test);
-        $path =~ s/^http\/tests\///;
-        print OUT "http://127.0.0.1:$httpdPort/$path\n";
+        if ($test !~ /^http\/tests\/local\//) {
+            my $path = canonpath($test);
+            $path =~ s/^http\/tests\///;
+            print OUT "http://127.0.0.1:$httpdPort/$path\n";
+        }
+        else {
+            my $testPath = "$testDirectory/$test";
+            if (isCygwin()) {
+                $testPath = `cygpath -m -s "$testPath"`;
+            }
+            else {
+                $testPath = canonpath($testPath);
+            }
+            print OUT "$testPath\n";
+        }
     }
 
     my $actual = "";