Changeset 242712 in webkit
- Timestamp:
- Mar 11, 2019, 10:01:27 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 46 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html (modified) (2 diffs)
-
LayoutTests/http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html (modified) (1 diff)
-
LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html (modified) (3 diffs)
-
LayoutTests/http/tests/resourceLoadStatistics/resources/set-cookie-on-redirect.php (modified) (1 diff)
-
LayoutTests/http/tests/resourceLoadStatistics/resources/util.js (modified) (1 diff)
-
LayoutTests/http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-user-interaction.html (modified) (2 diffs)
-
LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction.html (modified) (4 diffs)
-
LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction.html (modified) (4 diffs)
-
LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe.html (modified) (4 diffs)
-
LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html (modified) (4 diffs)
-
LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe.html (modified) (4 diffs)
-
LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe.html (modified) (4 diffs)
-
LayoutTests/http/tests/storageAccess/request-storage-access-top-frame.html (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (modified) (7 diffs)
-
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h (modified) (1 diff)
-
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (modified) (7 diffs)
-
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h (modified) (1 diff)
-
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp (modified) (2 diffs)
-
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h (modified) (4 diffs)
-
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (modified) (4 diffs)
-
Source/WebKit/NetworkProcess/NetworkProcess.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.h (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.messages.in (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkSession.cpp (modified) (2 diffs)
-
Source/WebKit/NetworkProcess/NetworkSession.h (modified) (2 diffs)
-
Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h (modified) (1 diff)
-
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebProcessPool.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (modified) (1 diff)
-
Tools/WebKitTestRunner/TestController.cpp (modified) (1 diff)
-
Tools/WebKitTestRunner/TestController.h (modified) (1 diff)
-
Tools/WebKitTestRunner/TestInvocation.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r242704 r242712 1 2019-03-11 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Make it possible exclude localhost from classification 4 https://bugs.webkit.org/show_bug.cgi?id=195474 5 <rdar://problem/47520577> 6 7 Reviewed by Brent Fulgham. 8 9 This patch makes sure that all test cases that need to, call the enableFeature() 10 function in http/tests/resourceLoadStatistics/resources/util.js. 11 12 The enableFeature() now calls the new function testRunner.setStatisticsIsRunningTest(). 13 14 * http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html: 15 * http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html: 16 * http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html: 17 * http/tests/resourceLoadStatistics/resources/set-cookie-on-redirect.php: 18 * http/tests/resourceLoadStatistics/resources/util.js: 19 (setEnableFeature): 20 * http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-user-interaction.html: 21 * http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction.html: 22 * http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction.html: 23 * http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe.html: 24 * http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html: 25 * http/tests/storageAccess/request-storage-access-same-origin-iframe.html: 26 * http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe.html: 27 * http/tests/storageAccess/request-storage-access-top-frame.html: 28 1 29 2019-03-11 Javier Fernandez <jfernandez@igalia.com> 2 30 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html
r234440 r242712 4 4 <meta charset="UTF-8"> 5 5 <script src="/js-test-resources/js-test.js"></script> 6 <script src="resources/util.js"></script> 6 7 <script> 7 8 description("Tests that blocking is not applied to top-level navigation redirects."); … … 12 13 function doRedirect() 13 14 { 14 testRunner.setStatisticsPrevalentResource("http://localhost", true, function() { 15 if (!testRunner.isStatisticsPrevalentResource("http://localhost")) { 16 testFailed("Host did not get set as prevalent resource."); 17 finishJSTest(); 18 } 19 else 20 document.location.href = "http://localhost:8000/resourceLoadStatistics/resources/set-cookie-on-redirect.php?step=1"; 15 setEnableFeature(true, function () { 16 testRunner.setStatisticsPrevalentResource("http://localhost", true, function () { 17 if (!testRunner.isStatisticsPrevalentResource("http://localhost")) { 18 testFailed("Host did not get set as prevalent resource."); 19 setEnableFeature(false, finishJSTest); 20 } else 21 document.location.href = "http://localhost:8000/resourceLoadStatistics/resources/set-cookie-on-redirect.php?step=1"; 22 }); 21 23 }); 22 24 } 23 25 </script> 24 26 </head> 25 <body onload=" doRedirect()">27 <body onload="setTimeout('doRedirect()', 0)"> 26 28 </body> 27 29 </html> -
trunk/LayoutTests/http/tests/resourceLoadStatistics/non-sandboxed-iframe-redirect-ip-to-localhost-to-ip.html
r234440 r242712 42 42 if (testRunner) { 43 43 setEnableFeature(true, function() { 44 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);45 44 testRunner.installStatisticsDidScanDataRecordsCallback(checkStats); 46 45 }); -
trunk/LayoutTests/http/tests/resourceLoadStatistics/prevalent-resource-with-user-interaction.html
r233888 r242712 5 5 <title>Tests for Prevalent Resource With User Interaction</title> 6 6 <script src="/js-test-resources/js-test.js"></script> 7 <script src="resources/util.js"></script> 7 8 </head> 8 <body >9 <body onload="setTimeout('setUpAndRun()', 0)"> 9 10 <script> 11 if (testRunner) 12 testRunner.waitUntilDone(); 13 10 14 const hostUnderTest = "127.0.0.1:8000"; 11 15 const statisticsUrl = "http://" + hostUnderTest + "/temp"; … … 38 42 else 39 43 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie); 40 internals.setResourceLoadStatisticsEnabled(false); 41 testRunner.statisticsResetToConsistentState(function() { 44 setEnableFeature(false, function() { 42 45 testRunner.notifyDone(); 43 46 }); … … 51 54 } 52 55 53 if (document.location.host === hostUnderTest && window.testRunner && window.internals) { 54 testRunner.waitUntilDone(); 55 internals.setResourceLoadStatisticsEnabled(true); 56 testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true); 57 runTestRunnerTest(); 56 function setUpAndRun() { 57 if (document.location.host === hostUnderTest && window.testRunner && window.internals) { 58 setEnableFeature(true, function () { 59 runTestRunnerTest(); 60 }); 61 } else { 62 testFailed("Wrong host, no testRunner, or no internals."); 63 testRunner.notifyDone(); 64 } 58 65 } 59 66 </script> -
trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/set-cookie-on-redirect.php
r234440 r242712 17 17 echo "FAILED: Cookie not set\n"; 18 18 } 19 echo "<script>if (window.testRunner && window.internals) testRunner.statisticsResetToConsistentState(function() { internals.setResourceLoadStatisticsEnabled(false); testRunner.notifyDone(); });</script>"; 19 echo "<script src='util.js'></script>"; 20 echo "<script>if (window.testRunner && window.internals) setEnableFeature(false, finishJSTest);</script>"; 20 21 } 21 22 ?> -
trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/util.js
r234440 r242712 5 5 if (enable) { 6 6 internals.setResourceLoadStatisticsEnabled(true); 7 testRunner.setStatisticsIsRunningTest(true); 7 8 completionHandler(); 8 9 } else { 9 10 testRunner.statisticsResetToConsistentState(function() { 11 testRunner.setStatisticsIsRunningTest(false); 10 12 internals.setResourceLoadStatisticsEnabled(false); 11 13 completionHandler(); -
trunk/LayoutTests/http/tests/storageAccess/has-storage-access-from-prevalent-domain-with-user-interaction.html
r234440 r242712 4 4 <script src="/js-test-resources/js-test.js"></script> 5 5 <script src="/js-test-resources/ui-helper.js"></script> 6 <script src="/resourceLoadStatistics/resources/util.js"></script> 6 7 <script> 7 8 description("Tests that a cross-origin iframe from a prevalent domain with user interaction does not have storage access."); … … 18 19 } else 19 20 testFailed("Received a message from an unexpected origin: " + event.origin); 20 finishJSTest();21 setEnableFeature(false, finishJSTest); 21 22 } 22 23 23 24 const hostUnderTest = "localhost:8000"; 24 25 const statisticsUrl = "http://" + hostUnderTest + "/temp"; 25 testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() { 26 if (!testRunner.isStatisticsPrevalentResource(statisticsUrl)) 27 testFailed("Host did not get set as prevalent resource."); 28 testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() { 29 if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl)) 30 testFailed("Host did not get logged for user interaction."); 31 let iframeElement = document.createElement("iframe"); 32 iframeElement.setAttribute("sandbox", "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals"); 33 iframeElement.id = "TheIframeThatRequestsStorageAccess"; 34 iframeElement.src = "http://localhost:8000/storageAccess/resources/has-storage-access-iframe.html#policyShouldNotGrantAccess"; 35 document.body.appendChild(iframeElement); 26 function runTest() { 27 setEnableFeature(true, function() { 28 testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() { 29 if (!testRunner.isStatisticsPrevalentResource(statisticsUrl)) 30 testFailed("Host did not get set as prevalent resource."); 31 testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() { 32 if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl)) 33 testFailed("Host did not get logged for user interaction."); 34 let iframeElement = document.createElement("iframe"); 35 iframeElement.setAttribute("sandbox", "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals"); 36 iframeElement.id = "TheIframeThatRequestsStorageAccess"; 37 iframeElement.src = "http://localhost:8000/storageAccess/resources/has-storage-access-iframe.html#policyShouldNotGrantAccess"; 38 document.body.appendChild(iframeElement); 39 }); 40 }); 41 36 42 }); 37 } );43 } 38 44 </script> 39 45 </head> 40 <body >46 <body onload="runTest()"> 41 47 </body> 42 48 </html> -
trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-with-user-interaction.html
r234440 r242712 4 4 <script src="/js-test-resources/js-test.js"></script> 5 5 <script src="/js-test-resources/ui-helper.js"></script> 6 <script src="/resourceLoadStatistics/resources/util.js"></script> 6 7 <script> 7 8 description("Tests that cross-origin iframe storage access is granted if the iframe is sandboxed, has the allow token, the iframe origin is a prevalent resource, the iframe origin has had recent user interaction, and the user opts in."); … … 18 19 } else 19 20 testFailed("Received a message from an unexpected origin: " + event.origin); 20 finishJSTest();21 setEnableFeature(false, finishJSTest); 21 22 } 22 23 … … 31 32 else { 32 33 testFailed("No eventSender."); 33 finishJSTest();34 setEnableFeature(false, finishJSTest); 34 35 } 35 36 }, 36 37 function () { 37 38 testFailed("Promise rejected."); 38 finishJSTest();39 setEnableFeature(false, finishJSTest); 39 40 } 40 41 ); … … 47 48 const hostUnderTest = "localhost:8000"; 48 49 const statisticsUrl = "http://" + hostUnderTest + "/temp"; 49 testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() { 50 if (!testRunner.isStatisticsPrevalentResource(statisticsUrl)) 51 testFailed("Host did not get set as prevalent resource."); 52 testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() { 53 if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl)) 54 testFailed("Host did not get logged for user interaction."); 55 let iframeElement = document.createElement("iframe"); 56 iframeElement.setAttribute("sandbox", "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals"); 57 iframeElement.onload = runTest; 58 iframeElement.id = "TheIframeThatRequestsStorageAccess"; 59 iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess,isNotSameOriginIframe"; 60 document.body.appendChild(iframeElement); 50 setEnableFeature(true, function() { 51 testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() { 52 if (!testRunner.isStatisticsPrevalentResource(statisticsUrl)) 53 testFailed("Host did not get set as prevalent resource."); 54 testRunner.setStatisticsHasHadUserInteraction(statisticsUrl, true, function() { 55 if (!testRunner.isStatisticsHasHadUserInteraction(statisticsUrl)) 56 testFailed("Host did not get logged for user interaction."); 57 let iframeElement = document.createElement("iframe"); 58 iframeElement.setAttribute("sandbox", "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals"); 59 iframeElement.onload = runTest; 60 iframeElement.id = "TheIframeThatRequestsStorageAccess"; 61 iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldGrantAccess,isNotSameOriginIframe"; 62 document.body.appendChild(iframeElement); 63 }); 61 64 }); 62 65 }); -
trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe-from-prevalent-domain-without-user-interaction.html
r234440 r242712 4 4 <script src="/js-test-resources/js-test.js"></script> 5 5 <script src="/js-test-resources/ui-helper.js"></script> 6 <script src="/resourceLoadStatistics/resources/util.js"></script> 6 7 <script> 7 8 description("Tests that cross-origin iframe storage access is denied if the iframe is sandboxed, has the allow token, the iframe origin is a prevalent resource, the iframe origin has not had user interaction, and the user opts in."); … … 18 19 } else 19 20 testFailed("Received a message from an unexpected origin: " + event.origin); 20 finishJSTest();21 setEnableFeature(false, finishJSTest); 21 22 } 22 23 … … 31 32 else { 32 33 testFailed("No eventSender."); 33 finishJSTest();34 setEnableFeature(false, finishJSTest); 34 35 } 35 36 }, 36 37 function () { 37 38 testFailed("Promise rejected."); 38 finishJSTest();39 setEnableFeature(false, finishJSTest); 39 40 } 40 41 ); … … 47 48 const hostUnderTest = "localhost:8000"; 48 49 const statisticsUrl = "http://" + hostUnderTest + "/temp"; 49 testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() { 50 if (!testRunner.isStatisticsPrevalentResource(statisticsUrl)) 51 testFailed("Host did not get set as prevalent resource."); 52 let iframeElement = document.createElement("iframe"); 53 iframeElement.setAttribute("sandbox", "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals"); 54 iframeElement.onload = runTest; 55 iframeElement.id = "TheIframeThatRequestsStorageAccess"; 56 iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldNotGrantAccess,isNotSameOriginIframe"; 57 document.body.appendChild(iframeElement); 50 51 setEnableFeature(true, function() { 52 testRunner.setStatisticsPrevalentResource(statisticsUrl, true, function() { 53 if (!testRunner.isStatisticsPrevalentResource(statisticsUrl)) 54 testFailed("Host did not get set as prevalent resource."); 55 let iframeElement = document.createElement("iframe"); 56 iframeElement.setAttribute("sandbox", "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-modals"); 57 iframeElement.onload = runTest; 58 iframeElement.id = "TheIframeThatRequestsStorageAccess"; 59 iframeElement.src = "http://localhost:8000/storageAccess/resources/request-storage-access-iframe.html#userShouldGrantAccess,userShouldBeConsulted,policyShouldNotGrantAccess,isNotSameOriginIframe"; 60 document.body.appendChild(iframeElement); 61 }); 58 62 }); 59 63 </script> -
trunk/LayoutTests/http/tests/storageAccess/request-and-grant-access-cross-origin-sandboxed-iframe.html
r234440 r242712 4 4 <script src="/js-test-resources/js-test.js"></script> 5 5 <script src="/js-test-resources/ui-helper.js"></script> 6 <script src="/resourceLoadStatistics/resources/util.js"></script> 6 7 <script> 7 8 description("Tests that cross-origin iframe storage access is granted if the iframe is sandboxed, has the allow token, and the user opts in."); … … 18 19 } else 19 20 testFailed("Received a message from an unexpected origin: " + event.origin); 20 finishJSTest();21 setEnableFeature(false, finishJSTest); 21 22 } 22 23 … … 31 32 else { 32 33 testFailed("No eventSender."); 33 finishJSTest();34 setEnableFeature(false, finishJSTest); 34 35 } 35 36 }, 36 37 function () { 37 38 testFailed("Promise rejected."); 38 finishJSTest();39 setEnableFeature(false, finishJSTest); 39 40 } 40 41 ); … … 42 43 43 44 function runTest() { 44 activateElement("TheIframeThatRequestsStorageAccess"); 45 setEnableFeature(true, function() { 46 activateElement("TheIframeThatRequestsStorageAccess"); 47 }); 45 48 } 46 49 </script> -
trunk/LayoutTests/http/tests/storageAccess/request-storage-access-cross-origin-sandboxed-iframe-with-unique-origin.html
r234440 r242712 4 4 <script src="/js-test-resources/js-test.js"></script> 5 5 <script src="/js-test-resources/ui-helper.js"></script> 6 <script src="/resourceLoadStatistics/resources/util.js"></script> 6 7 <script> 7 8 description("Tests that cross-origin iframe storage access is denied if the iframe is sandboxed and has the unique origin because it lacks the allow-same-origin token."); … … 18 19 } else 19 20 testFailed("Received a message from an unexpected origin: " + event.origin); 20 finishJSTest();21 setEnableFeature(false, finishJSTest); 21 22 } 22 23 … … 31 32 else { 32 33 testFailed("No eventSender."); 33 finishJSTest();34 setEnableFeature(false, finishJSTest); 34 35 } 35 36 }, 36 37 function () { 37 38 testFailed("Promise rejected."); 38 finishJSTest();39 setEnableFeature(false, finishJSTest); 39 40 } 40 41 ); … … 42 43 43 44 function runTest() { 44 activateElement("TheIframeThatRequestsStorageAccess"); 45 setEnableFeature(true, function() { 46 activateElement("TheIframeThatRequestsStorageAccess"); 47 }); 45 48 } 46 49 </script> -
trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-iframe.html
r234440 r242712 4 4 <script src="/js-test-resources/js-test.js"></script> 5 5 <script src="/js-test-resources/ui-helper.js"></script> 6 <script src="/resourceLoadStatistics/resources/util.js"></script> 6 7 <script> 7 8 description("Tests that same-origin iframe storage access is granted if the iframe is not sandboxed."); … … 18 19 } else 19 20 testFailed("Received a message from an unexpected origin: " + event.origin); 20 finishJSTest();21 setEnableFeature(false, finishJSTest); 21 22 } 22 23 … … 31 32 else { 32 33 testFailed("No eventSender."); 33 finishJSTest();34 setEnableFeature(false, finishJSTest); 34 35 } 35 36 }, 36 37 function () { 37 38 testFailed("Promise rejected."); 38 finishJSTest();39 setEnableFeature(false, finishJSTest); 39 40 } 40 41 ); … … 42 43 43 44 function runTest() { 44 activateElement("TheIframeThatRequestsStorageAccess"); 45 setEnableFeature(true, function() { 46 activateElement("TheIframeThatRequestsStorageAccess"); 47 }); 45 48 } 46 49 </script> -
trunk/LayoutTests/http/tests/storageAccess/request-storage-access-same-origin-sandboxed-iframe.html
r234440 r242712 4 4 <script src="/js-test-resources/js-test.js"></script> 5 5 <script src="/js-test-resources/ui-helper.js"></script> 6 <script src="/resourceLoadStatistics/resources/util.js"></script> 6 7 <script> 7 8 description("Tests that same-origin iframe storage access is granted if the iframe is sandboxed and has the allow token."); … … 18 19 } else 19 20 testFailed("Received a message from an unexpected origin: " + event.origin); 20 finishJSTest();21 setEnableFeature(false, finishJSTest); 21 22 } 22 23 … … 31 32 else { 32 33 testFailed("No eventSender."); 33 finishJSTest();34 setEnableFeature(false, finishJSTest); 34 35 } 35 36 }, 36 37 function () { 37 38 testFailed("Promise rejected."); 38 finishJSTest();39 setEnableFeature(false, finishJSTest); 39 40 } 40 41 ); … … 42 43 43 44 function runTest() { 44 activateElement("TheIframeThatRequestsStorageAccess"); 45 setEnableFeature(true, function() { 46 activateElement("TheIframeThatRequestsStorageAccess"); 47 }); 45 48 } 46 49 </script> -
trunk/LayoutTests/http/tests/storageAccess/request-storage-access-top-frame.html
r234440 r242712 27 27 28 28 function makeRequestWithUserGesture() { 29 var promise = document.requestStorageAccess(); 30 promise.then( 31 function () { 32 requestStorageAccessResolved = true; 33 continueAfterRequestWithUserGesture(); 34 }, 35 function () { 36 requestStorageAccessResolved = false; 37 continueAfterRequestWithUserGesture(); 38 } 39 ); 29 setEnableFeature(true, function() { 30 var promise = document.requestStorageAccess(); 31 promise.then( 32 function () { 33 requestStorageAccessResolved = true; 34 continueAfterRequestWithUserGesture(); 35 }, 36 function () { 37 requestStorageAccessResolved = false; 38 continueAfterRequestWithUserGesture(); 39 } 40 ); 41 }); 40 42 } 41 43 -
trunk/Source/WebKit/ChangeLog
r242710 r242712 1 2019-03-11 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Make it possible exclude localhost from classification 4 https://bugs.webkit.org/show_bug.cgi?id=195474 5 <rdar://problem/47520577> 6 7 Reviewed by Brent Fulgham. 8 9 This patch allows for localhost to be excluded from classification and 10 treatment as a prevalent resource. 11 12 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp: 13 (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore): 14 (WebKit::ResourceLoadStatisticsDatabaseStore::reclassifyResources): 15 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 16 (WebKit::ResourceLoadStatisticsDatabaseStore::setPrevalentResource): 17 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 18 (WebKit::ResourceLoadStatisticsDatabaseStore::isPrevalentResource const): 19 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 20 (WebKit::ResourceLoadStatisticsDatabaseStore::isVeryPrevalentResource const): 21 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 22 (WebKit::ResourceLoadStatisticsDatabaseStore::setVeryPrevalentResource): 23 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 24 * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h: 25 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: 26 (WebKit::ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore): 27 (WebKit::ResourceLoadStatisticsMemoryStore::classifyPrevalentResources): 28 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 29 (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResource): 30 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 31 (WebKit::ResourceLoadStatisticsMemoryStore::isPrevalentResource const): 32 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 33 (WebKit::ResourceLoadStatisticsMemoryStore::isVeryPrevalentResource const): 34 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 35 (WebKit::ResourceLoadStatisticsMemoryStore::setVeryPrevalentResource): 36 Makes use of the new ResourceLoadStatisticsMemoryStore::shouldSkip(). 37 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h: 38 * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp: 39 (WebKit::ResourceLoadStatisticsStore::ResourceLoadStatisticsStore): 40 Now takes a ShouldIncludeLocalhost parameter. 41 (WebKit::ResourceLoadStatisticsStore::shouldSkip const): 42 Convenience function, currently supporting the localhost exclusion. 43 (WebKit::ResourceLoadStatisticsStore::setIsRunningTest): 44 Test infrastructure. 45 * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h: 46 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 47 (WebKit::WebResourceLoadStatisticsStore::setIsRunningTest): 48 Test infrastructure. 49 (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore): 50 Now takes a ShouldIncludeLocalhost parameter. 51 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: 52 Defines the new ShouldIncludeLocalhost boolean enum. 53 * NetworkProcess/NetworkProcess.cpp: 54 (WebKit::NetworkProcess::setIsRunningResourceLoadStatisticsTest): 55 Test infrastructure. 56 * NetworkProcess/NetworkProcess.h: 57 * NetworkProcess/NetworkProcess.messages.in: 58 * NetworkProcess/NetworkSession.cpp: 59 (WebKit::NetworkSession::setResourceLoadStatisticsEnabled): 60 Forwards the localhost setting to the create function. 61 * NetworkProcess/NetworkSession.h: 62 * NetworkProcess/NetworkSessionCreationParameters.cpp: 63 (WebKit::NetworkSessionCreationParameters::encode const): 64 (WebKit::NetworkSessionCreationParameters::decode): 65 * NetworkProcess/NetworkSessionCreationParameters.h: 66 New parameter called shouldIncludeLocalhostInResourceLoadStatistics. 67 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 68 (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): 69 Picks up the localhost setting from the parameters. 70 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 71 (WKWebsiteDataStoreSetStatisticsIsRunningTest): 72 Test infrastructure. 73 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 74 * UIProcess/Network/NetworkProcessProxy.cpp: 75 (WebKit::NetworkProcessProxy::setIsRunningResourceLoadStatisticsTest): 76 Test infrastructure. 77 * UIProcess/Network/NetworkProcessProxy.h: 78 * UIProcess/WebProcessPool.cpp: 79 (WebKit::WebProcessPool::ensureNetworkProcess): 80 Picks up the localhost setting from the WebsiteDataStore parameters. 81 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 82 (WebKit::WebsiteDataStore::parameters): 83 Makes sure Safari does not exclude localhost. 84 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 85 (WebKit::WebsiteDataStore::setIsRunningResourceLoadStatisticsTest): 86 Test infrastructure. 87 * UIProcess/WebsiteData/WebsiteDataStore.h: 88 1 89 2019-03-11 Alex Christensen <achristensen@webkit.org> 2 90 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp
r242603 r242712 159 159 "FOREIGN KEY(fromDomainID) REFERENCES ObservedDomains(domainID) ON DELETE CASCADE);"_s; 160 160 161 ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, const String& storageDirectoryPath)162 : ResourceLoadStatisticsStore(store, workQueue )161 ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost, const String& storageDirectoryPath) 162 : ResourceLoadStatisticsStore(store, workQueue, shouldIncludeLocalhost) 163 163 , m_storageDirectoryPath(storageDirectoryPath + "/observations.db") 164 164 , m_observedDomainCount(m_database, observedDomainCountQuery) … … 690 690 691 691 for (auto& resourceStatistic : notVeryPrevalentResources.values()) { 692 if (shouldSkip(resourceStatistic.registerableDomain)) 693 continue; 694 692 695 auto newPrevalence = classifier().calculateResourcePrevalence(resourceStatistic.subresourceUnderTopFrameDomainsCount, resourceStatistic.subresourceUniqueRedirectsToCount, resourceStatistic.subframeUnderTopFrameDomainsCount, resourceStatistic.topFrameUniqueRedirectsToCount, resourceStatistic.prevalence); 693 696 if (newPrevalence != resourceStatistic.prevalence) … … 1067 1070 { 1068 1071 ASSERT(!RunLoop::isMain()); 1072 if (shouldSkip(domain)) 1073 return; 1069 1074 1070 1075 if (m_updatePrevalentResourceStatement.bindInt(1, 1) != SQLITE_OK … … 1140 1145 ASSERT(!RunLoop::isMain()); 1141 1146 1147 if (shouldSkip(domain)) 1148 return false; 1149 1142 1150 return predicateValueForDomain(m_isPrevalentResourceStatement, domain); 1143 1151 } … … 1146 1154 { 1147 1155 ASSERT(!RunLoop::isMain()); 1156 1157 if (shouldSkip(domain)) 1158 return false; 1148 1159 1149 1160 return predicateValueForDomain(m_isVeryPrevalentResourceStatement, domain); … … 1585 1596 ASSERT(!RunLoop::isMain()); 1586 1597 1598 if (shouldSkip(domain)) 1599 return; 1600 1587 1601 ensureResourceStatisticsForRegistrableDomain(domain); 1588 1602 setPrevalentResource(domain, ResourceLoadPrevalence::High); … … 1593 1607 ASSERT(!RunLoop::isMain()); 1594 1608 1609 if (shouldSkip(domain)) 1610 return; 1611 1595 1612 ensureResourceStatisticsForRegistrableDomain(domain); 1596 1613 setPrevalentResource(domain, ResourceLoadPrevalence::VeryHigh); -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h
r242603 r242712 51 51 class ResourceLoadStatisticsDatabaseStore final : public ResourceLoadStatisticsStore { 52 52 public: 53 ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore&, WorkQueue&, const String& storageDirectoryPath);53 ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost, const String& storageDirectoryPath); 54 54 55 55 void populateFromMemoryStore(const ResourceLoadStatisticsMemoryStore&); -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
r242603 r242712 68 68 } 69 69 70 ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue )71 : ResourceLoadStatisticsStore(store, workQueue )70 ResourceLoadStatisticsMemoryStore::ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost) 71 : ResourceLoadStatisticsStore(store, workQueue, shouldIncludeLocalhost) 72 72 { 73 73 ASSERT(!RunLoop::isMain()); … … 176 176 { 177 177 for (auto& resourceStatistic : m_resourceStatisticsMap.values()) { 178 if (shouldSkip(resourceStatistic.registrableDomain)) 179 continue; 178 180 if (isPrevalentDueToDebugMode(resourceStatistic)) 179 181 setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::High); … … 459 461 ASSERT(!RunLoop::isMain()); 460 462 463 if (shouldSkip(resourceStatistic.registrableDomain)) 464 return; 465 461 466 resourceStatistic.isPrevalentResource = true; 462 467 resourceStatistic.isVeryPrevalentResource = newPrevalence == ResourceLoadPrevalence::VeryHigh; … … 487 492 ASSERT(!RunLoop::isMain()); 488 493 494 if (shouldSkip(domain)) 495 return false; 496 489 497 auto mapEntry = m_resourceStatisticsMap.find(domain); 490 498 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.isPrevalentResource; … … 495 503 ASSERT(!RunLoop::isMain()); 496 504 505 if (shouldSkip(domain)) 506 return false; 507 497 508 auto mapEntry = m_resourceStatisticsMap.find(domain); 498 509 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.isPrevalentResource && mapEntry->value.isVeryPrevalentResource; … … 851 862 ASSERT(!RunLoop::isMain()); 852 863 864 if (shouldSkip(domain)) 865 return; 866 853 867 auto& resourceStatistic = ensureResourceStatisticsForRegistrableDomain(domain); 854 868 setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::High); … … 859 873 ASSERT(!RunLoop::isMain()); 860 874 875 if (shouldSkip(domain)) 876 return; 877 861 878 auto& resourceStatistic = ensureResourceStatisticsForRegistrableDomain(domain); 862 879 setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::VeryHigh); -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h
r242603 r242712 48 48 class ResourceLoadStatisticsMemoryStore final : public ResourceLoadStatisticsStore { 49 49 public: 50 ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore&, WorkQueue& );50 ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost); 51 51 52 52 void setPersistentStorage(ResourceLoadStatisticsPersistentStorage&); -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
r242598 r242712 102 102 } 103 103 104 ResourceLoadStatisticsStore::ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue )104 ResourceLoadStatisticsStore::ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore& store, WorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost) 105 105 : m_store(store) 106 106 , m_workQueue(workQueue) 107 , m_shouldIncludeLocalhost(shouldIncludeLocalhost) 107 108 { 108 109 ASSERT(!RunLoop::isMain()); … … 130 131 ASSERT(!RunLoop::isMain()); 131 132 m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned = value; 133 } 134 135 bool ResourceLoadStatisticsStore::shouldSkip(const RegistrableDomain& domain) const 136 { 137 ASSERT(!RunLoop::isMain()); 138 return !(parameters().isRunningTest) 139 && m_shouldIncludeLocalhost == ShouldIncludeLocalhost::No && domain.string() == "localhost"; 140 } 141 142 void ResourceLoadStatisticsStore::setIsRunningTest(bool value) 143 { 144 ASSERT(!RunLoop::isMain()); 145 m_parameters.isRunningTest = value; 132 146 } 133 147 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h
r242603 r242712 147 147 148 148 void setNotifyPagesWhenDataRecordsWereScanned(bool); 149 void setIsRunningTest(bool); 150 bool shouldSkip(const RegistrableDomain&) const; 149 151 void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool); 150 152 void setShouldSubmitTelemetry(bool); … … 185 187 static void debugLogDomainsInBatches(const char* action, const Vector<RegistrableDomain>& domains); 186 188 187 ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore&, WorkQueue& );189 ResourceLoadStatisticsStore(WebResourceLoadStatisticsStore&, WorkQueue&, ShouldIncludeLocalhost); 188 190 189 191 bool hasStatisticsExpired(const ResourceLoadStatistics&) const; … … 217 219 bool shouldClassifyResourcesBeforeDataRecordsRemoval { true }; 218 220 bool shouldSubmitTelemetry { true }; 221 bool isRunningTest { false }; 219 222 }; 220 223 const Parameters& parameters() const { return m_parameters; } … … 266 269 bool m_storageAccessPromptsEnabled { false }; 267 270 bool m_dataRecordsBeingRemoved { false }; 271 ShouldIncludeLocalhost m_shouldIncludeLocalhost { ShouldIncludeLocalhost::Yes }; 268 272 }; 269 273 -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r242603 r242712 109 109 } 110 110 111 void WebResourceLoadStatisticsStore::setIsRunningTest(bool value, CompletionHandler<void()>&& completionHandler) 112 { 113 ASSERT(RunLoop::isMain()); 114 115 postTask([this, value, completionHandler = WTFMove(completionHandler)]() mutable { 116 if (m_statisticsStore) 117 m_statisticsStore->setIsRunningTest(value); 118 119 postTaskReply(WTFMove(completionHandler)); 120 }); 121 } 122 111 123 void WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value, CompletionHandler<void()>&& completionHandler) 112 124 { … … 139 151 } 140 152 141 WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory )153 WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory, ShouldIncludeLocalhost shouldIncludeLocalhost) 142 154 : m_networkSession(makeWeakPtr(networkSession)) 143 155 , m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility)) … … 146 158 ASSERT(RunLoop::isMain()); 147 159 148 postTask([this, resourceLoadStatisticsDirectory = resourceLoadStatisticsDirectory.isolatedCopy() ] {160 postTask([this, resourceLoadStatisticsDirectory = resourceLoadStatisticsDirectory.isolatedCopy(), shouldIncludeLocalhost] { 149 161 if (RuntimeEnabledFeatures::sharedFeatures().isITPDatabaseEnabled()) { 150 m_statisticsStore = std::make_unique<ResourceLoadStatisticsDatabaseStore>(*this, m_statisticsQueue, resourceLoadStatisticsDirectory);151 152 auto memoryStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue );162 m_statisticsStore = std::make_unique<ResourceLoadStatisticsDatabaseStore>(*this, m_statisticsQueue, shouldIncludeLocalhost, resourceLoadStatisticsDirectory); 163 164 auto memoryStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue, shouldIncludeLocalhost); 153 165 auto persistentStore = std::make_unique<ResourceLoadStatisticsPersistentStorage>(*memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory); 154 166 155 167 downcast<ResourceLoadStatisticsDatabaseStore>(*m_statisticsStore.get()).populateFromMemoryStore(*memoryStore); 156 168 } else { 157 m_statisticsStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue );169 m_statisticsStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue, shouldIncludeLocalhost); 158 170 m_persistentStorage = std::make_unique<ResourceLoadStatisticsPersistentStorage>(downcast<ResourceLoadStatisticsMemoryStore>(*m_statisticsStore), m_statisticsQueue, resourceLoadStatisticsDirectory); 159 171 } -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
r242603 r242712 59 59 class WebProcessProxy; 60 60 enum class ShouldGrandfatherStatistics : bool; 61 enum class ShouldIncludeLocalhost : bool { No, Yes }; 61 62 62 63 class WebResourceLoadStatisticsStore final : public ThreadSafeRefCounted<WebResourceLoadStatisticsStore, WTF::DestructionThread::Main>, public IPC::MessageReceiver { … … 78 79 using FrameID = uint64_t; 79 80 80 static Ref<WebResourceLoadStatisticsStore> create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory )81 static Ref<WebResourceLoadStatisticsStore> create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory, ShouldIncludeLocalhost shouldIncludeLocalhost) 81 82 { 82 return adoptRef(*new WebResourceLoadStatisticsStore(networkSession, resourceLoadStatisticsDirectory ));83 return adoptRef(*new WebResourceLoadStatisticsStore(networkSession, resourceLoadStatisticsDirectory, shouldIncludeLocalhost)); 83 84 } 84 85 … … 129 130 void removePrevalentDomains(const Vector<RegistrableDomain>&); 130 131 void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&); 132 void setIsRunningTest(bool, CompletionHandler<void()>&&); 131 133 void setSubframeUnderTopFrameDomain(const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void()>&&); 132 134 void setSubresourceUnderTopFrameDomain(const SubResourceDomain&, const TopFrameDomain&, CompletionHandler<void()>&&); … … 172 174 173 175 private: 174 explicit WebResourceLoadStatisticsStore(NetworkSession&, const String& );176 explicit WebResourceLoadStatisticsStore(NetworkSession&, const String&, ShouldIncludeLocalhost); 175 177 176 178 void postTask(WTF::Function<void()>&&); -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r242603 r242712 787 787 } 788 788 789 void NetworkProcess::setIsRunningResourceLoadStatisticsTest(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) 790 { 791 if (auto* networkSession = this->networkSession(sessionID)) { 792 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 793 resourceLoadStatistics->setIsRunningTest(value, WTFMove(completionHandler)); 794 else 795 completionHandler(); 796 } else { 797 ASSERT_NOT_REACHED(); 798 completionHandler(); 799 } 800 } 801 789 802 void NetworkProcess::setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) 790 803 { -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r242603 r242712 245 245 void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 246 246 void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool value, CompletionHandler<void()>&&); 247 void setIsRunningResourceLoadStatisticsTest(PAL::SessionID, bool value, CompletionHandler<void()>&&); 247 248 void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool value, CompletionHandler<void()>&&); 248 249 void setResourceLoadStatisticsEnabled(bool); -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r242603 r242712 122 122 SetShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value) -> () Async 123 123 SetNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value) -> () Async 124 SetIsRunningResourceLoadStatisticsTest(PAL::SessionID sessionID, bool value) -> () Async 124 125 SetNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value) -> () Async 125 126 SetResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode) -> () Async -
trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp
r242598 r242712 31 31 #include "NetworkProcessProxyMessages.h" 32 32 #include "WebProcessProxy.h" 33 #include "WebResourceLoadStatisticsStore.h"34 33 #include <WebCore/AdClickAttribution.h> 35 34 #include <WebCore/CookieJar.h> … … 100 99 if (m_sessionID.isEphemeral()) 101 100 return; 102 103 m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory );101 102 m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory, m_shouldIncludeLocalhostInResourceLoadStatistics); 104 103 } 105 104 -
trunk/Source/WebKit/NetworkProcess/NetworkSession.h
r242598 r242712 26 26 #pragma once 27 27 28 #include "WebResourceLoadStatisticsStore.h" 28 29 #include <WebCore/RegistrableDomain.h> 29 30 #include <pal/SessionID.h> … … 92 93 #if ENABLE(RESOURCE_LOAD_STATISTICS) 93 94 RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics; 95 ShouldIncludeLocalhost m_shouldIncludeLocalhostInResourceLoadStatistics { ShouldIncludeLocalhost::Yes }; 94 96 #endif 95 97 UniqueRef<NetworkAdClickAttribution> m_adClickAttribution; -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp
r240858 r242712 80 80 encoder << resourceLoadStatisticsDirectoryExtensionHandle; 81 81 encoder << enableResourceLoadStatistics; 82 encoder << shouldIncludeLocalhostInResourceLoadStatistics; 82 83 } 83 84 … … 171 172 decoder >> enableResourceLoadStatistics; 172 173 if (!enableResourceLoadStatistics) 174 return WTF::nullopt; 175 176 Optional<bool> shouldIncludeLocalhostInResourceLoadStatistics; 177 decoder >> shouldIncludeLocalhostInResourceLoadStatistics; 178 if (!shouldIncludeLocalhostInResourceLoadStatistics) 173 179 return WTF::nullopt; 174 180 … … 197 203 , WTFMove(*resourceLoadStatisticsDirectoryExtensionHandle) 198 204 , WTFMove(*enableResourceLoadStatistics) 205 , WTFMove(*shouldIncludeLocalhostInResourceLoadStatistics) 199 206 }}; 200 207 } -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h
r240858 r242712 82 82 SandboxExtension::Handle resourceLoadStatisticsDirectoryExtensionHandle; 83 83 bool enableResourceLoadStatistics { false }; 84 bool shouldIncludeLocalhostInResourceLoadStatistics { true }; 84 85 }; 85 86 -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r242367 r242712 949 949 #if ENABLE(RESOURCE_LOAD_STATISTICS) 950 950 m_resourceLoadStatisticsDirectory = parameters.resourceLoadStatisticsDirectory; 951 m_shouldIncludeLocalhostInResourceLoadStatistics = parameters.shouldIncludeLocalhostInResourceLoadStatistics ? ShouldIncludeLocalhost::Yes : ShouldIncludeLocalhost::No; 951 952 setResourceLoadStatisticsEnabled(parameters.enableResourceLoadStatistics); 952 953 #endif -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r242598 r242712 337 337 } 338 338 339 void WKWebsiteDataStoreSetStatisticsIsRunningTest(WKWebsiteDataStoreRef dataStoreRef, bool value, void* context, WKWebsiteDataStoreSetStatisticsIsRunningTestFunction callback) 340 { 341 #if ENABLE(RESOURCE_LOAD_STATISTICS) 342 WebKit::toImpl(dataStoreRef)->websiteDataStore().setIsRunningResourceLoadStatisticsTest(value, [context, callback] { 343 callback(context); 344 }); 345 #else 346 callback(context); 347 #endif 348 } 349 339 350 void WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, bool value) 340 351 { -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r242598 r242712 80 80 WK_EXPORT void WKWebsiteDataStoreStatisticsSubmitTelemetry(WKWebsiteDataStoreRef dataStoreRef); 81 81 WK_EXPORT void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned(WKWebsiteDataStoreRef dataStoreRef, bool value); 82 typedef void (*WKWebsiteDataStoreSetStatisticsIsRunningTestFunction)(void* functionContext); 83 WK_EXPORT void WKWebsiteDataStoreSetStatisticsIsRunningTest(WKWebsiteDataStoreRef dataStoreRef, bool value, void* context, WKWebsiteDataStoreSetStatisticsIsRunningTestFunction callback); 82 84 WK_EXPORT void WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, bool value); 83 85 WK_EXPORT void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(WKWebsiteDataStoreRef dataStoreRef, bool value); -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r242603 r242712 595 595 } 596 596 597 void NetworkProcessProxy::setIsRunningResourceLoadStatisticsTest(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) 598 { 599 if (!canSendMessage()) { 600 completionHandler(); 601 return; 602 } 603 604 sendWithAsyncReply(Messages::NetworkProcess::SetIsRunningResourceLoadStatisticsTest(sessionID, value), WTFMove(completionHandler)); 605 } 606 597 607 void NetworkProcessProxy::setSubframeUnderTopFrameDomain(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void()>&& completionHandler) 598 608 { -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r242603 r242712 114 114 void setGrandfathered(PAL::SessionID, const RegistrableDomain&, bool isGrandfathered, CompletionHandler<void()>&&); 115 115 void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool, CompletionHandler<void()>&&); 116 void setIsRunningResourceLoadStatisticsTest(PAL::SessionID, bool, CompletionHandler<void()>&&); 116 117 void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool, CompletionHandler<void()>&&); 117 118 void setSubframeUnderTopFrameDomain(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void()>&&); -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r242603 r242712 575 575 576 576 bool enableResourceLoadStatistics = false; 577 if (withWebsiteDataStore) 577 bool shouldIncludeLocalhost = true; 578 if (withWebsiteDataStore) { 578 579 enableResourceLoadStatistics = withWebsiteDataStore->resourceLoadStatisticsEnabled(); 579 else if (m_websiteDataStore) 580 shouldIncludeLocalhost = withWebsiteDataStore->parameters().networkSessionParameters.shouldIncludeLocalhostInResourceLoadStatistics; 581 } else if (m_websiteDataStore) { 580 582 enableResourceLoadStatistics = m_websiteDataStore->resourceLoadStatisticsEnabled(); 583 shouldIncludeLocalhost = m_websiteDataStore->websiteDataStore().parameters().networkSessionParameters.shouldIncludeLocalhostInResourceLoadStatistics; 584 } 581 585 582 586 parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = enableResourceLoadStatistics; 587 parameters.defaultDataStoreParameters.networkSessionParameters.shouldIncludeLocalhostInResourceLoadStatistics = shouldIncludeLocalhost; 583 588 584 589 // Add any platform specific parameters -
trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r242302 r242712 103 103 WTFMove(resourceLoadStatisticsDirectory), 104 104 WTFMove(resourceLoadStatisticsDirectoryHandle), 105 false 105 false, 106 isSafari 106 107 }; 107 108 finalizeApplicationIdentifiers(); -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r242598 r242712 1609 1609 } 1610 1610 1611 void WebsiteDataStore::setIsRunningResourceLoadStatisticsTest(bool value, CompletionHandler<void()>&& completionHandler) 1612 { 1613 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1614 1615 for (auto& processPool : processPools()) 1616 processPool->ensureNetworkProcess().setIsRunningResourceLoadStatisticsTest(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1617 } 1618 1611 1619 void WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured(bool value, CompletionHandler<void()>&& completionHandler) 1612 1620 { -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r242598 r242712 148 148 void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&); 149 149 void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&); 150 void setIsRunningResourceLoadStatisticsTest(bool, CompletionHandler<void()>&&); 150 151 void setPruneEntriesDownTo(size_t, CompletionHandler<void()>&&); 151 152 void setSubframeUnderTopFrameDomain(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&&); -
trunk/Tools/ChangeLog
r242711 r242712 1 2019-03-11 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Make it possible exclude localhost from classification 4 https://bugs.webkit.org/show_bug.cgi?id=195474 5 <rdar://problem/47520577> 6 7 Reviewed by Brent Fulgham. 8 9 This patch allows for localhost to be excluded from classification and 10 treatment as a prevalent resource. 11 12 The WebKit Tools change adds a new function called 13 testRunner.setStatisticsIsRunningTest() which can be used to control this 14 behavior. 15 16 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 17 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 18 (WTR::TestRunner::setStatisticsIsRunningTest): 19 * WebKitTestRunner/InjectedBundle/TestRunner.h: 20 * WebKitTestRunner/TestController.cpp: 21 (WTR::TestController::setStatisticsIsRunningTest): 22 * WebKitTestRunner/TestController.h: 23 * WebKitTestRunner/TestInvocation.cpp: 24 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 25 1 26 2019-03-11 Aakash Jain <aakash_jain@apple.com> 2 27 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r242664 r242712 310 310 void statisticsSubmitTelemetry(); 311 311 void setStatisticsNotifyPagesWhenDataRecordsWereScanned(boolean value); 312 void setStatisticsIsRunningTest(boolean value); 312 313 void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(boolean value); 313 314 void setStatisticsNotifyPagesWhenTelemetryWasCaptured(boolean value); -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r242664 r242712 1948 1948 } 1949 1949 1950 void TestRunner::setStatisticsIsRunningTest(bool value) 1951 { 1952 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("StatisticsSetIsRunningTest")); 1953 WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value)); 1954 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1955 } 1956 1950 1957 void TestRunner::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool value) 1951 1958 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r242664 r242712 419 419 void setStatisticsTimeToLiveUserInteraction(double seconds); 420 420 void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool); 421 void setStatisticsIsRunningTest(bool); 421 422 void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool); 422 423 void setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value); -
trunk/Tools/WebKitTestRunner/TestController.cpp
r242664 r242712 3289 3289 } 3290 3290 3291 void TestController::setStatisticsIsRunningTest(bool value) 3292 { 3293 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 3294 ResourceStatisticsCallbackContext context(*this); 3295 WKWebsiteDataStoreSetStatisticsIsRunningTest(dataStore, value, &context, resourceStatisticsVoidResultCallback); 3296 runUntil(context.done, noTimeout); 3297 } 3298 3291 3299 void TestController::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool value) 3292 3300 { -
trunk/Tools/WebKitTestRunner/TestController.h
r242664 r242712 231 231 void statisticsSubmitTelemetry(); 232 232 void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool); 233 void setStatisticsIsRunningTest(bool); 233 234 void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool); 234 235 void setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value); -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r242664 r242712 1334 1334 } 1335 1335 1336 if (WKStringIsEqualToUTF8CString(messageName, "StatisticsSetIsRunningTest")) { 1337 ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID()); 1338 WKBooleanRef value = static_cast<WKBooleanRef>(messageBody); 1339 TestController::singleton().setStatisticsIsRunningTest(WKBooleanGetValue(value)); 1340 return nullptr; 1341 } 1342 1336 1343 if (WKStringIsEqualToUTF8CString(messageName, "StatisticsNotifyPagesWhenTelemetryWasCaptured")) { 1337 1344 ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
Note:
See TracChangeset
for help on using the changeset viewer.