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
+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
--- /dev/null
+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
--- /dev/null
+<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>
--- /dev/null
+<?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
+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).
// 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:
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); }
+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.
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 = "";