Resource Load Statistics: Add alternate classification method
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2017 09:19:53 +0000 (09:19 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Feb 2017 09:19:53 +0000 (09:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168347
<rdar://problem/30352793>
<rdar://problem/30646710>
<rdar://problem/30660708>

Reviewed by Alex Christensen.

Source/WebCore:

This patch only adds test infrastructure in WebCore.

Tests: http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html
       http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html
       http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html
       http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html
       http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html
       http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html
       http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
       http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::setSubframeUnderTopFrameOrigin):
(WebCore::ResourceLoadObserver::setSubresourceUnderTopFrameOrigin):
(WebCore::ResourceLoadObserver::setSubresourceUniqueRedirectTo):
* loader/ResourceLoadObserver.h:

Source/WebKit2:

This patch adds a CorePrediction-based classifier to the WebResourceLoadStatisticsStore.
The CorePrediction framework is introduced as a dependency for macOS and iOS. The patch
also adds functions to support layout tests of the feature.

* Platform/Logging.h:
    Added channel ResourceLoadStatistics.
* Platform/classifier/ResourceLoadStatisticsClassifier.h: Added.
    Pulls in the Cocoa-specific classifier for Cocoa-based platforms.
(WebKit::ResourceLoadStatisticsClassifier::ResourceLoadStatisticsClassifier):
* Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp: Added.
(WebKit::ResourceLoadStatisticsClassifierBase::hasPrevalentResourceCharacteristics):
    Shared classifier logic.
(WebKit::ResourceLoadStatisticsClassifierBase::classifyWithVectorThreshold):
    Fallback classifier for when we don't have CorePrediction.
* Platform/classifier/ResourceLoadStatisticsClassifierBase.h: Added.
(WebKit::ResourceLoadStatisticsClassifierBase::ResourceLoadStatisticsClassifierBase):
(WebKit::ResourceLoadStatisticsClassifierBase::~ResourceLoadStatisticsClassifierBase):
* Platform/classifier/cocoa/CorePredictionSoftLink.h: Added.
    Soft links to CorePrediction and the two functions we use from it.
* Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp: Added.
(WebKit::ResourceLoadStatisticsClassifier::classify):
(WebKit::ResourceLoadStatisticsClassifier::storagePath):
(WebKit::ResourceLoadStatisticsClassifier::shouldUseCorePredictionAndHaveModelLoaded):
(WebKit::ResourceLoadStatisticsClassifier::singletonPredictionModel):
    The new classifier for Cocoa platforms.
* Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h: Added.
* PlatformGTK.cmake:
    Added Platform/classifier directory and ResourceLoadStatisticsClassifierBase.cpp.
* PlatformMac.cmake:
    Added Platform/classifier and Platform/classifier/cocoa directories, and
    source files ResourceLoadStatisticsClassifierBase.cpp and
    ResourceLoadStatisticsClassifierCocoa.cpp
* Resources/ResourceLoadStatistics/corePrediction_model: Added.
    Model file to load into CorePrediction.
* UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
(WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin):
(WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin):
(WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo):
    Test infrastructure.
* UIProcess/API/C/WKResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsManager.cpp:
(WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
(WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
(WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
    Test infrastructure.
* UIProcess/WebResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
    Renamed m_storagePath to m_statisticsStoragePath for clarity.
(WebKit::WebResourceLoadStatisticsStore::classifyResource):
    Now calls the classifier through its ResourceLoadStatisticsClassifier
    member variable.
(WebKit::WebResourceLoadStatisticsStore::persistentStoragePath):
    Renamed m_storagePath to m_statisticsStoragePath for clarity.
(WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
    Renamed m_storagePath to m_statisticsStoragePath for clarity.
(WebKit::WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics): Deleted.
* UIProcess/WebResourceLoadStatisticsStore.h:
* WebKit2.xcodeproj/project.pbxproj:
    Added the new classifier source files under Platform/classifier and the
    corePrediction_model file under Resources/ResourceLoadStatistics.

Tools:

Added three testRunner functions to facilitate layout tests:
- setStatisticsSubframeUnderTopFrameOrigin()
- setStatisticsSubresourceUnderTopFrameOrigin()
- setStatisticsSubresourceUniqueRedirectTo()

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setStatisticsSubframeUnderTopFrameOrigin):
(WTR::TestRunner::setStatisticsSubresourceUnderTopFrameOrigin):
(WTR::TestRunner::setStatisticsSubresourceUniqueRedirectTo):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin):
(WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin):
(WTR::TestController::setStatisticsSubresourceUniqueRedirectTo):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
* http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html: Added.
* http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html:
    Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
* http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html:
    Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
* http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html:
    Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
* http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html:
    Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
* http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html:
    Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
* platform/gtk/TestExpectations:
    The whole http/tests/loading/resourceLoadStatistics marked as crashing based on
    Carlos Garcia Campos's assessment in https://bugs.webkit.org/show_bug.cgi?id=168171.
* platform/wk2/TestExpectations:
    The above tests are only valid for WebKit2. Marked as [ Pass ].

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212949 268f45cc-cd09-0410-ab3c-d52691b4dbfc

51 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html [new file with mode: 0644]
LayoutTests/http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html
LayoutTests/http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html
LayoutTests/http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html
LayoutTests/http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html
LayoutTests/http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadObserver.cpp
Source/WebCore/loader/ResourceLoadObserver.h
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/Logging.h
Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.cpp [new file with mode: 0644]
Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.h [new file with mode: 0644]
Source/WebKit2/Platform/classifier/cocoa/CorePredictionSoftLink.h [new file with mode: 0644]
Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp [new file with mode: 0644]
Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h [new file with mode: 0644]
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/PlatformMac.cmake
Source/WebKit2/Resources/ResourceLoadStatistics/corePrediction_model [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp

index 1cee1dd..08db2a3 100644 (file)
@@ -1,3 +1,45 @@
+2017-02-24  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+        <rdar://problem/30646710>
+        <rdar://problem/30660708>
+
+        Reviewed by Alex Christensen.
+
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt: Added.
+        * http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html: Added.
+        * http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html:
+            Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
+        * http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html:
+            Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
+        * http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html:
+            Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
+        * http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html:
+            Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
+        * http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html:
+            Added a call to internals.setResourceLoadStatisticsEnabled(false) before testRunner.notifyDone().
+        * platform/gtk/TestExpectations:
+            The whole http/tests/loading/resourceLoadStatistics marked as crashing based on
+            Carlos Garcia Campos's assessment in https://bugs.webkit.org/show_bug.cgi?id=168171.
+        * platform/wk2/TestExpectations:
+            The above tests are only valid for WebKit2. Marked as [ Pass ].
+
 2017-02-23  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] No controls are shown for <audio preload="none">
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics-expected.txt
new file mode 100644 (file)
index 0000000..1d28dd7
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Mixed Statistics
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host did not get classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html
new file mode 100644 (file)
index 0000000..f779fce
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Mixed Statistics</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt
new file mode 100644 (file)
index 0000000..ed0973a
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Sub Frame Under Top Frame Origins
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host did not get classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html
new file mode 100644 (file)
index 0000000..6360e7b
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Sub Frame Under Top Frame Origins</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins-expected.txt
new file mode 100644 (file)
index 0000000..60fa2af
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Subresource Under Top Frame Origins
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host did not get classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html
new file mode 100644 (file)
index 0000000..fd847fd
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Subresource Under Top Frame Origins</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to-expected.txt
new file mode 100644 (file)
index 0000000..9cf0948
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Subresource Unique Redirects To
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host did not get classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html
new file mode 100644 (file)
index 0000000..1aedc7e
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Subresource Unique Redirects To</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host classified as prevalent resource.");
+        else
+            testPassed("Host did not get classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics-expected.txt
new file mode 100644 (file)
index 0000000..a294285
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Mixed Statistics
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html
new file mode 100644 (file)
index 0000000..2910e0b
--- /dev/null
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Mixed Statistics</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins-expected.txt
new file mode 100644 (file)
index 0000000..8c97c93
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Sub Frame Under Top Frame Origins
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html
new file mode 100644 (file)
index 0000000..aa455da
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Sub Frame Under Top Frame Origins</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubframeUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins-expected.txt
new file mode 100644 (file)
index 0000000..11d43bf
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Subresource Under Top Frame Origins
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
new file mode 100644 (file)
index 0000000..0d573d9
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Subresource Under Top Frame Origins</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubresourceUnderTopFrameOrigin(statisticsUrl, topFrameOrigin4);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to-expected.txt
new file mode 100644 (file)
index 0000000..f3a11ce
--- /dev/null
@@ -0,0 +1,8 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didReceiveTitle: Tests for Classification Based on Subresource Unique Redirects To
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS Host classified as prevalent resource.
+
diff --git a/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html b/LayoutTests/http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html
new file mode 100644 (file)
index 0000000..a00aa5c
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Tests for Classification Based on Subresource Unique Redirects To</title>
+    <script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+    const hostUnderTest = "127.0.0.1:8000";
+    const statisticsUrl = "http://" + hostUnderTest + "/temp";
+    const topFrameOrigin1 = "http://127.0.0.2:8000/temp";
+    const topFrameOrigin2 = "http://127.0.0.3:8000/temp";
+    const topFrameOrigin3 = "http://127.0.0.4:8000/temp";
+    const topFrameOrigin4 = "http://127.0.0.5:8000/temp";
+    function runTestRunnerTest() {
+        testRunner.setStatisticsPrevalentResource(statisticsUrl, false);
+        if (testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get set as non-prevalent resource.");
+
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin1);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin2);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin3);
+        testRunner.setStatisticsSubresourceUniqueRedirectTo(statisticsUrl, topFrameOrigin4);
+
+        testRunner.statisticsFireDataModificationHandler();
+
+        if (!testRunner.isStatisticsPrevalentResource(statisticsUrl))
+            testFailed("Host did not get classified as prevalent resource.");
+        else
+            testPassed("Host classified as prevalent resource.");
+
+        testRunner.statisticsResetToConsistentState();
+        internals.setResourceLoadStatisticsEnabled(false);
+        testRunner.notifyDone();
+    }
+
+    if (document.location.host === hostUnderTest && window.testRunner && window.internals) {
+        testRunner.waitUntilDone();
+        internals.setResourceLoadStatisticsEnabled(true);
+        runTestRunnerTest();
+    }
+</script>
+</body>
+</html>
index bdc9ed6..c134f00 100644 (file)
@@ -38,6 +38,7 @@
             else
                 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
             testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(false);
             testRunner.notifyDone();
         });
         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
index 955244f..724dfd8 100644 (file)
@@ -38,6 +38,7 @@
             else
                 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
             testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(false);
             testRunner.notifyDone();
         });
         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
index 2dda79d..e10ef52 100644 (file)
@@ -31,6 +31,7 @@
             else
                 testPassed("Cookie deleted.");
             testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(false);
             testRunner.notifyDone();
         });
         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
index a65151c..d1a64fc 100644 (file)
@@ -38,6 +38,7 @@
             else
                 testFailed("Cookie deleted or document.cookie contains other cookies: " + document.cookie);
             testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(false);
             testRunner.notifyDone();
         });
         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
index 7cef910..08403ed 100644 (file)
@@ -31,6 +31,7 @@
             else
                 testPassed("Cookie deleted.");
             testRunner.statisticsResetToConsistentState();
+            internals.setResourceLoadStatisticsEnabled(false);
             testRunner.notifyDone();
         });
         testRunner.setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(false);
index 5e190a3..92f9905 100644 (file)
@@ -949,11 +949,7 @@ webkit.org/b/131546 media/track/track-in-band.html [ Crash Timeout Failure ]
 
 webkit.org/b/163782 media/video-played-ranges-1.html [ Crash Pass ]
 
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-with-user-interaction.html [ Crash ]
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html [ Crash ]
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html [ Crash ]
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction.html [ Crash ]
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html [ Crash ]
+webkit.org/b/168171 http/tests/loading/resourceLoadStatistics [ Crash ]
 
 webkit.org/b/167576 imported/w3c/IndexedDB-private-browsing/idbcursor_iterating.html [ Crash ]
 webkit.org/b/167576 imported/w3c/IndexedDB-private-browsing/idbcursor_iterating_index.html [ Crash ]
index 758b220..81c8def 100644 (file)
@@ -705,6 +705,14 @@ http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interacti
 http/tests/loading/resourceLoadStatistics/non-prevalent-resource-without-user-interaction.html [ Pass Timeout ]
 http/tests/loading/resourceLoadStatistics/prevalent-resource-without-user-interaction.html [ Pass Timeout ]
 http/tests/loading/resourceLoadStatistics/prevalent-resource-with-user-interaction-timeout.html [ Pass Timeout ]
+http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ]
 
 ### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
 ########################################
index 5250a74..77d0000 100644 (file)
@@ -1,3 +1,30 @@
+2017-02-24  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+        <rdar://problem/30646710>
+        <rdar://problem/30660708>
+
+        Reviewed by Alex Christensen.
+
+        This patch only adds test infrastructure in WebCore.
+
+        Tests: http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-mixed-statistics.html
+               http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-sub-frame-under-top-frame-origins.html
+               http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-under-top-frame-origins.html
+               http/tests/loading/resourceLoadStatistics/classify-as-non-prevalent-based-on-subresource-unique-redirects-to.html
+               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-mixed-statistics.html
+               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-sub-frame-under-top-frame-origins.html
+               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html
+               http/tests/loading/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html
+
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::ResourceLoadObserver::setSubframeUnderTopFrameOrigin):
+        (WebCore::ResourceLoadObserver::setSubresourceUnderTopFrameOrigin):
+        (WebCore::ResourceLoadObserver::setSubresourceUniqueRedirectTo):
+        * loader/ResourceLoadObserver.h:
+
 2017-02-23  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] No controls are shown for <audio preload="none">
index 8d3da3b..1026dae 100644 (file)
@@ -375,6 +375,33 @@ void ResourceLoadObserver::clearPrevalentResource(const URL& url)
     statistics.isPrevalentResource = false;
 }
 
+void ResourceLoadObserver::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame)
+{
+    if (subframe.isBlankURL() || subframe.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
+        return;
+    
+    auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subframe));
+    statistics.subframeUnderTopFrameOrigins.add(primaryDomain(topFrame));
+}
+
+void ResourceLoadObserver::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame)
+{
+    if (subresource.isBlankURL() || subresource.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
+        return;
+    
+    auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subresource));
+    statistics.subresourceUnderTopFrameOrigins.add(primaryDomain(topFrame));
+}
+
+void ResourceLoadObserver::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo)
+{
+    if (subresource.isBlankURL() || subresource.isEmpty() || hostNameRedirectedTo.isBlankURL() || hostNameRedirectedTo.isEmpty())
+        return;
+    
+    auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomain(subresource));
+    statistics.subresourceUniqueRedirectsTo.add(primaryDomain(hostNameRedirectedTo));
+}
+
 void ResourceLoadObserver::setTimeToLiveUserInteraction(double seconds)
 {
     m_store->setTimeToLiveUserInteraction(seconds);
index c8cce7b..78449a7 100644 (file)
@@ -58,6 +58,10 @@ public:
     WEBCORE_EXPORT bool isPrevalentResource(const URL&);
     WEBCORE_EXPORT void clearPrevalentResource(const URL&);
 
+    WEBCORE_EXPORT void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame);
+    WEBCORE_EXPORT void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame);
+    WEBCORE_EXPORT void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo);
+
     WEBCORE_EXPORT void setTimeToLiveUserInteraction(double seconds);
     WEBCORE_EXPORT void setReducedTimestampResolution(double seconds);
 
index dcb8b46..2b80500 100644 (file)
@@ -1,3 +1,75 @@
+2017-02-24  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+        <rdar://problem/30646710>
+        <rdar://problem/30660708>
+
+        Reviewed by Alex Christensen.
+
+        This patch adds a CorePrediction-based classifier to the WebResourceLoadStatisticsStore.
+        The CorePrediction framework is introduced as a dependency for macOS and iOS. The patch
+        also adds functions to support layout tests of the feature.
+
+        * Platform/Logging.h:
+            Added channel ResourceLoadStatistics.
+        * Platform/classifier/ResourceLoadStatisticsClassifier.h: Added.
+            Pulls in the Cocoa-specific classifier for Cocoa-based platforms.
+        (WebKit::ResourceLoadStatisticsClassifier::ResourceLoadStatisticsClassifier):
+        * Platform/classifier/ResourceLoadStatisticsClassifierBase.cpp: Added.
+        (WebKit::ResourceLoadStatisticsClassifierBase::hasPrevalentResourceCharacteristics):
+            Shared classifier logic.
+        (WebKit::ResourceLoadStatisticsClassifierBase::classifyWithVectorThreshold):
+            Fallback classifier for when we don't have CorePrediction.
+        * Platform/classifier/ResourceLoadStatisticsClassifierBase.h: Added.
+        (WebKit::ResourceLoadStatisticsClassifierBase::ResourceLoadStatisticsClassifierBase):
+        (WebKit::ResourceLoadStatisticsClassifierBase::~ResourceLoadStatisticsClassifierBase):
+        * Platform/classifier/cocoa/CorePredictionSoftLink.h: Added.
+            Soft links to CorePrediction and the two functions we use from it.
+        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp: Added.
+        (WebKit::ResourceLoadStatisticsClassifier::classify):
+        (WebKit::ResourceLoadStatisticsClassifier::storagePath):
+        (WebKit::ResourceLoadStatisticsClassifier::shouldUseCorePredictionAndHaveModelLoaded):
+        (WebKit::ResourceLoadStatisticsClassifier::singletonPredictionModel):
+            The new classifier for Cocoa platforms.
+        * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h: Added.
+        * PlatformGTK.cmake:
+            Added Platform/classifier directory and ResourceLoadStatisticsClassifierBase.cpp.
+        * PlatformMac.cmake:
+            Added Platform/classifier and Platform/classifier/cocoa directories, and
+            source files ResourceLoadStatisticsClassifierBase.cpp and
+            ResourceLoadStatisticsClassifierCocoa.cpp
+        * Resources/ResourceLoadStatistics/corePrediction_model: Added.
+            Model file to load into CorePrediction.
+        * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
+        (WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin):
+        (WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin):
+        (WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo):
+            Test infrastructure.
+        * UIProcess/API/C/WKResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsManager.cpp:
+        (WebKit::WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin):
+        (WebKit::WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin):
+        (WebKit::WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo):
+            Test infrastructure.
+        * UIProcess/WebResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
+            Renamed m_storagePath to m_statisticsStoragePath for clarity.
+        (WebKit::WebResourceLoadStatisticsStore::classifyResource):
+            Now calls the classifier through its ResourceLoadStatisticsClassifier
+            member variable.
+        (WebKit::WebResourceLoadStatisticsStore::persistentStoragePath):
+            Renamed m_storagePath to m_statisticsStoragePath for clarity.
+        (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
+            Renamed m_storagePath to m_statisticsStoragePath for clarity.
+        (WebKit::WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics): Deleted.
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+        * WebKit2.xcodeproj/project.pbxproj:
+            Added the new classifier source files under Platform/classifier and the
+            corePrediction_model file under Resources/ResourceLoadStatistics.
+
 2017-02-23  Joseph Pecoraro  <pecoraro@apple.com>
 
         [Resource Timing] Add Experimental Feature Flag
index 3d1e172..76ee680 100644 (file)
@@ -63,6 +63,7 @@ extern "C" {
     M(ProcessSuspension) \
     M(RemoteLayerTree) \
     M(Resize) \
+    M(ResourceLoadStatistics) \
     M(Selection) \
     M(SessionState) \
     M(StorageAPI) \
diff --git a/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.cpp b/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.cpp
new file mode 100644 (file)
index 0000000..bce7ca7
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ResourceLoadStatisticsClassifier.h"
+
+#include "Logging.h"
+#include <WebCore/ResourceLoadStatistics.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const auto featureVectorLengthThreshold = 3;
+bool ResourceLoadStatisticsClassifier::hasPrevalentResourceCharacteristics(const ResourceLoadStatistics& resourceStatistic)
+{
+    auto subresourceUnderTopFrameOriginsCount = resourceStatistic.subresourceUnderTopFrameOrigins.size();
+    auto subresourceUniqueRedirectsToCount = resourceStatistic.subresourceUniqueRedirectsTo.size();
+    auto subframeUnderTopFrameOriginsCount = resourceStatistic.subframeUnderTopFrameOrigins.size();
+    
+    if (!subresourceUnderTopFrameOriginsCount
+        && !subresourceUniqueRedirectsToCount
+        && !subframeUnderTopFrameOriginsCount)
+        return false;
+    
+    if (subresourceUnderTopFrameOriginsCount > featureVectorLengthThreshold
+        || subresourceUniqueRedirectsToCount > featureVectorLengthThreshold
+        || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold)
+        return true;
+
+    return classify(subresourceUnderTopFrameOriginsCount, subresourceUniqueRedirectsToCount, subframeUnderTopFrameOriginsCount);
+}
+
+bool ResourceLoadStatisticsClassifier::classifyWithVectorThreshold(unsigned a, unsigned b, unsigned c)
+{
+    LOG(ResourceLoadStatistics, "ResourceLoadStatisticsClassifier::classifyWithVectorThreshold(): Classified with threshold.");
+    return sqrt(a * a + b * b + c * c) > featureVectorLengthThreshold;
+}
+    
+}
diff --git a/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.h b/Source/WebKit2/Platform/classifier/ResourceLoadStatisticsClassifier.h
new file mode 100644 (file)
index 0000000..9b42d21
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+struct ResourceLoadStatistics;
+}
+
+namespace WebKit {
+
+class ResourceLoadStatisticsClassifier {
+public:
+    ResourceLoadStatisticsClassifier() = default;
+    virtual ~ResourceLoadStatisticsClassifier() = default;
+    bool hasPrevalentResourceCharacteristics(const WebCore::ResourceLoadStatistics& resourceStatistic);
+protected:
+    virtual bool classify(unsigned subresourceUnderTopFrameOriginsCount, unsigned subresourceUniqueRedirectsToCount, unsigned subframeUnderTopFrameOriginsCount)
+    {
+        return classifyWithVectorThreshold(subresourceUnderTopFrameOriginsCount, subresourceUniqueRedirectsToCount, subframeUnderTopFrameOriginsCount);
+    }
+    bool classifyWithVectorThreshold(unsigned, unsigned, unsigned);
+};
+
+}
diff --git a/Source/WebKit2/Platform/classifier/cocoa/CorePredictionSoftLink.h b/Source/WebKit2/Platform/classifier/cocoa/CorePredictionSoftLink.h
new file mode 100644 (file)
index 0000000..81ccc1a
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <WebCore/SoftLinking.h>
+
+struct svm_model;
+struct svm_node {
+    int index;
+    double value;
+};
+
+SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(CorePrediction)
+SOFT_LINK(CorePrediction, svm_predict_values, double, (const struct svm_model *model, const struct svm_node *x, double* dec_values), (model, x, dec_values))
+SOFT_LINK(CorePrediction, svm_load_model, svm_model*, (const char *model_file_name), (model_file_name))
diff --git a/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp b/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp
new file mode 100644 (file)
index 0000000..4f7c128
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ResourceLoadStatisticsClassifierCocoa.h"
+
+#include "Logging.h"
+#include <wtf/NeverDestroyed.h>
+#include "CorePredictionSoftLink.h"
+
+namespace WebKit {
+
+bool ResourceLoadStatisticsClassifierCocoa::classify(unsigned subresourceUnderTopFrameOriginsCount, unsigned subresourceUniqueRedirectsToCount, unsigned subframeUnderTopFrameOriginsCount)
+{
+    if (!canUseCorePrediction())
+        return classifyWithVectorThreshold(subresourceUnderTopFrameOriginsCount, subresourceUniqueRedirectsToCount, subframeUnderTopFrameOriginsCount);
+
+    Vector<svm_node> features;
+
+    if (subresourceUnderTopFrameOriginsCount)
+        features.append({1, static_cast<double>(subresourceUnderTopFrameOriginsCount)});
+    if (subresourceUniqueRedirectsToCount)
+        features.append({2, static_cast<double>(subresourceUniqueRedirectsToCount)});
+    if (subframeUnderTopFrameOriginsCount)
+        features.append({3, static_cast<double>(subframeUnderTopFrameOriginsCount)});
+
+    // Add termination node with index -1.
+    features.append({-1, -1});
+
+    double score;
+    int classification = svm_predict_values(singletonPredictionModel(), features.data(), &score);
+    LOG(ResourceLoadStatistics, "ResourceLoadStatisticsClassifierCocoa::classify(): Classified with CorePrediction.");
+    return classification < 0;
+}
+
+String ResourceLoadStatisticsClassifierCocoa::storagePath()
+{
+    CFBundleRef webKitBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"));
+    RetainPtr<CFURLRef> resourceUrl = adoptCF(CFBundleCopyResourcesDirectoryURL(webKitBundle));
+    resourceUrl = adoptCF(CFURLCreateCopyAppendingPathComponent(nullptr, resourceUrl.get(), CFSTR("corePrediction_model"), false));
+    CFErrorRef error = nullptr;
+    resourceUrl = adoptCF(CFURLCreateFilePathURL(nullptr, resourceUrl.get(), &error));
+
+    if (error || !resourceUrl)
+        return String();
+
+    RetainPtr<CFStringRef> resourceUrlString = adoptCF(CFURLCopyFileSystemPath(resourceUrl.get(), kCFURLPOSIXPathStyle));
+    return String(resourceUrlString.get());
+}
+
+bool ResourceLoadStatisticsClassifierCocoa::canUseCorePrediction()
+{
+    if (m_haveLoadedModel)
+        return true;
+
+    if (!m_useCorePrediction)
+        return false;
+
+    if (!CorePredictionLibrary()) {
+        m_useCorePrediction = false;
+        return false;
+    }
+
+    String storagePathStr = storagePath();
+    if (storagePathStr.isNull() || storagePathStr.isEmpty()) {
+        m_useCorePrediction = false;
+        return false;
+    }
+
+    if (singletonPredictionModel()) {
+        m_haveLoadedModel = true;
+        return true;
+    }
+
+    m_useCorePrediction = false;
+    return false;
+}
+
+const struct svm_model* ResourceLoadStatisticsClassifierCocoa::singletonPredictionModel()
+{
+    static NeverDestroyed<struct svm_model*> corePredictionModel = svm_load_model(storagePath().utf8().data());
+
+    if (corePredictionModel)
+        return corePredictionModel;
+
+    WTFLogAlways("ResourceLoadStatisticsClassifierCocoa::singletonPredictionModel(): Couldn't load model file at path %s.", storagePath().utf8().data());
+    m_useCorePrediction = false;
+    return nullptr;
+}
+}
diff --git a/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h b/Source/WebKit2/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.h
new file mode 100644 (file)
index 0000000..2571a06
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "ResourceLoadStatisticsClassifier.h"
+#include <wtf/Platform.h>
+#include <wtf/text/WTFString.h>
+
+struct svm_model;
+
+namespace WebKit {
+
+class ResourceLoadStatisticsClassifierCocoa : public ResourceLoadStatisticsClassifier {
+private:
+    bool classify(unsigned, unsigned, unsigned) override;
+    String storagePath();
+    bool canUseCorePrediction();
+    const struct svm_model* singletonPredictionModel();
+    bool m_useCorePrediction { true };
+    bool m_haveLoadedModel { false };
+};
+    
+}
index 88d5eae..e1f8a60 100644 (file)
@@ -46,6 +46,8 @@ list(APPEND WebKit2_SOURCES
     Platform/IPC/unix/AttachmentUnix.cpp
     Platform/IPC/unix/ConnectionUnix.cpp
 
+    Platform/classifier/ResourceLoadStatisticsClassifier.cpp
+
     Platform/glib/ModuleGlib.cpp
 
     Platform/unix/LoggingUnix.cpp
@@ -865,6 +867,7 @@ list(APPEND WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/NetworkProcess/soup"
     "${WEBKIT2_DIR}/NetworkProcess/unix"
     "${WEBKIT2_DIR}/Platform/IPC/glib"
+    "${WEBKIT2_DIR}/Platform/classifier"
     "${WEBKIT2_DIR}/Shared/API/c/gtk"
     "${WEBKIT2_DIR}/Shared/CoordinatedGraphics"
     "${WEBKIT2_DIR}/Shared/CoordinatedGraphics/threadedcompositor"
index f0bdeba..ea4f484 100644 (file)
@@ -49,6 +49,10 @@ list(APPEND WebKit2_SOURCES
 
     Platform/cg/CGUtilities.cpp
 
+    Platform/classifier/ResourceLoadStatisticsClassifier.cpp
+
+    Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp
+
     Platform/foundation/LoggingFoundation.mm
 
     Platform/cocoa/SharedMemoryCocoa.cpp
@@ -391,6 +395,8 @@ list(APPEND WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/UIProcess/Scrolling"
     "${WEBKIT2_DIR}/UIProcess/ios"
     "${WEBKIT2_DIR}/Platform/cg"
+    "${WEBKIT2_DIR}/Platform/classifier"
+    "${WEBKIT2_DIR}/Platform/classifier/cocoa"
     "${WEBKIT2_DIR}/Platform/mac"
     "${WEBKIT2_DIR}/Platform/unix"
     "${WEBKIT2_DIR}/Platform/spi/Cocoa"
diff --git a/Source/WebKit2/Resources/ResourceLoadStatistics/corePrediction_model b/Source/WebKit2/Resources/ResourceLoadStatistics/corePrediction_model
new file mode 100644 (file)
index 0000000..9ace838
--- /dev/null
@@ -0,0 +1,678 @@
+svm_type c_svc
+kernel_type rbf
+gamma 0.1
+nr_class 2
+total_sv 330
+rho 0.287945642261
+label -1 1
+nr_sv 300 30
+SV
+-0.0546697038724 1:14.0 2:3.0 3:7.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:12.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:3.0 2:16.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 2:1.0 
+-0.0546697038724 1:5.0 
+-0.0546697038724 1:16.0 2:2.0 3:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:11.0 
+-0.0546697038724 1:4.0 3:3.0 
+-0.0546697038724 1:28.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:22.0 2:1.0 3:12.0 
+-0.0546697038724 1:14.0 3:5.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:48.0 2:1.0 
+-0.0546697038724 1:25.0 3:16.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:3.0 3:2.0 
+-0.0546697038724 1:7.0 2:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:5.0 2:2.0 3:3.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:9.0 3:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:47.0 2:21.0 3:33.0 
+-0.0546697038724 1:11.0 2:2.0 3:5.0 
+-0.0546697038724 1:11.0 2:3.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:43.0 3:2.0 
+-0.0546697038724 1:13.0 3:7.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:13.0 3:4.0 
+-0.0546697038724 1:42.0 2:4.0 3:32.0 
+-0.0546697038724 1:10.0 2:5.0 3:1.0 
+-0.0546697038724 1:7.0 3:4.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:16.0 2:4.0 
+-0.0546697038724 1:10.0 2:1.0 3:2.0 
+-0.0546697038724 1:18.0 2:3.0 3:6.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:21.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 2:2.0 
+-0.0546697038724 1:14.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:4.0 3:3.0 
+-0.0546697038724 1:2.0 3:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:39.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 3:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 2:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:16.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:20.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:8.0 
+-0.0546697038724 1:7.0 2:1.0 3:2.0 
+-0.0546697038724 1:8.0 2:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:12.0 3:7.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:8.0 2:2.0 
+-0.0546697038724 1:17.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:13.0 2:4.0 3:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:16.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:11.0 3:11.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:15.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:20.0 2:12.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:7.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 3:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 2:3.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:7.0 2:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:14.0 
+-0.0546697038724 1:12.0 3:6.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:4.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:9.0 2:1.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 2:1.0 
+-0.0546697038724 1:3.0 2:3.0 
+-0.0546697038724 1:2.0 2:2.0 
+-0.0546697038724 1:1.0 2:1.0 3:1.0 
+-0.0546697038724 1:8.0 2:1.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:9.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:36.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:4.0 3:2.0 
+-0.0546697038724 1:13.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0402075178942 1:1.0 
+0.585365853659 1:1.0 
+0.479276139001 1:6.0 2:3.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 
+0.585365853659 1:3.0 3:3.0 
+0.585365853659 1:42.0 2:2.0 3:28.0 
+0.585365853659 1:2.0 
+0.585365853659 1:12.0 
+0.479283046578 1:7.0 
+0.300397873476 1:3.0 3:1.0 
+0.0543173306442 1:6.0 3:2.0 
+0.563465126299 1:11.0 
+0.585365853659 1:2.0 
+0.585365853659 1:10.0 2:3.0 3:6.0 
+0.585365853659 1:1.0 2:1.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 2:1.0 
+0.585365853659 1:3.0 3:1.0 
+0.585365853659 1:1.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 2:1.0 
+0.584989719909 1:7.0 
+0.585365853659 1:3.0 
+0.585365853659 1:3.0 
+0.525925136983 1:3.0 2:2.0 
+0.585365853659 1:1.0 
+0.585365853659 1:1.0 
+0.585365853659 1:3.0 3:1.0 
+0.585365853659 1:1.0 
+0.520745822374 1:3.0 
+svm_type c_svc
+kernel_type rbf
+gamma 0.1
+nr_class 2
+total_sv 330
+rho 0.287945642261
+label -1 1
+nr_sv 300 30
+SV
+-0.0546697038724 1:14.0 2:3.0 3:7.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:12.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:3.0 2:16.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 2:1.0 
+-0.0546697038724 1:5.0 
+-0.0546697038724 1:16.0 2:2.0 3:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:11.0 
+-0.0546697038724 1:4.0 3:3.0 
+-0.0546697038724 1:28.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:22.0 2:1.0 3:12.0 
+-0.0546697038724 1:14.0 3:5.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:48.0 2:1.0 
+-0.0546697038724 1:25.0 3:16.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:3.0 3:2.0 
+-0.0546697038724 1:7.0 2:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:5.0 2:2.0 3:3.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:9.0 3:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:47.0 2:21.0 3:33.0 
+-0.0546697038724 1:11.0 2:2.0 3:5.0 
+-0.0546697038724 1:11.0 2:3.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:43.0 3:2.0 
+-0.0546697038724 1:13.0 3:7.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:13.0 3:4.0 
+-0.0546697038724 1:42.0 2:4.0 3:32.0 
+-0.0546697038724 1:10.0 2:5.0 3:1.0 
+-0.0546697038724 1:7.0 3:4.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:16.0 2:4.0 
+-0.0546697038724 1:10.0 2:1.0 3:2.0 
+-0.0546697038724 1:18.0 2:3.0 3:6.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:21.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 2:2.0 
+-0.0546697038724 1:14.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:4.0 3:3.0 
+-0.0546697038724 1:2.0 3:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:39.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 3:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 2:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:16.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:20.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:8.0 
+-0.0546697038724 1:7.0 2:1.0 3:2.0 
+-0.0546697038724 1:8.0 2:2.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:12.0 3:7.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:7.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 2:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:8.0 2:2.0 
+-0.0546697038724 1:17.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:13.0 2:4.0 3:2.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 3:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:16.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:3.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:11.0 3:11.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:15.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:20.0 2:12.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:7.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:3.0 3:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 2:3.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:7.0 2:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:14.0 
+-0.0546697038724 1:12.0 3:6.0 
+-0.0546697038724 1:3.0 
+-0.0546697038724 1:4.0 2:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 
+-0.0546697038724 1:9.0 2:1.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:9.0 2:1.0 
+-0.0546697038724 1:3.0 2:3.0 
+-0.0546697038724 1:2.0 2:2.0 
+-0.0546697038724 1:1.0 2:1.0 3:1.0 
+-0.0546697038724 1:8.0 2:1.0 3:3.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 2:1.0 
+-0.0546697038724 1:9.0 2:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:36.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:6.0 
+-0.0546697038724 1:1.0 3:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:1.0 
+-0.0546697038724 1:2.0 
+-0.0546697038724 1:4.0 3:2.0 
+-0.0546697038724 1:13.0 3:4.0 
+-0.0546697038724 1:1.0 
+-0.0402075178942 1:1.0 
+0.585365853659 1:1.0 
+0.479276139001 1:6.0 2:3.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 
+0.585365853659 1:3.0 3:3.0 
+0.585365853659 1:42.0 2:2.0 3:28.0 
+0.585365853659 1:2.0 
+0.585365853659 1:12.0 
+0.479283046578 1:7.0 
+0.300397873476 1:3.0 3:1.0 
+0.0543173306442 1:6.0 3:2.0 
+0.563465126299 1:11.0 
+0.585365853659 1:2.0 
+0.585365853659 1:10.0 2:3.0 3:6.0 
+0.585365853659 1:1.0 2:1.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 2:1.0 
+0.585365853659 1:3.0 3:1.0 
+0.585365853659 1:1.0 
+0.585365853659 1:2.0 
+0.585365853659 1:1.0 2:1.0 
+0.584989719909 1:7.0 
+0.585365853659 1:3.0 
+0.585365853659 1:3.0 
+0.525925136983 1:3.0 2:2.0 
+0.585365853659 1:1.0 
+0.585365853659 1:1.0 
+0.585365853659 1:3.0 3:1.0 
+0.585365853659 1:1.0 
+0.520745822374 1:3.0 
index 879abeb..9edb84f 100644 (file)
@@ -56,6 +56,21 @@ bool WKResourceLoadStatisticsManagerIsHasHadUserInteraction(WKStringRef hostName
     return WebResourceLoadStatisticsManager::hasHadUserInteraction(toWTFString(hostName));
 }
 
+void WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
+{
+    WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName));
+}
+
+void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
+{
+    WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(toWTFString(hostName), toWTFString(topFrameHostName));
+}
+
+void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo)
+{
+    WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(toWTFString(hostName), toWTFString(hostNameRedirectedTo));
+}
+
 void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds)
 {
     WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(seconds);
index 2b83f5c..89a17b9 100644 (file)
@@ -38,6 +38,9 @@ extern "C" {
     WK_EXPORT bool WKResourceLoadStatisticsManagerIsPrevalentResource(WKStringRef hostName);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetHasHadUserInteraction(WKStringRef hostName, bool value);
     WK_EXPORT bool WKResourceLoadStatisticsManagerIsHasHadUserInteraction(WKStringRef hostName);
+    WK_EXPORT void WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
+    WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
+    WK_EXPORT void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds);
     WK_EXPORT void WKResourceLoadStatisticsManagerSetReducedTimestampResolution(double seconds);
     WK_EXPORT void WKResourceLoadStatisticsManagerFireDataModificationHandler();
index ddc8cc3..b028d8f 100644 (file)
@@ -61,6 +61,21 @@ bool WebResourceLoadStatisticsManager::hasHadUserInteraction(const String& hostN
     return WebCore::ResourceLoadObserver::sharedObserver().hasHadUserInteraction(URL(URL(), hostName));
 }
 
+void WebResourceLoadStatisticsManager::setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName)
+{
+    WebCore::ResourceLoadObserver::sharedObserver().setSubframeUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName));
+}
+
+void WebResourceLoadStatisticsManager::setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName)
+{
+    WebCore::ResourceLoadObserver::sharedObserver().setSubresourceUnderTopFrameOrigin(URL(URL(), hostName), URL(URL(), topFrameHostName));
+}
+
+void WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo)
+{
+    WebCore::ResourceLoadObserver::sharedObserver().setSubresourceUniqueRedirectTo(URL(URL(), hostName), URL(URL(), hostNameRedirectedTo));
+}
+
 void WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(double seconds)
 {
     WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(seconds);
index 0e8102f..7223cda 100644 (file)
@@ -42,6 +42,9 @@ public:
     static bool isPrevalentResource(const String& hostName);
     static void setHasHadUserInteraction(const String& hostName, bool value);
     static bool hasHadUserInteraction(const String& hostName);
+    static void setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
+    static void setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
+    static void setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo);
     static void setTimeToLiveUserInteraction(double seconds);
     static void setReducedTimestampResolution(double seconds);
     static void fireDataModificationHandler();
index 66f2934..5846879 100644 (file)
@@ -45,7 +45,6 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static const auto featureVectorLengthThreshold = 3;
 static auto minimumTimeBetweeenDataRecordsRemoval = 60;
 static OptionSet<WebKit::WebsiteDataType> dataTypesToRemove;
 static auto notifyPages = false;
@@ -59,7 +58,7 @@ Ref<WebResourceLoadStatisticsStore> WebResourceLoadStatisticsStore::create(const
 WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(const String& resourceLoadStatisticsDirectory)
     : m_resourceLoadStatisticsStore(ResourceLoadStatisticsStore::create())
     , m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue"))
-    , m_storagePath(resourceLoadStatisticsDirectory)
+    , m_statisticsStoragePath(resourceLoadStatisticsDirectory)
 {
 }
 
@@ -83,40 +82,11 @@ void WebResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval(do
         minimumTimeBetweeenDataRecordsRemoval = seconds;
 }
 
-bool WebResourceLoadStatisticsStore::hasPrevalentResourceCharacteristics(const ResourceLoadStatistics& resourceStatistic)
-{
-    auto subresourceUnderTopFrameOriginsCount = resourceStatistic.subresourceUnderTopFrameOrigins.size();
-    auto subresourceUniqueRedirectsToCount = resourceStatistic.subresourceUniqueRedirectsTo.size();
-    auto subframeUnderTopFrameOriginsCount = resourceStatistic.subframeUnderTopFrameOrigins.size();
-    
-    if (!subresourceUnderTopFrameOriginsCount
-        && !subresourceUniqueRedirectsToCount
-        && !subframeUnderTopFrameOriginsCount)
-        return false;
-
-    if (subresourceUnderTopFrameOriginsCount > featureVectorLengthThreshold
-        || subresourceUniqueRedirectsToCount > featureVectorLengthThreshold
-        || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold)
-        return true;
-
-    // The resource is considered prevalent if the feature vector
-    // is longer than the threshold.
-    // Vector length for n dimensions is sqrt(a^2 + (...) + n^2).
-    double vectorLength = 0;
-    vectorLength += subresourceUnderTopFrameOriginsCount * subresourceUnderTopFrameOriginsCount;
-    vectorLength += subresourceUniqueRedirectsToCount * subresourceUniqueRedirectsToCount;
-    vectorLength += subframeUnderTopFrameOriginsCount * subframeUnderTopFrameOriginsCount;
-
-    ASSERT(vectorLength > 0);
-
-    return sqrt(vectorLength) > featureVectorLengthThreshold;
-}
-    
 void WebResourceLoadStatisticsStore::classifyResource(ResourceLoadStatistics& resourceStatistic)
 {
-    if (!resourceStatistic.isPrevalentResource && hasPrevalentResourceCharacteristics(resourceStatistic)) {
+    if (!resourceStatistic.isPrevalentResource
+        && m_resourceLoadStatisticsClassifier.hasPrevalentResourceCharacteristics(resourceStatistic))
         resourceStatistic.isPrevalentResource = true;
-    }
 }
 
 void WebResourceLoadStatisticsStore::removeDataRecords()
@@ -249,11 +219,11 @@ void WebResourceLoadStatisticsStore::applicationWillTerminate()
 
 String WebResourceLoadStatisticsStore::persistentStoragePath(const String& label) const
 {
-    if (m_storagePath.isEmpty())
+    if (m_statisticsStoragePath.isEmpty())
         return emptyString();
 
     // TODO Decide what to call this file
-    return pathByAppendingComponent(m_storagePath, label + "_resourceLog.plist");
+    return pathByAppendingComponent(m_statisticsStoragePath, label + "_resourceLog.plist");
 }
 
 void WebResourceLoadStatisticsStore::writeEncoderToDisk(KeyedEncoder& encoder, const String& label) const
@@ -266,8 +236,8 @@ void WebResourceLoadStatisticsStore::writeEncoderToDisk(KeyedEncoder& encoder, c
     if (resourceLog.isEmpty())
         return;
 
-    if (!m_storagePath.isEmpty())
-        makeAllDirectories(m_storagePath);
+    if (!m_statisticsStoragePath.isEmpty())
+        makeAllDirectories(m_statisticsStoragePath);
 
     auto handle = openFile(resourceLog, OpenForWrite);
     if (!handle)
index 5e49007..7f94c0c 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebResourceLoadStatisticsStore_h
-#define WebResourceLoadStatisticsStore_h
+#pragma once
 
 #include "APIObject.h"
 #include "Connection.h"
+#include "ResourceLoadStatisticsClassifier.h"
 #include "WebsiteDataRecord.h"
 #include <WebCore/ResourceLoadStatisticsStore.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
+#if PLATFORM(COCOA)
+#include "ResourceLoadStatisticsClassifierCocoa.h"
+#endif
+
 namespace WTF {
 class WorkQueue;
 }
@@ -76,7 +80,6 @@ private:
 
     void processStatisticsAndDataRecords();
 
-    bool hasPrevalentResourceCharacteristics(const WebCore::ResourceLoadStatistics&);
     void classifyResource(WebCore::ResourceLoadStatistics&);
     void removeDataRecords();
 
@@ -89,8 +92,13 @@ private:
     std::unique_ptr<WebCore::KeyedDecoder> createDecoderFromDisk(const String& label) const;
 
     Ref<WebCore::ResourceLoadStatisticsStore> m_resourceLoadStatisticsStore;
+#if PLATFORM(COCOA)
+    ResourceLoadStatisticsClassifierCocoa m_resourceLoadStatisticsClassifier;
+#else
+    ResourceLoadStatisticsClassifier m_resourceLoadStatisticsClassifier;
+#endif
     Ref<WTF::WorkQueue> m_statisticsQueue;
-    String m_storagePath;
+    String m_statisticsStoragePath;
     bool m_resourceLoadStatisticsEnabled { false };
 
     double m_lastTimeDataRecordsWereRemoved { 0 };
@@ -98,5 +106,3 @@ private:
 };
 
 } // namespace WebKit
-
-#endif // WebResourceLoadStatisticsStore_h
index b927a6f..a404f06 100644 (file)
                6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */; };
                659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
                65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               6B2E09BA1E57B88100C8A8B9 /* CorePredictionSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */; };
                6BE9699C1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6BE9699E1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */; };
                6BE969A01E43B86E008B7483 /* WebResourceLoadStatisticsManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */; };
                6BE969A21E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969A11E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp */; };
+               6BE969C11E54D452008B7483 /* corePrediction_model in Resources */ = {isa = PBXBuildFile; fileRef = 6BE969C01E54D452008B7483 /* corePrediction_model */; };
+               6BE969C71E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp */; };
+               6BE969CA1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */; };
+               6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */; };
+               6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h */; };
                6EE849C81368D9390038D481 /* WKInspectorPrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                728E86F11795188C0087879E /* WebColorPickerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 728E86EF1795188C0087879E /* WebColorPickerMac.h */; };
                728E86F21795188C0087879E /* WebColorPickerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 728E86F01795188C0087879E /* WebColorPickerMac.mm */; };
                6546A82A13000164000CEB1C /* InjectedBundlePageResourceLoadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageResourceLoadClient.h; sourceTree = "<group>"; };
                65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = "<group>"; };
                65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; };
+               6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CorePredictionSoftLink.h; sourceTree = "<group>"; };
                6BE9699B1E43B3FF008B7483 /* WKResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKResourceLoadStatisticsManager.h; sourceTree = "<group>"; };
                6BE9699D1E43B41D008B7483 /* WKResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; };
                6BE9699F1E43B86E008B7483 /* WebResourceLoadStatisticsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadStatisticsManager.h; sourceTree = "<group>"; };
                6BE969A11E43B8A4008B7483 /* WebResourceLoadStatisticsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceLoadStatisticsManager.cpp; sourceTree = "<group>"; };
+               6BE969C01E54D452008B7483 /* corePrediction_model */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = corePrediction_model; sourceTree = "<group>"; };
+               6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifier.cpp; sourceTree = "<group>"; };
+               6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatisticsClassifierCocoa.cpp; sourceTree = "<group>"; };
+               6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifierCocoa.h; sourceTree = "<group>"; };
+               6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsClassifier.h; sourceTree = "<group>"; };
                6D8A91A511F0EFD100DD01FE /* com.apple.WebProcess.sb.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = com.apple.WebProcess.sb.in; path = WebProcess/com.apple.WebProcess.sb.in; sourceTree = "<group>"; };
                6EE849C61368D92D0038D481 /* WKInspectorPrivateMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKInspectorPrivateMac.h; path = mac/WKInspectorPrivateMac.h; sourceTree = "<group>"; };
                728E86EF1795188C0087879E /* WebColorPickerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebColorPickerMac.h; sourceTree = "<group>"; };
                089C1665FE841158C02AAC07 /* Resources */ = {
                        isa = PBXGroup;
                        children = (
+                               6BE969BF1E54D452008B7483 /* ResourceLoadStatistics */,
                                37F8C94F1AE22BD8007DAB9E /* mac */,
                                7CB16FE11724B9B5007A0A95 /* PlugInSandboxProfiles */,
                                A78CCDD5193AC9E3005ECC25 /* SandboxProfiles */,
                        name = Cocoa;
                        sourceTree = "<group>";
                };
+               6BE969BF1E54D452008B7483 /* ResourceLoadStatistics */ = {
+                       isa = PBXGroup;
+                       children = (
+                               6BE969C01E54D452008B7483 /* corePrediction_model */,
+                       );
+                       name = ResourceLoadStatistics;
+                       path = Resources/ResourceLoadStatistics;
+                       sourceTree = "<group>";
+               };
+               6BE969C21E54D467008B7483 /* classifier */ = {
+                       isa = PBXGroup;
+                       children = (
+                               6BE969C31E54D467008B7483 /* cocoa */,
+                               6BE969C61E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp */,
+                               6BE969CC1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h */,
+                       );
+                       path = classifier;
+                       sourceTree = "<group>";
+               };
+               6BE969C31E54D467008B7483 /* cocoa */ = {
+                       isa = PBXGroup;
+                       children = (
+                               6BE969C81E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp */,
+                               6BE969C91E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h */,
+                               6B2E09B91E57B88100C8A8B9 /* CorePredictionSoftLink.h */,
+                       );
+                       path = cocoa;
+                       sourceTree = "<group>";
+               };
                6EE849C41368D9040038D481 /* mac */ = {
                        isa = PBXGroup;
                        children = (
                BC2E6E74114196F000A63B1E /* Platform */ = {
                        isa = PBXGroup;
                        children = (
+                               6BE969C21E54D467008B7483 /* classifier */,
                                3709504118A88BA40087AE5D /* cf */,
                                1AA2E51A12E4C05600BC4966 /* cg */,
                                4450AEBE1DC3FAAC009943F2 /* cocoa */,
                                41DC45961E3D6E2200B11F51 /* NetworkRTCProvider.h in Headers */,
                                7C1BA33E1A4A0E600043E249 /* APIDictionary.h in Headers */,
                                1F7D36C118DA513F00D9D659 /* APIDownloadClient.h in Headers */,
+                               6BE969CB1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.h in Headers */,
                                516A4A5D120A2CCD00C05B7F /* APIError.h in Headers */,
                                317FE7C51C487A6C00A0CA89 /* APIExperimentalFeature.h in Headers */,
                                00B9661618E24CBA00CE1F88 /* APIFindClient.h in Headers */,
                                512127C41908239A00DAF35C /* WebPasteboardOverrides.h in Headers */,
                                7C4694D11A51E36800AD5845 /* WebPasteboardProxy.h in Headers */,
                                7C4694CA1A4B4EA100AD5845 /* WebPasteboardProxyMessages.h in Headers */,
+                               6B2E09BA1E57B88100C8A8B9 /* CorePredictionSoftLink.h in Headers */,
                                1AB1F7971D1B3613007C9BD1 /* WebPaymentCoordinatorMessages.h in Headers */,
                                1AB1F78C1D1B3355007C9BD1 /* WebPaymentCoordinatorProxy.h in Headers */,
                                1AB1F77E1D1B30A9007C9BD1 /* WebPaymentCoordinatorProxyCocoa.h in Headers */,
                                BC7B633D12A45D1200D174A4 /* WKBundlePageGroup.h in Headers */,
                                1AB474D8184D43FD0051B622 /* WKBundlePageLoaderClient.h in Headers */,
                                ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */,
+                               6BE969CD1E54E054008B7483 /* ResourceLoadStatisticsClassifier.h in Headers */,
                                1AB474EA184D45130051B622 /* WKBundlePagePolicyClient.h in Headers */,
                                BC1B419811D41D570011E8DD /* WKBundlePagePrivate.h in Headers */,
                                1AB474DA184D44250051B622 /* WKBundlePageResourceLoadClient.h in Headers */,
                                7A5E394A1D5BD8BE00B4B7CE /* com.macromedia.Flash Player ESR.plugin.sb in Resources */,
                                8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */,
                                93A2A3461D246125002B59D3 /* mediaIcon.pdf in Resources */,
+                               6BE969C11E54D452008B7483 /* corePrediction_model in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                51795567162876CB00FA43B6 /* NetworkProcessMac.mm in Sources */,
                                5163199416289A6000E22F00 /* NetworkProcessMessageReceiver.cpp in Sources */,
                                E14A954916E016A40068DE82 /* NetworkProcessPlatformStrategies.cpp in Sources */,
+                               6BE969CA1E54D4CF008B7483 /* ResourceLoadStatisticsClassifierCocoa.cpp in Sources */,
                                5179556D162877B100FA43B6 /* NetworkProcessProxy.cpp in Sources */,
                                516319921628980A00E22F00 /* NetworkProcessProxyMac.mm in Sources */,
                                513A163C163088F6005D7D22 /* NetworkProcessProxyMessageReceiver.cpp in Sources */,
                                D3B9484611FF4B6500032B39 /* WebPopupMenu.cpp in Sources */,
                                BCC43AC7127B99DE00317F16 /* WebPopupMenuMac.mm in Sources */,
                                BC5750981268F3C6006F0F12 /* WebPopupMenuProxyMac.mm in Sources */,
+                               6BE969C71E54D4B6008B7483 /* ResourceLoadStatisticsClassifier.cpp in Sources */,
                                BCD59800112B57BE00EC8C23 /* WebPreferences.cpp in Sources */,
                                7C85FD7F19341665000177C4 /* WebPreferencesKeys.cpp in Sources */,
                                BC84EB1812A7100C0083F2DA /* WebPreferencesMac.mm in Sources */,
index 193f3c2..19b6bc9 100644 (file)
@@ -1,3 +1,32 @@
+2017-02-24  John Wilander  <wilander@apple.com>
+
+        Resource Load Statistics: Add alternate classification method
+        https://bugs.webkit.org/show_bug.cgi?id=168347
+        <rdar://problem/30352793>
+        <rdar://problem/30646710>
+        <rdar://problem/30660708>
+
+        Reviewed by Alex Christensen.
+
+        Added three testRunner functions to facilitate layout tests:
+        - setStatisticsSubframeUnderTopFrameOrigin()
+        - setStatisticsSubresourceUnderTopFrameOrigin()
+        - setStatisticsSubresourceUniqueRedirectTo()
+
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setStatisticsSubframeUnderTopFrameOrigin):
+        (WTR::TestRunner::setStatisticsSubresourceUnderTopFrameOrigin):
+        (WTR::TestRunner::setStatisticsSubresourceUniqueRedirectTo):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin):
+        (WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin):
+        (WTR::TestController::setStatisticsSubresourceUniqueRedirectTo):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
+
 2017-02-23  Joseph Pecoraro  <pecoraro@apple.com>
 
         [Resource Timing] Add Experimental Feature Flag
index 352fa0a..6e4387f 100644 (file)
@@ -253,6 +253,9 @@ interface TestRunner {
     boolean isStatisticsPrevalentResource(DOMString hostName);
     void setStatisticsHasHadUserInteraction(DOMString hostName, boolean value);
     boolean isStatisticsHasHadUserInteraction(DOMString hostName);
+    void setStatisticsSubframeUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName);
+    void setStatisticsSubresourceUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName);
+    void setStatisticsSubresourceUniqueRedirectTo(DOMString hostName, DOMString hostNameRedirectedTo);
     void setStatisticsTimeToLiveUserInteraction(double seconds);
     void statisticsFireDataModificationHandler();
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(boolean value);
index 6f7eb0c..6a9b4f4 100644 (file)
@@ -1226,6 +1226,78 @@ bool TestRunner::isStatisticsHasHadUserInteraction(JSStringRef hostName)
     return WKBooleanGetValue(static_cast<WKBooleanRef>(returnData));
 }
 
+void TestRunner::setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName)
+{
+    Vector<WKRetainPtr<WKStringRef>> keys;
+    Vector<WKRetainPtr<WKTypeRef>> values;
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(hostName) });
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(topFrameHostName) });
+    
+    Vector<WKStringRef> rawKeys(keys.size());
+    Vector<WKTypeRef> rawValues(values.size());
+    
+    for (size_t i = 0; i < keys.size(); ++i) {
+        rawKeys[i] = keys[i].get();
+        rawValues[i] = values[i].get();
+    }
+    
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubframeUnderTopFrameOrigin"));
+    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
+void TestRunner::setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName)
+{
+    Vector<WKRetainPtr<WKStringRef>> keys;
+    Vector<WKRetainPtr<WKTypeRef>> values;
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(hostName) });
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(topFrameHostName) });
+    
+    Vector<WKStringRef> rawKeys(keys.size());
+    Vector<WKTypeRef> rawValues(values.size());
+    
+    for (size_t i = 0; i < keys.size(); ++i) {
+        rawKeys[i] = keys[i].get();
+        rawValues[i] = values[i].get();
+    }
+    
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubresourceUnderTopFrameOrigin"));
+    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
+void TestRunner::setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo)
+{
+    Vector<WKRetainPtr<WKStringRef>> keys;
+    Vector<WKRetainPtr<WKTypeRef>> values;
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(hostName) });
+    
+    keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo") });
+    values.append({ AdoptWK, WKStringCreateWithJSString(hostNameRedirectedTo) });
+    
+    Vector<WKStringRef> rawKeys(keys.size());
+    Vector<WKTypeRef> rawValues(values.size());
+    
+    for (size_t i = 0; i < keys.size(); ++i) {
+        rawKeys[i] = keys[i].get();
+        rawValues[i] = values[i].get();
+    }
+    
+    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubresourceUniqueRedirectTo"));
+    WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size()));
+    WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr);
+}
+
 void TestRunner::setStatisticsTimeToLiveUserInteraction(double seconds)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsTimeToLiveUserInteraction"));
index 764c9e4..79147a9 100644 (file)
@@ -354,6 +354,9 @@ public:
     bool isStatisticsPrevalentResource(JSStringRef hostName);
     void setStatisticsHasHadUserInteraction(JSStringRef hostName, bool value);
     bool isStatisticsHasHadUserInteraction(JSStringRef hostName);
+    void setStatisticsSubframeUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
+    void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
+    void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo);
     void setStatisticsTimeToLiveUserInteraction(double seconds);
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
     void setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
index 6ea2c55..4bddc19 100644 (file)
@@ -2229,6 +2229,21 @@ bool TestController::isStatisticsHasHadUserInteraction(WKStringRef hostName)
     return WKResourceLoadStatisticsManagerIsHasHadUserInteraction(hostName);
 }
 
+void TestController::setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
+{
+    WKResourceLoadStatisticsManagerSetSubframeUnderTopFrameOrigin(hostName, topFrameHostName);
+}
+
+void TestController::setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName)
+{
+    WKResourceLoadStatisticsManagerSetSubresourceUnderTopFrameOrigin(hostName, topFrameHostName);
+}
+    
+void TestController::setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo)
+{
+    WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(hostName, hostNameRedirectedTo);
+}
+
 void TestController::setStatisticsTimeToLiveUserInteraction(double seconds)
 {
     WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(seconds);
index cc753c2..e49f37f 100644 (file)
@@ -152,6 +152,9 @@ public:
     bool isStatisticsPrevalentResource(WKStringRef hostName);
     void setStatisticsHasHadUserInteraction(WKStringRef hostName, bool value);
     bool isStatisticsHasHadUserInteraction(WKStringRef hostName);
+    void setStatisticsSubframeUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
+    void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
+    void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo);
     void setStatisticsTimeToLiveUserInteraction(double seconds);
     void statisticsFireDataModificationHandler();
     void setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool);
index b0a0442..8f350ae 100644 (file)
@@ -932,6 +932,48 @@ WKRetainPtr<WKTypeRef> TestInvocation::didReceiveSynchronousMessageFromInjectedB
         return result;
     }
     
+    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubframeUnderTopFrameOrigin")) {
+        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+        
+        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+        WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName"));
+        WKRetainPtr<WKStringRef> topFrameHostNameKey(AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName"));
+        
+        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
+        WKStringRef topFrameHostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, topFrameHostNameKey.get()));
+
+        TestController::singleton().setStatisticsSubframeUnderTopFrameOrigin(hostName, topFrameHostName);
+        return nullptr;
+    }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubresourceUnderTopFrameOrigin")) {
+        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+        
+        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+        WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName"));
+        WKRetainPtr<WKStringRef> topFrameHostNameKey(AdoptWK, WKStringCreateWithUTF8CString("TopFrameHostName"));
+        
+        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
+        WKStringRef topFrameHostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, topFrameHostNameKey.get()));
+        
+        TestController::singleton().setStatisticsSubresourceUnderTopFrameOrigin(hostName, topFrameHostName);
+        return nullptr;
+    }
+    
+    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubresourceUniqueRedirectTo")) {
+        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+        
+        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
+        WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName"));
+        WKRetainPtr<WKStringRef> hostNameRedirectedToKey(AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo"));
+        
+        WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get()));
+        WKStringRef hostNameRedirectedTo = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameRedirectedToKey.get()));
+        
+        TestController::singleton().setStatisticsSubresourceUniqueRedirectTo(hostName, hostNameRedirectedTo);
+        return nullptr;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTimeToLiveUserInteraction")) {
         ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID());
         WKDoubleRef seconds = static_cast<WKDoubleRef>(messageBody);