Bug 35920 - Test for referer information being stripped when the header is removed in willSendRequest
Summary: Test for referer information being stripped when the header is removed in wil...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-09 07:13 PST by jochen
Modified: 2010-03-12 06:06 PST (History)
5 users (show)

See Also:


Attachments
Patch (11.72 KB, patch)
2010-03-09 07:15 PST, jochen
no flags Details | Formatted Diff | Diff
https://bugs.webkit.org/show_bug.cgi?id=35920 (11.72 KB, patch)
2010-03-09 07:22 PST, jochen
no flags Details | Formatted Diff | Diff
patch (11.73 KB, patch)
2010-03-09 07:36 PST, jochen
no flags Details | Formatted Diff | Diff
patch (11.93 KB, patch)
2010-03-09 07:53 PST, jochen
no flags Details | Formatted Diff | Diff
patch (12.12 KB, patch)
2010-03-09 09:09 PST, jochen
no flags Details | Formatted Diff | Diff
patch (14.38 KB, patch)
2010-03-11 07:30 PST, jochen
no flags Details | Formatted Diff | Diff
patch (14.42 KB, patch)
2010-03-11 07:33 PST, jochen
no flags Details | Formatted Diff | Diff
patch (14.43 KB, patch)
2010-03-11 07:34 PST, jochen
no flags Details | Formatted Diff | Diff
patch (14.37 KB, patch)
2010-03-11 08:27 PST, jochen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jochen 2010-03-09 07:13:30 PST
Test for referer information being stripped when the header is removed in willSendRequest
Comment 1 jochen 2010-03-09 07:15:28 PST
Created attachment 50302 [details]
Patch
Comment 2 WebKit Review Bot 2010-03-09 07:16:51 PST
Attachment 50302 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebKitTools/DumpRenderTree/LayoutTestController.h:35:  Alphabetical sorting problem.  [build/include_order] [4]
WebKitTools/ChangeLog:5:  Line contains tab character.  [whitespace/tab] [5]
Total errors found: 2 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 jochen 2010-03-09 07:23:44 PST
Comment on attachment 50303 [details]
https://bugs.webkit.org/show_bug.cgi?id=35920

Please look esp. at the DumpRenderTree/win part - I failed to setup a build environment for windows, so I couldn't test :(
Comment 5 WebKit Review Bot 2010-03-09 07:27:36 PST
Attachment 50303 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebKitTools/DumpRenderTree/LayoutTestController.h:35:  Alphabetical sorting problem.  [build/include_order] [4]
WebKitTools/ChangeLog:5:  Line contains tab character.  [whitespace/tab] [5]
Total errors found: 2 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 jochen 2010-03-09 07:36:41 PST
Created attachment 50305 [details]
patch
Comment 7 Adam Barth 2010-03-09 07:38:25 PST
Comment on attachment 50305 [details]
patch

I don't read objective-C, but this looks good to me.  I'm going to leave this here for a bit so someone who actually understands objective-C can look at it.
Comment 8 Jeremy Orlow 2010-03-09 07:38:32 PST
Comment on attachment 50303 [details]
https://bugs.webkit.org/show_bug.cgi?id=35920

> diff --git a/LayoutTests/http/tests/security/no-referer.html b/LayoutTests/http/tests/security/no-referer.html
> new file mode 100644
> index 0000000..31e1625
> --- /dev/null
> +++ b/LayoutTests/http/tests/security/no-referer.html
> @@ -0,0 +1,9 @@
> +<script>
> +if (window.layoutTestController) {
> +    layoutTestController.waitUntilDone();
> +    layoutTestController.dumpAsText();
> +    layoutTestController.setWillSendRequestClearHeader("Referer");
> +}
> +</script>
> +<div id=log></div>
> +<iframe src="http://127.0.0.1:8000/security/resources/no-referer-frame.php"></iframe>
> diff --git a/LayoutTests/http/tests/security/resources/no-referer-frame.php b/LayoutTests/http/tests/security/resources/no-referer-frame.php

Does this have to be done with an iframe?  Is it the normal way to do it?

> new file mode 100644
> index 0000000..f00b9bb
> --- /dev/null
> +++ b/LayoutTests/http/tests/security/resources/no-referer-frame.php
> @@ -0,0 +1,39 @@
> +<script>
> +function log(message)
> +{
> +    parent.document.getElementById("log").innerHTML += message + "<br>";
> +}
> +
> +if (document.referrer.toString() != "") {
> +  log("JavaScript: FAIL");
> +} else {
> +  log("JavaScript: PASS");
> +}

No {}'s



I don't know enough about DRT to r+ this, but it looks pretty solid to me.
Comment 9 Jeremy Orlow 2010-03-09 07:39:26 PST
(In reply to comment #8)
> (From update of attachment 50303 [details])
> > diff --git a/LayoutTests/http/tests/security/no-referer.html b/LayoutTests/http/tests/security/no-referer.html
> > new file mode 100644
> > index 0000000..31e1625
> > --- /dev/null
> > +++ b/LayoutTests/http/tests/security/no-referer.html
> > @@ -0,0 +1,9 @@
> > +<script>
> > +if (window.layoutTestController) {
> > +    layoutTestController.waitUntilDone();
> > +    layoutTestController.dumpAsText();
> > +    layoutTestController.setWillSendRequestClearHeader("Referer");
> > +}
> > +</script>
> > +<div id=log></div>
> > +<iframe src="http://127.0.0.1:8000/security/resources/no-referer-frame.php"></iframe>
> > diff --git a/LayoutTests/http/tests/security/resources/no-referer-frame.php b/LayoutTests/http/tests/security/resources/no-referer-frame.php
> 
> Does this have to be done with an iframe?  Is it the normal way to do it?
> 
> > new file mode 100644
> > index 0000000..f00b9bb
> > --- /dev/null
> > +++ b/LayoutTests/http/tests/security/resources/no-referer-frame.php
> > @@ -0,0 +1,39 @@
> > +<script>
> > +function log(message)
> > +{
> > +    parent.document.getElementById("log").innerHTML += message + "<br>";
> > +}
> > +
> > +if (document.referrer.toString() != "") {
> > +  log("JavaScript: FAIL");
> > +} else {
> > +  log("JavaScript: PASS");
> > +}
> 
> No {}'s
> 
> 
> 
> I don't know enough about DRT to r+ this, but it looks pretty solid to me.

(Or obj C)  So we still need an obj C reviewer to take a look.
Comment 10 Adam Barth 2010-03-09 07:42:31 PST
> Does this have to be done with an iframe?  Is it the normal way to do it?

Our loading code is sufficiently complicated that it makes sense to test as many of our load paths as we can.

In this case, he wants to check the document.referrer property, which needs a document (and hence a frame).
Comment 11 jochen 2010-03-09 07:44:01 PST
(In reply to comment #8)
> (From update of attachment 50303 [details])
> > diff --git a/LayoutTests/http/tests/security/no-referer.html b/LayoutTests/http/tests/security/no-referer.html
> > new file mode 100644
> > index 0000000..31e1625
> > --- /dev/null
> > +++ b/LayoutTests/http/tests/security/no-referer.html
> > @@ -0,0 +1,9 @@
> > +<script>
> > +if (window.layoutTestController) {
> > +    layoutTestController.waitUntilDone();
> > +    layoutTestController.dumpAsText();
> > +    layoutTestController.setWillSendRequestClearHeader("Referer");
> > +}
> > +</script>
> > +<div id=log></div>
> > +<iframe src="http://127.0.0.1:8000/security/resources/no-referer-frame.php"></iframe>
> > diff --git a/LayoutTests/http/tests/security/resources/no-referer-frame.php b/LayoutTests/http/tests/security/resources/no-referer-frame.php
> 
> Does this have to be done with an iframe?  Is it the normal way to do it?

It's mostly copied from http/tests/security/credentials-in-referer.html

> 
> > new file mode 100644
> > index 0000000..f00b9bb
> > --- /dev/null
> > +++ b/LayoutTests/http/tests/security/resources/no-referer-frame.php
> > @@ -0,0 +1,39 @@
> > +<script>
> > +function log(message)
> > +{
> > +    parent.document.getElementById("log").innerHTML += message + "<br>";
> > +}
> > +
> > +if (document.referrer.toString() != "") {
> > +  log("JavaScript: FAIL");
> > +} else {
> > +  log("JavaScript: PASS");
> > +}
> 
> No {}'s
> 
> 
> 
> I don't know enough about DRT to r+ this, but it looks pretty solid to me.
Comment 12 jochen 2010-03-09 07:53:13 PST
Created attachment 50308 [details]
patch
Comment 13 Darin Adler 2010-03-09 08:51:03 PST
Comment on attachment 50308 [details]
patch

Normally we use the misspelling "referer" only in the actual header name on the wire and use the normal English word "referrer" everywhere else.

>  #include <JavaScriptCore/JSObjectRef.h>
>  #include <JavaScriptCore/JSRetainPtr.h>
> -#include <wtf/RefCounted.h>
> +
> +#include <set>
>  #include <string>
>  #include <vector>
>  
> +#include <wtf/RefCounted.h>

Normally our includes are in a single paragraph sorted as if by the sort tool, not separate logical paragraphs.

> +    const std::set<std::string>& clearHeaders = gLayoutTestController->willSendRequestClearHeaders();

Normally we do "using namespace std" in our implementation files rather than using the "std::" prefix that is required in headers. Unless there's a name conflict of some sort.

No downside in adding a test, unless it has intermittent failures, so we should land this. r=me
Comment 14 jochen 2010-03-09 09:09:08 PST
Created attachment 50313 [details]
patch
Comment 15 WebKit Review Bot 2010-03-09 09:12:59 PST
Attachment 50313 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp:41:  Use 'using namespace std;' instead of 'using std::set;'.  [build/using_std] [4]
WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp:42:  Use 'using namespace std;' instead of 'using std::string;'.  [build/using_std] [4]
Total errors found: 2 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 16 jochen 2010-03-09 09:13:47 PST
I also added a missing ; in ResourceLoaderDelegate.mm:

[nsHeader release]; <-
Comment 17 jochen 2010-03-09 09:14:34 PST
(In reply to comment #15)
> Attachment 50313 [details] did not pass style-queue:
> 
> Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
> WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp:41:  Use 'using
> namespace std;' instead of 'using std::set;'.  [build/using_std] [4]
> WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp:42:  Use 'using
> namespace std;' instead of 'using std::string;'.  [build/using_std] [4]
> Total errors found: 2 in 10 files
> 
> 
> If any of these errors are false positives, please file a bug against
> check-webkit-style.

the original file already has use std::wstring; 

I assume there's a reason it doesn't use "using namespace std;"?
Comment 18 Adam Barth 2010-03-09 09:15:29 PST
Comment on attachment 50313 [details]
patch

Please address style nits.  :)
Comment 19 Adam Barth 2010-03-09 09:16:16 PST
> the original file already has use std::wstring; 
> 
> I assume there's a reason it doesn't use "using namespace std;"?

I suspect the original file is wrong.  We haven't had the style bot for that long.
Comment 20 Alexey Proskuryakov 2010-03-09 14:54:08 PST
Shouldn't the test be added to Skipped list for platforms that don't implement the new call?
Comment 21 jochen 2010-03-11 07:30:29 PST
Created attachment 50500 [details]
patch
Comment 22 jochen 2010-03-11 07:33:19 PST
Created attachment 50501 [details]
patch
Comment 23 jochen 2010-03-11 07:34:26 PST
Created attachment 50503 [details]
patch
Comment 24 jochen 2010-03-11 07:36:44 PST
Hopefully I got the changelog right now..

updates:
- fixed the nits
- actually managed to compile the code on windows and verified it's working there.
Comment 25 Jeremy Orlow 2010-03-11 08:10:48 PST
Comment on attachment 50503 [details]
patch

> diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
> index 70369a7..bd4c368 100644
> --- a/LayoutTests/ChangeLog
> +++ b/LayoutTests/ChangeLog
> @@ -1,3 +1,17 @@
> +2010-03-09  Jochen Eisinger  <jochen@chromium.org>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        Test for referrer information being stripped when the header is removed in willSendRequest
> +        https://bugs.webkit.org/show_bug.cgi?id=35920
> +
> +        * http/tests/security/no-referrer-expected.txt: Added.
> +        * http/tests/security/no-referrer.html: Added.
> +        * http/tests/security/resources/no-referrer-frame.php: Added.
> +        * http/tests/security/resources/no-referrer.php: Added.
> +	* platform/gtk/Skipped:
> +	* platform/qt/Skipped:

Use spaces, not tabs.

r=me (+ Darin on ObjC bits)
Comment 26 jochen 2010-03-11 08:27:08 PST
Created attachment 50507 [details]
patch
Comment 27 WebKit Commit Bot 2010-03-12 06:06:37 PST
Comment on attachment 50507 [details]
patch

Clearing flags on attachment: 50507

Committed r55893: <http://trac.webkit.org/changeset/55893>
Comment 28 WebKit Commit Bot 2010-03-12 06:06:44 PST
All reviewed patches have been landed.  Closing bug.