Changeset 223565 in webkit


Ignore:
Timestamp:
Oct 17, 2017 11:57:21 AM (7 years ago)
Author:
wilander@apple.com
Message:

Add and remove cookie partition accordingly in intermediary redirect requests
https://bugs.webkit.org/show_bug.cgi?id=178369
<rdar://problem/34467603>

Reviewed by Brent Fulgham.

Source/WebCore:

Tests: http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html

http/tests/resourceLoadStatistics/remove-partitioning-from-redirect.html

  • loader/ResourceLoadObserver.h:

Now exposes notifyObserver() so that it can be triggered
by the TestRunner.
Removed unimplemented ResourceLoadObserver::setShouldThrottleObserverNotifications().

Source/WebKit:

  • NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:

(WebKit::shouldChangePartition):

Convenience function. Comment documents the logic.

(WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):

Now adds and removes cookie partition based on the
redirect-to URL's domain.

  • WebProcess/InjectedBundle/API/c/WKBundle.cpp:

(WKBundleResourceLoadStatisticsNotifyObserver):

Test infrastructure.

  • WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:

Tools:

Adds the function statisticsNotifyObserver().

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:

(WTR::InjectedBundle::statisticsNotifyObserver):

  • WebKitTestRunner/InjectedBundle/InjectedBundle.h:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::statisticsNotifyObserver):

  • WebKitTestRunner/InjectedBundle/TestRunner.h:

LayoutTests:

This patch adds two new tests, relevant for the code change.
Also makes changes to existing tests to increase speed and
reliability.

  • http/tests/resourceLoadStatistics/add-partitioning-to-redirect-expected.txt: Added.
  • http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html: Added.
  • http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
  • http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
  • http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
  • http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
  • http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
  • http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
  • http/tests/resourceLoadStatistics/remove-partitioning-from-redirect-expected.txt: Added.
  • http/tests/resourceLoadStatistics/remove-partitioning-from-redirect.html: Added.
  • http/tests/resourceLoadStatistics/resources/get-cookies.php: Added.
  • http/tests/resourceLoadStatistics/resources/redirect.php:
  • http/tests/resourceLoadStatistics/resources/set-cookie.php: Added.
  • http/tests/resourceLoadStatistics/sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
  • http/tests/resourceLoadStatistics/sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
  • http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
  • http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
  • http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
  • http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
  • platform/ios/TestExpectations:

The two new tests are marked [ Pass ].

  • platform/mac-wk2/TestExpectations:

The two new tests are marked [ Pass ].

  • platform/wk2/TestExpectations:

The two new tests are marked [ Skip ] because they require cookie partitioning.

Location:
trunk
Files:
6 added
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r223563 r223565  
     12017-10-17  John Wilander  <wilander@apple.com>
     2
     3        Add and remove cookie partition accordingly in intermediary redirect requests
     4        https://bugs.webkit.org/show_bug.cgi?id=178369
     5        <rdar://problem/34467603>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        This patch adds two new tests, relevant for the code change.
     10        Also makes changes to existing tests to increase speed and
     11        reliability.
     12
     13        * http/tests/resourceLoadStatistics/add-partitioning-to-redirect-expected.txt: Added.
     14        * http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html: Added.
     15        * http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
     16        * http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
     17        * http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
     18        * http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
     19        * http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
     20        * http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
     21        * http/tests/resourceLoadStatistics/remove-partitioning-from-redirect-expected.txt: Added.
     22        * http/tests/resourceLoadStatistics/remove-partitioning-from-redirect.html: Added.
     23        * http/tests/resourceLoadStatistics/resources/get-cookies.php: Added.
     24        * http/tests/resourceLoadStatistics/resources/redirect.php:
     25        * http/tests/resourceLoadStatistics/resources/set-cookie.php: Added.
     26        * http/tests/resourceLoadStatistics/sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
     27        * http/tests/resourceLoadStatistics/sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
     28        * http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
     29        * http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
     30        * http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html:
     31        * http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html:
     32        * platform/ios/TestExpectations:
     33            The two new tests are marked [ Pass ].
     34        * platform/mac-wk2/TestExpectations:
     35            The two new tests are marked [ Pass ].
     36        * platform/wk2/TestExpectations:
     37            The two new tests are marked [ Skip ] because they require cookie partitioning.
     38
    1392017-10-17  Ryan Haddad  <ryanhaddad@apple.com>
    240
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a non-sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
    3755</head>
    3856<body>
    39 <iframe src="http://127.0.0.1:8000/resourceLoadStatistics/resources/redirect.php/?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/redirect.php/?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/resources/iframe-report-back-loaded.html">
     57<iframe src="http://127.0.0.1:8000/resourceLoadStatistics/resources/redirect.php?redirectTo=http://localhost:8000/resourceLoadStatistics/resources/redirect.php/?redirectTo=http://127.0.0.1:8000/resourceLoadStatistics/resources/iframe-report-back-loaded.html">
    4058</iframe>
    4159</body>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a non-sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a non-sandboxed iframe nested in a non-sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a non-sandboxed iframe nested in a non-sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a sandboxed iframe nested in a non-sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/non-sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a sandboxed iframe nested in a non-sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/redirect.php

    r223253 r223565  
    11<?php
    2 header('Location: ' . $_GET["redirectTo"]);
     2$redirectURL = $_GET["redirectTo"];
     3if (isset($_GET["name2"])) {
     4    $redirectURL = $redirectURL . "&name2=" . $_GET["name2"];
     5}
     6if (isset($_GET["name3"])) {
     7    $redirectURL = $redirectURL . "&name3=" . $_GET["name3"];
     8}
     9if (isset($_GET["message"])) {
     10    $redirectURL = $redirectURL . "&message=" . $_GET["message"];
     11}
     12header('Location: ' . $redirectURL);
    313die();
    414?>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/sandboxed-iframe-redirect-ip-to-localhost-to-ip.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for sandboxed iframes get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for sandboxed iframes get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a non-sandboxed iframe nested in a sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-non-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a non-sandboxed iframe nested in a sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a sandboxed iframe nested in a non-sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/http/tests/resourceLoadStatistics/sandboxed-nesting-iframe-with-sandboxed-iframe-redirect-localhost-to-ip-to-localhost.html

    r223253 r223565  
    33<head>
    44    <script src="/js-test-resources/js-test.js"></script>
    5     <script src="/js-test-resources/ui-helper.js"></script>
    65    <script>
    76        description("Tests that redirects for a sandboxed iframe nested in a non-sandboxed iframe get counted properly.");
    87        jsTestIsAsync = true;
    98        window.addEventListener("message", receiveMessage, false);
     9
     10        function setEnableFeature(enable) {
     11            if (!enable)
     12                testRunner.statisticsResetToConsistentState();
     13            internals.setResourceLoadStatisticsEnabled(enable);
     14            testRunner.setCookieStoragePartitioningEnabled(enable);
     15        }
     16
     17        function finishTest() {
     18            setEnableFeature(false);
     19            finishJSTest();
     20        }
     21
    1022        if (testRunner) {
     23            setEnableFeature(true);
    1124            testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
    1225            testRunner.installStatisticsDidScanDataRecordsCallback(checkStats);
    1326        }
    1427
    15         var testPhasesDone = 0;
     28        var lastPageInRedirectChainLoaded = false;
     29        var statsChecked = false;
    1630
    1731        function receiveMessage(event) {
     
    2135            } else
    2236                testFailed("Received a message from an unexpected origin: " + event.origin);
    23             ++testPhasesDone;
    24             if (testPhasesDone === 2)
    25                 finishJSTest();
     37
     38            lastPageInRedirectChainLoaded = true;
     39            if (statsChecked)
     40                finishTest();
     41            else
     42                testRunner.statisticsNotifyObserver();
    2643        }
    2744
     
    3047            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://localhost", "http://127.0.0.1")');
    3148            shouldBeTrue('testRunner.isStatisticsRegisteredAsRedirectingTo("http://127.0.0.1", "http://localhost")');
    32             ++testPhasesDone;
    33             if (testPhasesDone === 2)
    34                 finishJSTest();
     49
     50            statsChecked = true;
     51            if (lastPageInRedirectChainLoaded)
     52                finishTest();
    3553        }
    3654    </script>
  • trunk/LayoutTests/platform/ios/TestExpectations

    r223414 r223565  
    27832783
    27842784webkit.org/b/174120 http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html [ Skip ]
     2785# Skipped in WK2 expectations because cookie partitioning is only available in macOS High Sierra and iOS 11.
     2786http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html [ Pass ]
     2787http/tests/resourceLoadStatistics/remove-partitioning-from-redirect.html [ Pass ]
    27852788
    27862789webkit.org/b/175273 imported/w3c/web-platform-tests/html/browsers/windows/noreferrer-window-name.html [ Failure ]
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r223556 r223565  
    808808[ HighSierra+ ] http/tests/loading/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html [ Pass Failure ]
    809809[ HighSierra+ ] http/tests/loading/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html [ Pass Failure ]
     810[ HighSierra+ ] http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html [ Pass ]
     811[ HighSierra+ ] http/tests/resourceLoadStatistics/remove-partitioning-from-redirect.html [ Pass ]
    810812
    811813# <rdar://problem/33555759>
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r223408 r223565  
    692692http/tests/storageAccess/request-storage-access-top-frame.html [ Pass ]
    693693http/tests/resourceLoadStatistics [ Pass ]
     694# Cookie partitioning is only supported in macOS High Sierra and iOS 11.
     695http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html [ Skip ]
     696http/tests/resourceLoadStatistics/remove-partitioning-from-redirect.html [ Skip ]
     697
    694698
    695699### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
  • trunk/Source/WebCore/ChangeLog

    r223564 r223565  
     12017-10-17  John Wilander  <wilander@apple.com>
     2
     3        Add and remove cookie partition accordingly in intermediary redirect requests
     4        https://bugs.webkit.org/show_bug.cgi?id=178369
     5        <rdar://problem/34467603>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Tests: http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html
     10               http/tests/resourceLoadStatistics/remove-partitioning-from-redirect.html
     11
     12        * loader/ResourceLoadObserver.h:
     13            Now exposes notifyObserver() so that it can be triggered
     14            by the TestRunner.
     15            Removed unimplemented ResourceLoadObserver::setShouldThrottleObserverNotifications().
     16
    1172017-10-17  Jer Noble  <jer.noble@apple.com>
    218
  • trunk/Source/WebCore/loader/ResourceLoadObserver.h

    r223253 r223565  
    5454    WEBCORE_EXPORT static ResourceLoadObserver& shared();
    5555
    56     WEBCORE_EXPORT void setShouldThrottleObserverNotifications(bool);
    57    
    5856    void logFrameNavigation(const Frame&, const Frame& topFrame, const ResourceRequest& newRequest, const URL& redirectUrl);
    5957    void logSubresourceLoading(const Frame*, const ResourceRequest& newRequest, const ResourceResponse& redirectResponse);
     
    6563    WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&&);
    6664
     65    WEBCORE_EXPORT void notifyObserver();
    6766    WEBCORE_EXPORT void clearState();
    6867private:
     
    7372
    7473    void scheduleNotificationIfNeeded();
    75     void notifyObserver();
    7674    Vector<ResourceLoadStatistics> takeStatistics();
    7775
  • trunk/Source/WebKit/ChangeLog

    r223558 r223565  
     12017-10-17  John Wilander  <wilander@apple.com>
     2
     3        Add and remove cookie partition accordingly in intermediary redirect requests
     4        https://bugs.webkit.org/show_bug.cgi?id=178369
     5        <rdar://problem/34467603>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
     10        (WebKit::shouldChangePartition):
     11            Convenience function. Comment documents the logic.
     12        (WebKit::NetworkDataTaskCocoa::willPerformHTTPRedirection):
     13            Now adds and removes cookie partition based on the
     14            redirect-to URL's domain.
     15        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
     16        (WKBundleResourceLoadStatisticsNotifyObserver):
     17            Test infrastructure.
     18        * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
     19
    1202017-10-17  Youenn Fablet  <youenn@apple.com>
    221
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm

    r222667 r223565  
    197197}
    198198
     199static bool shouldChangePartition(const String& requiredStoragePartition, const String& currentStoragePartition)
     200{
     201    // The need for a partion change is according to the following:
     202    //      currentStoragePartition:  null  ""    abc
     203    // requiredStoragePartition: ""   false false true
     204    //                           abc  true  true  false
     205    //                           xyz  true  true  true
     206    return !((requiredStoragePartition.isEmpty() && currentStoragePartition.isEmpty()) || currentStoragePartition == requiredStoragePartition);
     207}
     208
    199209void NetworkDataTaskCocoa::willPerformHTTPRedirection(WebCore::ResourceResponse&& redirectResponse, WebCore::ResourceRequest&& request, RedirectCompletionHandler&& completionHandler)
    200210{
     
    241251    }
    242252   
     253#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     254    if (m_storedCredentialsPolicy == WebCore::StoredCredentialsPolicy::Use) {
     255        String requiredStoragePartition = m_session->networkStorageSession().cookieStoragePartition(request);
     256        if (shouldChangePartition(requiredStoragePartition, m_task.get()._storagePartitionIdentifier)) {
     257            LOG(NetworkSession, "%llu %s cookies for redirected URL %s", [m_task taskIdentifier], (requiredStoragePartition.isEmpty() ? "Not partitioning" : "Partitioning"), request.url().string().utf8().data());
     258            m_task.get()._storagePartitionIdentifier = requiredStoragePartition;
     259        }
     260    }
     261#endif
     262
    243263    if (m_client)
    244264        m_client->willPerformHTTPRedirection(WTFMove(redirectResponse), WTFMove(request), WTFMove(completionHandler));
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp

    r220302 r223565  
    283283    ResourceLoadObserver::shared().clearState();
    284284}
     285
     286void WKBundleResourceLoadStatisticsNotifyObserver(WKBundleRef)
     287{
     288    ResourceLoadObserver::shared().notifyObserver();
     289}
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h

    r220302 r223565  
    9393
    9494WK_EXPORT void WKBundleClearResourceLoadStatistics(WKBundleRef);
     95WK_EXPORT void WKBundleResourceLoadStatisticsNotifyObserver(WKBundleRef);
    9596
    9697#ifdef __cplusplus
  • trunk/Tools/ChangeLog

    r223558 r223565  
     12017-10-17  John Wilander  <wilander@apple.com>
     2
     3        Add and remove cookie partition accordingly in intermediary redirect requests
     4        https://bugs.webkit.org/show_bug.cgi?id=178369
     5        <rdar://problem/34467603>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Adds the function statisticsNotifyObserver().
     10
     11        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     12        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     13        (WTR::InjectedBundle::statisticsNotifyObserver):
     14        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
     15        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     16        (WTR::TestRunner::statisticsNotifyObserver):
     17        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     18
    1192017-10-17  Youenn Fablet  <youenn@apple.com>
    220
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r223558 r223565  
    279279    void setStatisticsTimeToLiveUserInteraction(double seconds);
    280280    void setStatisticsTimeToLiveCookiePartitionFree(double seconds);
     281    void statisticsNotifyObserver();
    281282    void statisticsProcessStatisticsAndDataRecords();
    282283    void statisticsUpdateCookiePartitioning();
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r223433 r223565  
    841841}
    842842
     843void InjectedBundle::statisticsNotifyObserver()
     844{
     845    WKBundleResourceLoadStatisticsNotifyObserver(m_bundle);
     846}
     847
    843848} // namespace WTR
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

    r223211 r223565  
    134134
    135135    void setAllowsAnySSLCertificate(bool);
    136    
     136
     137    void statisticsNotifyObserver();
     138
    137139private:
    138140    InjectedBundle();
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r223558 r223565  
    15191519    callTestRunnerCallback(StatisticsDidRunTelemetryCallbackID, 1, &result);
    15201520}
    1521    
     1521
     1522void TestRunner::statisticsNotifyObserver()
     1523{
     1524    InjectedBundle::singleton().statisticsNotifyObserver();
     1525}
     1526
    15221527void TestRunner::statisticsProcessStatisticsAndDataRecords()
    15231528{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r223558 r223565  
    364364    void statisticsDidScanDataRecordsCallback();
    365365    void statisticsDidRunTelemetryCallback(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins);
     366    void statisticsNotifyObserver();
    366367    void statisticsProcessStatisticsAndDataRecords();
    367368    void statisticsUpdateCookiePartitioning();
Note: See TracChangeset for help on using the changeset viewer.