Title: [226397] trunk
Revision
226397
Author
[email protected]
Date
2018-01-04 00:24:54 -0800 (Thu, 04 Jan 2018)

Log Message

Implement  https://fetch.spec.whatwg.org/#main-fetch default referrer policy setting
https://bugs.webkit.org/show_bug.cgi?id=181239

Patch by Youenn Fablet <[email protected]> on 2018-01-04
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Updated test to output more tests for better error reporting.
Also updated to relax the settings so that HTTP loads are done even though the page is HTTPS.
Updated referrer computation since it should be done based on the fetch context and not its parent context.

* web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https-expected.txt:
* web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https.html:

Source/WebCore:

Covered by updated and rebased test.

Setting the request referrer policy to the Document referrer policy if no one is set.
If Document has no referrer policy, use no-referrer-when-downgrade as per the spec.

* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::updateHTTPRequestHeaders):
(WebCore::CachedResourceLoader::requestResource):
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::updateReferrerPolicy):
(WebCore::CachedResourceRequest::updateReferrerOriginAndUserAgentHeaders):
* loader/cache/CachedResourceRequest.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (226396 => 226397)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-01-04 07:44:55 UTC (rev 226396)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-01-04 08:24:54 UTC (rev 226397)
@@ -1,3 +1,17 @@
+2018-01-04  Youenn Fablet  <[email protected]>
+
+        Implement  https://fetch.spec.whatwg.org/#main-fetch default referrer policy setting
+        https://bugs.webkit.org/show_bug.cgi?id=181239
+
+        Reviewed by Alex Christensen.
+
+        Updated test to output more tests for better error reporting.
+        Also updated to relax the settings so that HTTP loads are done even though the page is HTTPS.
+        Updated referrer computation since it should be done based on the fetch context and not its parent context.
+
+        * web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https.html:
+
 2018-01-02  Youenn Fablet  <[email protected]>
 
         Memory cache should not reuse resources with different credential fetch option

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https-expected.txt (226396 => 226397)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https-expected.txt	2018-01-04 07:44:55 UTC (rev 226396)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https-expected.txt	2018-01-04 08:24:54 UTC (rev 226397)
@@ -1,4 +1,76 @@
+CONSOLE MESSAGE: line 32: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
 
+CONSOLE MESSAGE: line 54: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
 
-FAIL Service Worker responds to fetch event with the referrer policy assert_unreached: unexpected rejection: assert_equals: Service Worker should respond to fetch with the default referrer policy expected "ReferrerPolicy: no-referrer-when-downgrade" but got "ReferrerPolicy: " Reached unreachable code
+CONSOLE MESSAGE: line 76: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
 
+CONSOLE MESSAGE: line 98: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 120: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 132: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 197: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 231: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 32: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 54: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 76: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 98: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 120: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 132: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 197: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+CONSOLE MESSAGE: line 231: The page at https://localhost:9443/service-workers/service-worker/fetch-event-referrer-policy.https.html was allowed to display insecure content from http://localhost:8800/service-workers/service-worker//resources/simple.html?referrerFull.
+
+
+PASS Service Worker responds to fetch event with the referrer policy 
+PASS Service Worker should respond to fetch with the default referrer policy 
+PASS Service Worker should respond to fetch with the referrer URL when a member of RequestInit is present - Default Referrer 
+PASS Service Worker should respond to fetch with no referrer when a member of RequestInit is present with an HTTP request - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer with "" - Default Referrer 
+PASS Service Worker should respond to fetch with no referrer with "" - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "origin" and a same origin request - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "origin" and a cross origin request - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer URL with "origin-when-cross-origin" and a same origin request - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "origin-when-cross-origin" and a cross origin request - Default Referrer 
+PASS Service Worker should respond to fetch with no referrer with "no-referrer-when-downgrade" and a same origin request - Default Referrer 
+PASS Service Worker should respond to fetch with no referrer with "no-referrer-when-downgrade" and an HTTP request - Default Referrer 
+PASS Service Worker should respond to fetch with no referrer with "unsafe-url" - Default Referrer 
+PASS Service Worker should respond to fetch with no referrer URL with "no-referrer" - Default Referrer 
+PASS Service Worker should respond to fetch with referrer URL with "same-origin" and a same origin request - Default Referrer 
+PASS Service Worker should respond to fetch with no referrer with "same-origin" and cross origin request - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer origin  with "strict-origin" and a HTTPS cross origin request - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "strict-origin" and a same origin request - Default Referrer 
+PASS Service Worker should respond to fetch with no referrer with "strict-origin" and a HTTP request - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer URL with "strict-origin-when-cross-origin" and a same origin request - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "strict-origin-when-cross-origin" and a HTTPS cross origin request - Default Referrer 
+PASS Service Worker should respond to fetch with no referrer with "strict-origin-when-cross-origin" and a HTTP request - Default Referrer 
+PASS Service Worker should respond to fetch with the referrer URL when a member of RequestInit is present - Custom Referrer 
+PASS Service Worker should respond to fetch with no referrer when a member of RequestInit is present with an HTTP request - Custom Referrer 
+PASS Service Worker should respond to fetch with the referrer with "" - Custom Referrer 
+PASS Service Worker should respond to fetch with no referrer with "" - Custom Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "origin" and a same origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "origin" and a cross origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with the referrer URL with "origin-when-cross-origin" and a same origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "origin-when-cross-origin" and a cross origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with no referrer with "no-referrer-when-downgrade" and a same origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with no referrer with "no-referrer-when-downgrade" and an HTTP request - Custom Referrer 
+PASS Service Worker should respond to fetch with no referrer with "unsafe-url" - Custom Referrer 
+PASS Service Worker should respond to fetch with no referrer URL with "no-referrer" - Custom Referrer 
+PASS Service Worker should respond to fetch with referrer URL with "same-origin" and a same origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with no referrer with "same-origin" and cross origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with the referrer origin  with "strict-origin" and a HTTPS cross origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "strict-origin" and a same origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with no referrer with "strict-origin" and a HTTP request - Custom Referrer 
+PASS Service Worker should respond to fetch with the referrer URL with "strict-origin-when-cross-origin" and a same origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with the referrer origin with "strict-origin-when-cross-origin" and a HTTPS cross origin request - Custom Referrer 
+PASS Service Worker should respond to fetch with no referrer with "strict-origin-when-cross-origin" and a HTTP request - Custom Referrer 
+

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https.html (226396 => 226397)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https.html	2018-01-04 07:44:55 UTC (rev 226396)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-referrer-policy.https.html	2018-01-04 08:24:54 UTC (rev 226397)
@@ -7,12 +7,22 @@
 <script>
 var worker = 'resources/fetch-event-test-worker.js';
 
+if (window.internals && window.internals.settings)
+    internals.settings.setAllowDisplayOfInsecureContent(true);
+
+function do_test(referrer, value, expected, name)
+{
+    test(() => {
+          assert_equals(value, expected);
+    }, name + (referrer ? " - Custom Referrer" : " - Default Referrer"));
+}
+
 function run_referrer_policy_tests(frame, referrer, href, origin) {
     return frame.contentWindow.fetch('resources/simple.html?referrerFull',
                                      {method: "GET", referrer: referrer})
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + href + '\n' +
             'ReferrerPolicy: no-referrer-when-downgrade',
@@ -24,7 +34,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: \n' +
             'ReferrerPolicy: no-referrer-when-downgrade',
@@ -34,7 +44,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + href + '\n' +
             'ReferrerPolicy: no-referrer-when-downgrade',
@@ -46,7 +56,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: \n' +
             'ReferrerPolicy: no-referrer-when-downgrade',
@@ -56,7 +66,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + origin + '/' + '\n' +
             'ReferrerPolicy: origin',
@@ -68,7 +78,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + origin + '/' + '\n' +
             'ReferrerPolicy: origin',
@@ -78,7 +88,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + href + '\n' +
             'ReferrerPolicy: origin-when-cross-origin',
@@ -90,7 +100,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + origin + '/' + '\n' +
             'ReferrerPolicy: origin-when-cross-origin',
@@ -100,7 +110,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + href + '\n' +
             'ReferrerPolicy: no-referrer-when-downgrade',
@@ -112,7 +122,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: \n' +
             'ReferrerPolicy: no-referrer-when-downgrade',
@@ -123,7 +133,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + href + '\n' +
             'ReferrerPolicy: unsafe-url',
@@ -133,7 +143,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: \n' +
             'ReferrerPolicy: no-referrer',
@@ -143,7 +153,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + href + '\n' +
             'ReferrerPolicy: same-origin',
@@ -155,7 +165,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: \n' +
             'ReferrerPolicy: same-origin',
@@ -167,7 +177,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + origin + '/' + '\n' +
             'ReferrerPolicy: strict-origin',
@@ -177,7 +187,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + origin + '/' + '\n' +
             'ReferrerPolicy: strict-origin',
@@ -189,7 +199,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: \n' +
             'ReferrerPolicy: strict-origin',
@@ -199,7 +209,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + href + '\n' +
             'ReferrerPolicy: strict-origin-when-cross-origin',
@@ -211,7 +221,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: ' + origin + '/' + '\n' +
             'ReferrerPolicy: strict-origin-when-cross-origin',
@@ -223,7 +233,7 @@
         })
       .then(function(response) { return response.text(); })
       .then(function(response_text) {
-          assert_equals(
+          do_test(referrer,
             response_text,
             'Referrer: \n' +
             'ReferrerPolicy: strict-origin-when-cross-origin',
@@ -241,10 +251,9 @@
       .then(function() { return with_iframe(scope); })
       .then(function(f) {
           frame = f;
-          assert_equals(
-            frame.contentDocument.body.textContent,
-            'ReferrerPolicy: no-referrer-when-downgrade',
-            'Service Worker should respond to fetch with the default referrer policy');
+          test(() => {
+            assert_equals(frame.contentDocument.body.textContent, 'ReferrerPolicy: no-referrer-when-downgrade');
+          }, 'Service Worker should respond to fetch with the default referrer policy');
           // First, run the referrer policy tests without passing a referrer in RequestInit.
           return run_referrer_policy_tests(frame, undefined, frame.contentDocument.location.href,
                                            frame.contentDocument.location.origin);
@@ -251,7 +260,7 @@
         })
       .then(function() {
           // Now, run the referrer policy tests while passing a referrer in RequestInit.
-          var referrer = get_host_info()['HTTPS_ORIGIN'] + base_path() + 'fake-referrer';
+          var referrer = get_host_info()['HTTPS_ORIGIN'] + base_path() + 'resources/fake-referrer';
           return run_referrer_policy_tests(frame, 'fake-referrer', referrer,
                                            frame.contentDocument.location.origin);
         })

Modified: trunk/Source/WebCore/ChangeLog (226396 => 226397)


--- trunk/Source/WebCore/ChangeLog	2018-01-04 07:44:55 UTC (rev 226396)
+++ trunk/Source/WebCore/ChangeLog	2018-01-04 08:24:54 UTC (rev 226397)
@@ -1,3 +1,24 @@
+2018-01-04  Youenn Fablet  <[email protected]>
+
+        Implement  https://fetch.spec.whatwg.org/#main-fetch default referrer policy setting
+        https://bugs.webkit.org/show_bug.cgi?id=181239
+
+        Reviewed by Alex Christensen.
+
+        Covered by updated and rebased test.
+
+        Setting the request referrer policy to the Document referrer policy if no one is set.
+        If Document has no referrer policy, use no-referrer-when-downgrade as per the spec.
+
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::updateHTTPRequestHeaders):
+        (WebCore::CachedResourceLoader::requestResource):
+        * loader/cache/CachedResourceLoader.h:
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::updateReferrerPolicy):
+        (WebCore::CachedResourceRequest::updateReferrerOriginAndUserAgentHeaders):
+        * loader/cache/CachedResourceRequest.h:
+
 2018-01-03  Wenson Hsieh  <[email protected]>
 
         [Attachment Support] Create attachment elements when dropping files on iOS

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (226396 => 226397)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2018-01-04 07:44:55 UTC (rev 226396)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2018-01-04 08:24:54 UTC (rev 226397)
@@ -742,7 +742,7 @@
         // In some cases we may try to load resources in frameless documents. Such loads always fail.
         // FIXME: We shouldn't need to do the check on frame.
         if (auto* frame = this->frame())
-            request.updateReferrerOriginAndUserAgentHeaders(frame->loader(), document() ? document()->referrerPolicy() : ReferrerPolicy::NoReferrerWhenDowngrade);
+            request.updateReferrerOriginAndUserAgentHeaders(frame->loader());
     }
 
     request.updateAccordingCacheMode();
@@ -750,6 +750,7 @@
 
 ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ForPreload forPreload, DeferOption defer)
 {
+    // Entry point to https://fetch.spec.whatwg.org/#main-fetch.
     std::unique_ptr<ResourceRequest> originalRequest;
     if (CachedResource::shouldUsePingLoad(type))
         originalRequest = std::make_unique<ResourceRequest>(request.resourceRequest());
@@ -757,6 +758,7 @@
     if (Document* document = this->document())
         request.upgradeInsecureRequestIfNeeded(*document);
 
+    request.updateReferrerPolicy(document() ? document()->referrerPolicy() : ReferrerPolicy::NoReferrerWhenDowngrade);
     URL url = ""
 
     LOG(ResourceLoading, "CachedResourceLoader::requestResource '%s', charset '%s', priority=%d, forPreload=%u", url.stringCenterEllipsizedToLength().latin1().data(), request.charset().latin1().data(), request.priority() ? static_cast<int>(request.priority().value()) : -1, forPreload == ForPreload::Yes);

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (226396 => 226397)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2018-01-04 07:44:55 UTC (rev 226396)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2018-01-04 08:24:54 UTC (rev 226397)
@@ -171,7 +171,6 @@
 
     void prepareFetch(CachedResource::Type, CachedResourceRequest&);
     void updateHTTPRequestHeaders(CachedResource::Type, CachedResourceRequest&);
-    void updateReferrerOriginAndUserAgentHeaders(CachedResourceRequest&);
 
     bool canRequest(CachedResource::Type, const URL&, const CachedResourceRequest&, ForPreload);
 

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp (226396 => 226397)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2018-01-04 07:44:55 UTC (rev 226396)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp	2018-01-04 08:24:54 UTC (rev 226397)
@@ -223,8 +223,14 @@
 
 #endif
 
-void CachedResourceRequest::updateReferrerOriginAndUserAgentHeaders(FrameLoader& frameLoader, ReferrerPolicy defaultPolicy)
+void CachedResourceRequest::updateReferrerPolicy(ReferrerPolicy defaultPolicy)
 {
+    if (m_options.referrerPolicy == ReferrerPolicy::EmptyString)
+        m_options.referrerPolicy = defaultPolicy;
+}
+
+void CachedResourceRequest::updateReferrerOriginAndUserAgentHeaders(FrameLoader& frameLoader)
+{
     // Implementing step 7 to 9 of https://fetch.spec.whatwg.org/#http-network-or-cache-fetch
 
     String outgoingOrigin;
@@ -236,15 +242,7 @@
         outgoingOrigin = frameLoader.outgoingOrigin();
     }
 
-    switch (m_options.referrerPolicy) {
-    case ReferrerPolicy::EmptyString:
-        outgoingReferrer = SecurityPolicy::generateReferrerHeader(defaultPolicy, m_resourceRequest.url(), outgoingReferrer);
-        break;
-    default:
-        outgoingReferrer = SecurityPolicy::generateReferrerHeader(m_options.referrerPolicy, m_resourceRequest.url(), outgoingReferrer);
-        break;
-    };
-
+    outgoingReferrer = SecurityPolicy::generateReferrerHeader(m_options.referrerPolicy, m_resourceRequest.url(), outgoingReferrer);
     if (outgoingReferrer.isEmpty())
         m_resourceRequest.clearHTTPReferrer();
     else

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.h (226396 => 226397)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.h	2018-01-04 07:44:55 UTC (rev 226396)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.h	2018-01-04 08:24:54 UTC (rev 226397)
@@ -75,7 +75,8 @@
     void setAsPotentiallyCrossOrigin(const String&, Document&);
     void updateForAccessControl(Document&);
 
-    void updateReferrerOriginAndUserAgentHeaders(FrameLoader&, ReferrerPolicy);
+    void updateReferrerPolicy(ReferrerPolicy);
+    void updateReferrerOriginAndUserAgentHeaders(FrameLoader&);
     void upgradeInsecureRequestIfNeeded(Document&);
     void setAcceptHeaderIfNone(CachedResource::Type);
     void updateAccordingCacheMode();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to