Title: [116563] trunk
Revision
116563
Author
[email protected]
Date
2012-05-09 15:13:12 -0700 (Wed, 09 May 2012)

Log Message

When creating a new page during a navigation, prime the initial document with the correct referrer policy
https://bugs.webkit.org/show_bug.cgi?id=86001

Reviewed by Adam Barth.

Source/WebCore:

Test: http/tests/security/referrer-policy-redirect-link.html

* dom/Document.h:
(WebCore::Document::setReferrerPolicy):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):

Tools:

Store the referrer policy in the request, so the network stack can comply with it.

* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::willSendRequest):

LayoutTests:

Skip the test on all but chromium, see https://bugs.webkit.org/show_bug.cgi?id=86000

* http/tests/security/referrer-policy-redirect-link-expected.txt: Added.
* http/tests/security/referrer-policy-redirect-link.html: Added.
* http/tests/security/resources/referrer-policy-postmessage.php: Added.
* http/tests/security/resources/referrer-policy-redirect-link.html: Added.
* platform/efl/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
* platform/wincairo/Skipped:
* platform/wk2/Skipped:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (116562 => 116563)


--- trunk/LayoutTests/ChangeLog	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/LayoutTests/ChangeLog	2012-05-09 22:13:12 UTC (rev 116563)
@@ -1,3 +1,23 @@
+2012-05-09  Jochen Eisinger  <[email protected]>
+
+        When creating a new page during a navigation, prime the initial document with the correct referrer policy
+        https://bugs.webkit.org/show_bug.cgi?id=86001
+
+        Reviewed by Adam Barth.
+
+        Skip the test on all but chromium, see https://bugs.webkit.org/show_bug.cgi?id=86000
+
+        * http/tests/security/referrer-policy-redirect-link-expected.txt: Added.
+        * http/tests/security/referrer-policy-redirect-link.html: Added.
+        * http/tests/security/resources/referrer-policy-postmessage.php: Added.
+        * http/tests/security/resources/referrer-policy-redirect-link.html: Added.
+        * platform/efl/Skipped:
+        * platform/mac/Skipped:
+        * platform/qt/Skipped:
+        * platform/win/Skipped:
+        * platform/wincairo/Skipped:
+        * platform/wk2/Skipped:
+
 2012-05-09  Adrienne Walker  <[email protected]>
 
         Update compositing/RTL tests to fail if the root layer is shifted incorrectly

Added: trunk/LayoutTests/http/tests/security/referrer-policy-redirect-link-expected.txt (0 => 116563)


--- trunk/LayoutTests/http/tests/security/referrer-policy-redirect-link-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/referrer-policy-redirect-link-expected.txt	2012-05-09 22:13:12 UTC (rev 116563)
@@ -0,0 +1,11 @@
+This test checks the referrer policy is obeyed along the redirect chain. The test passes if the referrer is https://127.0.0.1:8443
+
+
+
+--------
+Frame: 'iframe'
+--------
+If not running in DumpRenderTree, click this link
+HTTP Referer header is https://127.0.0.1:8443/
+Referrer is https://127.0.0.1:8443/
+

Added: trunk/LayoutTests/http/tests/security/referrer-policy-redirect-link.html (0 => 116563)


--- trunk/LayoutTests/http/tests/security/referrer-policy-redirect-link.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/referrer-policy-redirect-link.html	2012-05-09 22:13:12 UTC (rev 116563)
@@ -0,0 +1,25 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.dumpChildFramesAsText();
+    layoutTestController.waitUntilDone();
+    layoutTestController.setCanOpenWindows();
+    layoutTestController.setCloseRemainingWindowsWhenComplete(true);
+}
+
+function runTest() {
+    var iframe = document.getElementById("iframe");
+    iframe.contentWindow.postMessage({"action": "click", "offsetLeft": iframe.offsetLeft, "offsetTop": iframe.offsetTop}, "*");
+}
+</script>
+</head>
+<body>
+<p>
+This test checks the referrer policy is obeyed along the redirect chain.  The
+test passes if the referrer is https://127.0.0.1:8443
+</p>
+<iframe id="iframe" _onload_="runTest()" src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/security/resources/referrer-policy-postmessage.php (0 => 116563)


--- trunk/LayoutTests/http/tests/security/resources/referrer-policy-postmessage.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/referrer-policy-postmessage.php	2012-05-09 22:13:12 UTC (rev 116563)
@@ -0,0 +1,26 @@
+<html>
+<head>
+<script>
+function log(msg) {
+    window.opener.postMessage(msg, "*");
+}
+
+function runTest() {
+    var referrerHeader = "<?php echo $_SERVER['HTTP_REFERER'] ?>";
+    if (referrerHeader == "")
+        log("HTTP Referer header is empty");
+    else
+        log("HTTP Referer header is " + referrerHeader);
+
+    if (document.referrer == "")
+        log("Referrer is empty");
+    else
+        log("Referrer is " + document.referrer);
+
+    log("done");
+}
+</script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/security/resources/referrer-policy-redirect-link.html (0 => 116563)


--- trunk/LayoutTests/http/tests/security/resources/referrer-policy-redirect-link.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/referrer-policy-redirect-link.html	2012-05-09 22:13:12 UTC (rev 116563)
@@ -0,0 +1,27 @@
+<html>
+<head>
+<meta name="referrer" content="origin" />
+<script>
+window.addEventListener("message", receiveMessage, false);
+
+function receiveMessage(evt) {
+    if (evt.data == "done") {
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    } else if (typeof(evt.data) == "object" && evt.data.action == "click")  {
+        var link = document.getElementById("link");
+        eventSender.mouseMoveTo(link.offsetLeft + evt.data.offsetLeft + 2,
+                                link.offsetTop + evt.data.offsetTop + 2);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    } else {
+        document.getElementById("log").innerHTML += evt.data + "<br>";
+    }
+}
+</script>
+</head>
+<body>
+<a id="link" target="_blank" href="" not running in DumpRenderTree, click this link</a>
+<div id="log"></div>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/efl/Skipped (116562 => 116563)


--- trunk/LayoutTests/platform/efl/Skipped	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/LayoutTests/platform/efl/Skipped	2012-05-09 22:13:12 UTC (rev 116563)
@@ -1855,6 +1855,7 @@
 http/tests/security/referrer-policy-https-never.html
 http/tests/security/referrer-policy-https-origin.html
 http/tests/security/referrer-policy-redirect.html
+http/tests/security/referrer-policy-redirect-link.html
 http/tests/security/xss-DENIED-xsl-document-redirect.xml
 http/tests/security/xss-DENIED-xsl-external-entity-redirect.xml
 http/tests/ssl/referer-301.html

Modified: trunk/LayoutTests/platform/mac/Skipped (116562 => 116563)


--- trunk/LayoutTests/platform/mac/Skipped	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/LayoutTests/platform/mac/Skipped	2012-05-09 22:13:12 UTC (rev 116563)
@@ -836,3 +836,6 @@
 
 # https://bugs.webkit.org/show_bug.cgi?id=85969
 http/tests/loading/post-in-iframe-with-back-navigation.html
+
+# https://bugs.webkit.org/show_bug.cgi?id=86000
+http/tests/security/referrer-policy-redirect-link.html

Modified: trunk/LayoutTests/platform/qt/Skipped (116562 => 116563)


--- trunk/LayoutTests/platform/qt/Skipped	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/LayoutTests/platform/qt/Skipped	2012-05-09 22:13:12 UTC (rev 116563)
@@ -1960,6 +1960,9 @@
 security/block-test-no-port.html
 security/block-test.html
 
+# https://bugs.webkit.org/show_bug.cgi?id=86000
+http/tests/security/referrer-policy-redirect-link.html
+
 # ============================================================================= #
 # failing tables tests
 # ============================================================================= #

Modified: trunk/LayoutTests/platform/win/Skipped (116562 => 116563)


--- trunk/LayoutTests/platform/win/Skipped	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/LayoutTests/platform/win/Skipped	2012-05-09 22:13:12 UTC (rev 116563)
@@ -1737,3 +1737,6 @@
 # Interferes with the other requestAnimationFrame tests
 # https://bugs.webkit.org/show_bug.cgi?id=85689
 fast/animation/request-animation-frame-disabled.html
+
+# https://bugs.webkit.org/show_bug.cgi?id=86000
+http/tests/security/referrer-policy-redirect-link.html

Modified: trunk/LayoutTests/platform/wincairo/Skipped (116562 => 116563)


--- trunk/LayoutTests/platform/wincairo/Skipped	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/LayoutTests/platform/wincairo/Skipped	2012-05-09 22:13:12 UTC (rev 116563)
@@ -2094,3 +2094,6 @@
 
 # Generate results for your platform http://webkit.org/b/85567
 fast/images/png-suite/test.html
+
+# https://bugs.webkit.org/show_bug.cgi?id=86000
+http/tests/security/referrer-policy-redirect-link.html

Modified: trunk/LayoutTests/platform/wk2/Skipped (116562 => 116563)


--- trunk/LayoutTests/platform/wk2/Skipped	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/LayoutTests/platform/wk2/Skipped	2012-05-09 22:13:12 UTC (rev 116563)
@@ -854,6 +854,11 @@
 # autoZoomPageToFitWidth().
 inspector/styles/override-screen-size.html
 
+# The network stack unconditionally strips the header on transitions from
+# secure to insecure. It should take the referrer policy into account instead.
+# https://bugs.webkit.org/show_bug.cgi?id=86000
+http/tests/security/referrer-policy-redirect-link.html
+
 ### END OF (1) Classified failures with bug reports
 ########################################
 

Modified: trunk/Source/WebCore/ChangeLog (116562 => 116563)


--- trunk/Source/WebCore/ChangeLog	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/Source/WebCore/ChangeLog	2012-05-09 22:13:12 UTC (rev 116563)
@@ -1,3 +1,17 @@
+2012-05-09  Jochen Eisinger  <[email protected]>
+
+        When creating a new page during a navigation, prime the initial document with the correct referrer policy
+        https://bugs.webkit.org/show_bug.cgi?id=86001
+
+        Reviewed by Adam Barth.
+
+        Test: http/tests/security/referrer-policy-redirect-link.html
+
+        * dom/Document.h:
+        (WebCore::Document::setReferrerPolicy):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
+
 2012-05-09  Alec Flett  <[email protected]>
 
         IndexedDB: call abort handler when there are problems committing

Modified: trunk/Source/WebCore/dom/Document.h (116562 => 116563)


--- trunk/Source/WebCore/dom/Document.h	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/Source/WebCore/dom/Document.h	2012-05-09 22:13:12 UTC (rev 116563)
@@ -330,6 +330,7 @@
     bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
 #endif
 
+    void setReferrerPolicy(ReferrerPolicy referrerPolicy) { m_referrerPolicy = referrerPolicy; }
     ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; }
 
     DocumentType* doctype() const { return m_docType.get(); }

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (116562 => 116563)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2012-05-09 22:13:12 UTC (rev 116563)
@@ -2775,8 +2775,10 @@
 
     mainFrame->page()->setOpenedByDOM();
     mainFrame->loader()->m_client->dispatchShow();
-    if (!m_suppressOpenerInNewFrame)
+    if (!m_suppressOpenerInNewFrame) {
         mainFrame->loader()->setOpener(frame.get());
+        mainFrame->document()->setReferrerPolicy(frame->document()->referrerPolicy());
+    }
     mainFrame->loader()->loadWithNavigationAction(request, NavigationAction(request), false, FrameLoadTypeStandard, formState);
 }
 

Modified: trunk/Tools/ChangeLog (116562 => 116563)


--- trunk/Tools/ChangeLog	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/Tools/ChangeLog	2012-05-09 22:13:12 UTC (rev 116563)
@@ -1,3 +1,15 @@
+2012-05-09  Jochen Eisinger  <[email protected]>
+
+        When creating a new page during a navigation, prime the initial document with the correct referrer policy
+        https://bugs.webkit.org/show_bug.cgi?id=86001
+
+        Reviewed by Adam Barth.
+
+        Store the referrer policy in the request, so the network stack can comply with it.
+
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::willSendRequest):
+
 2012-05-09  Vivek Galatage  <[email protected]>
 
         Remove CYGWIN=tty from environment variable as its no longer supported

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (116562 => 116563)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-05-09 22:09:10 UTC (rev 116562)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-05-09 22:13:12 UTC (rev 116563)
@@ -42,6 +42,7 @@
 #include "WebDOMMessageEvent.h"
 #include "WebDataSource.h"
 #include "WebDeviceOrientationClientMock.h"
+#include "WebDocument.h"
 #include "platform/WebDragData.h"
 #include "WebElement.h"
 #include "WebFrame.h"
@@ -1199,7 +1200,7 @@
     m_resourceIdentifierMap.remove(identifier);
 }
 
-void WebViewHost::willSendRequest(WebFrame*, unsigned identifier, WebURLRequest& request, const WebURLResponse& redirectResponse)
+void WebViewHost::willSendRequest(WebFrame* frame, unsigned identifier, WebURLRequest& request, const WebURLResponse& redirectResponse)
 {
     // Need to use GURL for host() and SchemeIs()
     GURL url = ""
@@ -1217,6 +1218,8 @@
         fputs("\n", stdout);
     }
 
+    request.setExtraData(webkit_support::CreateWebURLRequestExtraData(frame->document().referrerPolicy()));
+
     if (!redirectResponse.isNull() && m_blocksRedirects) {
         fputs("Returning null for this redirect\n", stdout);
         // To block the request, we set its URL to an empty one.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to