Title: [259725] trunk
Revision
259725
Author
[email protected]
Date
2020-04-08 10:21:09 -0700 (Wed, 08 Apr 2020)

Log Message

Import fetch/origin/assorted.window.js
https://bugs.webkit.org/show_bug.cgi?id=210128

Patch by Rob Buis <[email protected]> on 2020-04-08
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Import fetch/origin/assorted.window.js after
https://github.com/web-platform-tests/wpt/pull/22567.

* web-platform-tests/fetch/origin/assorted.window-expected.txt:
* web-platform-tests/fetch/origin/assorted.window.js:
(async const):
(fetchReferrerPolicy):
(referrerPolicyTestString):

Source/WebCore:

Import fetch/origin/assorted.window.js and remove
the hack to make the previous (incorrect) version work.

* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::updateReferrerAndOriginHeaders):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (259724 => 259725)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-04-08 17:14:09 UTC (rev 259724)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-04-08 17:21:09 UTC (rev 259725)
@@ -1,3 +1,19 @@
+2020-04-08  Rob Buis  <[email protected]>
+
+        Import fetch/origin/assorted.window.js
+        https://bugs.webkit.org/show_bug.cgi?id=210128
+
+        Reviewed by Youenn Fablet.
+
+        Import fetch/origin/assorted.window.js after
+        https://github.com/web-platform-tests/wpt/pull/22567.
+
+        * web-platform-tests/fetch/origin/assorted.window-expected.txt:
+        * web-platform-tests/fetch/origin/assorted.window.js:
+        (async const):
+        (fetchReferrerPolicy):
+        (referrerPolicyTestString):
+
 2020-04-08  Antoine Quint  <[email protected]>
 
         transition-property is not computed correctly when transition-duration is set to "inherit"

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/origin/assorted.window-expected.txt (259724 => 259725)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/origin/assorted.window-expected.txt	2020-04-08 17:14:09 UTC (rev 259724)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/origin/assorted.window-expected.txt	2020-04-08 17:21:09 UTC (rev 259725)
@@ -5,31 +5,41 @@
 PASS Origin header and POST same-origin navigation with Referrer-Policy no-referrer 
 PASS Origin header and POST same-origin fetch no-cors mode with Referrer-Policy no-referrer 
 PASS Origin header and POST same-origin fetch cors mode with Referrer-Policy no-referrer 
+PASS Origin header and GET same-origin fetch cors mode with Referrer-Policy no-referrer 
 PASS Origin header and POST cross-origin navigation with Referrer-Policy no-referrer 
 PASS Origin header and POST cross-origin fetch no-cors mode with Referrer-Policy no-referrer 
 PASS Origin header and POST cross-origin fetch cors mode with Referrer-Policy no-referrer 
+PASS Origin header and GET cross-origin fetch cors mode with Referrer-Policy no-referrer 
 PASS Origin header and POST same-origin navigation with Referrer-Policy same-origin 
 PASS Origin header and POST same-origin fetch no-cors mode with Referrer-Policy same-origin 
 PASS Origin header and POST same-origin fetch cors mode with Referrer-Policy same-origin 
+PASS Origin header and GET same-origin fetch cors mode with Referrer-Policy same-origin 
 PASS Origin header and POST cross-origin navigation with Referrer-Policy same-origin 
 PASS Origin header and POST cross-origin fetch no-cors mode with Referrer-Policy same-origin 
 PASS Origin header and POST cross-origin fetch cors mode with Referrer-Policy same-origin 
+PASS Origin header and GET cross-origin fetch cors mode with Referrer-Policy same-origin 
 PASS Origin header and POST same-origin navigation with Referrer-Policy origin-when-cross-origin 
 PASS Origin header and POST same-origin fetch no-cors mode with Referrer-Policy origin-when-cross-origin 
 PASS Origin header and POST same-origin fetch cors mode with Referrer-Policy origin-when-cross-origin 
+PASS Origin header and GET same-origin fetch cors mode with Referrer-Policy origin-when-cross-origin 
 PASS Origin header and POST cross-origin navigation with Referrer-Policy origin-when-cross-origin 
 PASS Origin header and POST cross-origin fetch no-cors mode with Referrer-Policy origin-when-cross-origin 
 PASS Origin header and POST cross-origin fetch cors mode with Referrer-Policy origin-when-cross-origin 
+PASS Origin header and GET cross-origin fetch cors mode with Referrer-Policy origin-when-cross-origin 
 PASS Origin header and POST same-origin navigation with Referrer-Policy no-referrer-when-downgrade 
 PASS Origin header and POST same-origin fetch no-cors mode with Referrer-Policy no-referrer-when-downgrade 
 PASS Origin header and POST same-origin fetch cors mode with Referrer-Policy no-referrer-when-downgrade 
+PASS Origin header and GET same-origin fetch cors mode with Referrer-Policy no-referrer-when-downgrade 
 PASS Origin header and POST cross-origin navigation with Referrer-Policy no-referrer-when-downgrade 
 PASS Origin header and POST cross-origin fetch no-cors mode with Referrer-Policy no-referrer-when-downgrade 
 PASS Origin header and POST cross-origin fetch cors mode with Referrer-Policy no-referrer-when-downgrade 
+PASS Origin header and GET cross-origin fetch cors mode with Referrer-Policy no-referrer-when-downgrade 
 PASS Origin header and POST same-origin navigation with Referrer-Policy unsafe-url 
 PASS Origin header and POST same-origin fetch no-cors mode with Referrer-Policy unsafe-url 
 PASS Origin header and POST same-origin fetch cors mode with Referrer-Policy unsafe-url 
+PASS Origin header and GET same-origin fetch cors mode with Referrer-Policy unsafe-url 
 PASS Origin header and POST cross-origin navigation with Referrer-Policy unsafe-url 
 PASS Origin header and POST cross-origin fetch no-cors mode with Referrer-Policy unsafe-url 
 PASS Origin header and POST cross-origin fetch cors mode with Referrer-Policy unsafe-url 
+PASS Origin header and GET cross-origin fetch cors mode with Referrer-Policy unsafe-url 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/origin/assorted.window.js (259724 => 259725)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/origin/assorted.window.js	2020-04-08 17:14:09 UTC (rev 259724)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/origin/assorted.window.js	2020-04-08 17:21:09 UTC (rev 259725)
@@ -115,10 +115,9 @@
   };
 }
 
-function fetchReferrerPolicy(referrerPolicy, destination, fetchMode, expectedOrigin) {
+function fetchReferrerPolicy(referrerPolicy, destination, fetchMode, expectedOrigin, httpMethod) {
   return async function () {
     const stash = token();
-    const referrerPolicyPath = "/fetch/origin/resources/referrer-policy.py";
     const redirectPath = "/fetch/origin/resources/redirect-and-stash.py";
 
     let fetchUrl =
@@ -126,7 +125,7 @@
                                        : origins.HTTP_REMOTE_ORIGIN) +
         redirectPath + "?stash=" + stash;
 
-    await fetch(fetchUrl, { mode: fetchMode, method: "POST" , "referrerPolicy": referrerPolicy});
+    await fetch(fetchUrl, { mode: fetchMode, method: httpMethod , "referrerPolicy": referrerPolicy});
 
     const json = await (await fetch(redirectPath + "?dump&stash=" + stash)).json();
 
@@ -134,8 +133,8 @@
   };
 }
 
-function referrerPolicyTestString(referrerPolicy, destination) {
-  return "Origin header and POST " + destination + " with Referrer-Policy " +
+function referrerPolicyTestString(referrerPolicy, method, destination) {
+  return "Origin header and " + method + " " + destination + " with Referrer-Policy " +
          referrerPolicy;
 }
 
@@ -180,23 +179,33 @@
     promise_test(navigationReferrerPolicy(testObj.policy,
                                           destination.name,
                                           destination.expectedOrigin),
-                 referrerPolicyTestString(testObj.policy,
+                 referrerPolicyTestString(testObj.policy, "POST",
                                           destination.name + " navigation"));
     // Test fetch
     promise_test(fetchReferrerPolicy(testObj.policy,
                                      destination.name,
                                      "no-cors",
-                                     destination.expectedOrigin),
-                 referrerPolicyTestString(testObj.policy,
+                                     destination.expectedOrigin,
+                                     "POST"),
+                 referrerPolicyTestString(testObj.policy, "POST",
                                           destination.name + " fetch no-cors mode"));
 
-    // When we're dealing with CORS (mode is "cors"), we shouldn't take the
-    // Referrer-Policy into account
+    // Test cors mode POST
     promise_test(fetchReferrerPolicy(testObj.policy,
                                      destination.name,
                                      "cors",
-                                     origins.HTTP_ORIGIN),
-                 referrerPolicyTestString(testObj.policy,
+                                     (destination.name == "same-origin") ? destination.expectedOrigin : origins.HTTP_ORIGIN,
+                                     "POST"),
+                 referrerPolicyTestString(testObj.policy, "POST",
                                           destination.name + " fetch cors mode"));
+
+    // Test cors mode GET
+    promise_test(fetchReferrerPolicy(testObj.policy,
+                                     destination.name,
+                                     "cors",
+                                     (destination.name == "same-origin") ? "no Origin header" : origins.HTTP_ORIGIN,
+                                     "GET"),
+                 referrerPolicyTestString(testObj.policy, "GET",
+                                          destination.name + " fetch cors mode"));
   });
 });

Modified: trunk/Source/WebCore/ChangeLog (259724 => 259725)


--- trunk/Source/WebCore/ChangeLog	2020-04-08 17:14:09 UTC (rev 259724)
+++ trunk/Source/WebCore/ChangeLog	2020-04-08 17:21:09 UTC (rev 259725)
@@ -1,3 +1,16 @@
+2020-04-08  Rob Buis  <[email protected]>
+
+        Import fetch/origin/assorted.window.js
+        https://bugs.webkit.org/show_bug.cgi?id=210128
+
+        Reviewed by Youenn Fablet.
+
+        Import fetch/origin/assorted.window.js and remove
+        the hack to make the previous (incorrect) version work.
+
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::updateReferrerAndOriginHeaders):
+
 2020-04-08  Doug Kelly  <[email protected]>
 
         Hit test with clipPath referencing parent element causes infinite recursion

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp (259724 => 259725)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2020-04-08 17:14:09 UTC (rev 259724)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2020-04-08 17:21:09 UTC (rev 259725)
@@ -231,9 +231,7 @@
 
     if (doesRequestNeedHTTPOriginHeader(m_resourceRequest)) {
         auto outgoingOrigin = SecurityOrigin::createFromString(outgoingReferrer);
-        // FIXME: Should take referrer-policy into account in some cases, see https://github.com/web-platform-tests/wpt/issues/22298.
-        auto referrerPolicy = (m_options.mode == FetchOptions::Mode::Cors) ? ReferrerPolicy::UnsafeUrl : m_options.referrerPolicy;
-        auto origin = SecurityPolicy::generateOriginHeader(referrerPolicy, m_resourceRequest.url(), outgoingOrigin);
+        auto origin = SecurityPolicy::generateOriginHeader(m_options.referrerPolicy, m_resourceRequest.url(), outgoingOrigin);
         m_resourceRequest.setHTTPOrigin(origin);
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to