Title: [223094] branches/safari-604-branch

Diff

Modified: branches/safari-604-branch/LayoutTests/ChangeLog (223093 => 223094)


--- branches/safari-604-branch/LayoutTests/ChangeLog	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/LayoutTests/ChangeLog	2017-10-10 00:07:57 UTC (rev 223094)
@@ -1,5 +1,25 @@
 2017-10-02  Jason Marcell  <[email protected]>
 
+        Cherry-pick r220302. rdar://problem/34770803
+
+    2017-08-04  John Wilander  <[email protected]>
+
+            Resource Load Statistics: Report user interaction immediately, but only when needed
+            https://bugs.webkit.org/show_bug.cgi?id=175090
+            <rdar://problem/33685546>
+
+            Reviewed by Chris Dumez.
+
+            * http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html:
+                Now no longer needs to disable throttling since reports of
+                user interaction happen immediately (when needed).
+            * http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time-expected.txt: Added.
+            * http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html: Added.
+            * platform/mac-wk2/TestExpectations:
+                user-interaction-only-reported-once-within-short-period-of-time.html marked as [ Pass ].
+
+2017-10-02  Jason Marcell  <[email protected]>
+
         Cherry-pick r221128. rdar://problem/34771005
 
     2017-08-23  Wenson Hsieh  <[email protected]>

Modified: branches/safari-604-branch/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html (223093 => 223094)


--- branches/safari-604-branch/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html	2017-10-10 00:07:57 UTC (rev 223094)
@@ -25,10 +25,8 @@
 }
 
 _onload_ = function() {
-    if (internals) {
+    if (internals)
         internals.setResourceLoadStatisticsEnabled(true);
-        internals.setResourceLoadStatisticsShouldThrottleObserverNotifications(false);
-    }
 
     if (testRunner) {
         testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);

Added: branches/safari-604-branch/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time-expected.txt (0 => 223094)


--- branches/safari-604-branch/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time-expected.txt	                        (rev 0)
+++ branches/safari-604-branch/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time-expected.txt	2017-10-10 00:07:57 UTC (rev 223094)
@@ -0,0 +1,22 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+Tests that user interaction is not reported repeatedly within a short period of time.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.location.origin is topFrameOrigin
+PASS testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin) is false
+PASS testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin) is false
+PASS testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin) is true
+PASS testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin) is false
+PASS testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin) is false
+PASS testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin) is false
+PASS testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This is the test element

Added: branches/safari-604-branch/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html (0 => 223094)


--- branches/safari-604-branch/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html	                        (rev 0)
+++ branches/safari-604-branch/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html	2017-10-10 00:07:57 UTC (rev 223094)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+<script>
+    description("Tests that user interaction is not reported repeatedly within a short period of time.");
+    jsTestIsAsync = true;
+
+    const topFrameOrigin = "http://127.0.0.1:8000";
+    const subFrameOrigin = "http://localhost:8000";
+
+    function activateElement(elementId, callback) {
+        var element = document.getElementById(elementId);
+        var centerX = element.offsetLeft + element.offsetWidth / 2;
+        var centerY = element.offsetTop + element.offsetHeight / 2;
+        UIHelper.activateAt(centerX, centerY).then(
+            function() {
+                callback();
+            },
+            function() {
+                testFailed("Promise rejected.");
+                finishJSTest();
+            }
+        );
+    }
+
+    function firstInteraction() {
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
+        activateElement("testElement", secondInteraction);
+    }
+
+    function secondInteraction() {
+        shouldBeTrue("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
+
+        if (testRunner)
+            testRunner.setStatisticsHasHadUserInteraction(topFrameOrigin, false);
+
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+
+        activateElement("testElement", finishTest);
+    }
+
+    function finishTest() {
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+        shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
+
+        finishJSTest();
+    }
+
+    _onload_ = function() {
+        if (internals)
+            internals.setResourceLoadStatisticsEnabled(true);
+
+        shouldBe("document.location.origin", "topFrameOrigin");
+
+        firstInteraction();
+    };
+</script>
+<div id="testElement">This is the test element</div>
+</body>
+</html>
\ No newline at end of file

Modified: branches/safari-604-branch/LayoutTests/platform/mac-wk2/TestExpectations (223093 => 223094)


--- branches/safari-604-branch/LayoutTests/platform/mac-wk2/TestExpectations	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/LayoutTests/platform/mac-wk2/TestExpectations	2017-10-10 00:07:57 UTC (rev 223094)
@@ -719,5 +719,6 @@
 
 webkit.org/b/172397 [ Sierra Debug ] animations/needs-layout.html [ Pass ImageOnlyFailure ]
 
-# Currently only tests with click, not tap.
+# Move to general wk2 expectations once webkit.org/b/175170 is resolved.
 http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html [ Pass ]
+http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html [ Pass ]

Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (223093 => 223094)


--- branches/safari-604-branch/Source/WebCore/ChangeLog	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog	2017-10-10 00:07:57 UTC (rev 223094)
@@ -1,5 +1,44 @@
 2017-10-02  Jason Marcell  <[email protected]>
 
+        Cherry-pick r220302. rdar://problem/34770803
+
+    2017-08-04  John Wilander  <[email protected]>
+
+            Resource Load Statistics: Report user interaction immediately, but only when needed
+            https://bugs.webkit.org/show_bug.cgi?id=175090
+            <rdar://problem/33685546>
+
+            Reviewed by Chris Dumez.
+
+            Test: http/tests/loading/resourceLoadStatistics/user-interaction-only-reported-once-within-short-period-of-time.html
+
+            * loader/ResourceLoadObserver.cpp:
+            (WebCore::ResourceLoadObserver::ResourceLoadObserver):
+            (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+                Now tells the UI process immediately but also records that it has
+                done so to avoid doing it when not needed.
+            (WebCore::ResourceLoadObserver::scheduleNotificationIfNeeded):
+                Conditional throttling gone, now always throttles.
+            (WebCore::ResourceLoadObserver::notifyObserver):
+                Renamed from ResourceLoadObserver::notificationTimerFired().
+            (WebCore::ResourceLoadObserver::clearState):
+                New function to allow the test runner to reset the web process'
+                statistics state now that we keep track of whether or not we've
+                reported user interaction to the UI process.
+            (WebCore::ResourceLoadObserver::setShouldThrottleObserverNotifications): Deleted.
+            (WebCore::ResourceLoadObserver::notificationTimerFired): Deleted.
+            * loader/ResourceLoadObserver.h:
+            (): Deleted.
+            * testing/Internals.cpp:
+            (WebCore::Internals::resetToConsistentState):
+            (WebCore::Internals::setResourceLoadStatisticsShouldThrottleObserverNotifications): Deleted.
+                No longer needed since user interaction is always communicated
+                immediately.
+            * testing/Internals.h:
+            * testing/Internals.idl:
+
+2017-10-02  Jason Marcell  <[email protected]>
+
         Cherry-pick r221128. rdar://problem/34771005
 
     2017-08-23  Wenson Hsieh  <[email protected]>

Modified: branches/safari-604-branch/Source/WebCore/loader/ResourceLoadObserver.cpp (223093 => 223094)


--- branches/safari-604-branch/Source/WebCore/loader/ResourceLoadObserver.cpp	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Source/WebCore/loader/ResourceLoadObserver.cpp	2017-10-10 00:07:57 UTC (rev 223094)
@@ -99,19 +99,6 @@
     return firstMetaDomainIdentifier == metaDomainIdentifiers.get().get(secondDomain);
 }
 
-void ResourceLoadObserver::setShouldThrottleObserverNotifications(bool shouldThrottle)
-{
-    m_shouldThrottleNotifications = shouldThrottle;
-
-    if (!m_notificationTimer.isActive())
-        return;
-
-    // If we change the notification state, we need to restart any notifications
-    // so they will be on the right schedule.
-    m_notificationTimer.stop();
-    scheduleNotificationIfNeeded();
-}
-
 void ResourceLoadObserver::setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&& notificationCallback)
 {
     ASSERT(!m_notificationCallback);
@@ -119,7 +106,7 @@
 }
 
 ResourceLoadObserver::ResourceLoadObserver()
-    : m_notificationTimer(*this, &ResourceLoadObserver::notificationTimerFired)
+    : m_notificationTimer(*this, &ResourceLoadObserver::notifyObserver)
 {
 }
 
@@ -280,16 +267,21 @@
     if (url.isBlankURL() || url.isEmpty())
         return;
 
-    auto& statistics = ensureResourceStatisticsForPrimaryDomain(primaryDomain(url));
+    auto domain = primaryDomain(url);
     auto newTime = reduceToHourlyTimeResolution(WallTime::now());
-    if (newTime == statistics.mostRecentUserInteractionTime)
+    auto lastReportedUserInteraction = m_lastReportedUserInteractionMap.get(domain);
+    if (newTime == lastReportedUserInteraction)
         return;
 
+    m_lastReportedUserInteractionMap.set(domain, newTime);
+
+    auto& statistics = ensureResourceStatisticsForPrimaryDomain(domain);
     statistics.hadUserInteraction = true;
     statistics.lastSeen = newTime;
     statistics.mostRecentUserInteractionTime = newTime;
 
-    scheduleNotificationIfNeeded();
+    m_notificationTimer.stop();
+    notifyObserver();
 }
 
 ResourceLoadStatistics& ResourceLoadObserver::ensureResourceStatisticsForPrimaryDomain(const String& primaryDomain)
@@ -309,12 +301,13 @@
     }
 
     if (!m_notificationTimer.isActive())
-        m_notificationTimer.startOneShot(m_shouldThrottleNotifications ? minimumNotificationInterval : 0_s);
+        m_notificationTimer.startOneShot(minimumNotificationInterval);
 }
 
-void ResourceLoadObserver::notificationTimerFired()
+void ResourceLoadObserver::notifyObserver()
 {
     ASSERT(m_notificationCallback);
+    m_notificationTimer.stop();
     m_notificationCallback(takeStatistics());
 }
 
@@ -339,4 +332,11 @@
     return statistics;
 }
 
+void ResourceLoadObserver::clearState()
+{
+    m_notificationTimer.stop();
+    m_resourceStatisticsMap.clear();
+    m_lastReportedUserInteractionMap.clear();
+}
+
 } // namespace WebCore

Modified: branches/safari-604-branch/Source/WebCore/loader/ResourceLoadObserver.h (223093 => 223094)


--- branches/safari-604-branch/Source/WebCore/loader/ResourceLoadObserver.h	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Source/WebCore/loader/ResourceLoadObserver.h	2017-10-10 00:07:57 UTC (rev 223094)
@@ -33,6 +33,7 @@
 namespace WTF {
 class Lock;
 class WorkQueue;
+class WallTime;
 }
 
 namespace WebCore {
@@ -62,6 +63,7 @@
 
     WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&&);
 
+    WEBCORE_EXPORT void clearState();
 private:
     ResourceLoadObserver();
 
@@ -69,13 +71,13 @@
     ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
 
     void scheduleNotificationIfNeeded();
-    void notificationTimerFired();
+    void notifyObserver();
     Vector<ResourceLoadStatistics> takeStatistics();
 
     HashMap<String, ResourceLoadStatistics> m_resourceStatisticsMap;
+    HashMap<String, WTF::WallTime> m_lastReportedUserInteractionMap;
     WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback;
     Timer m_notificationTimer;
-    bool m_shouldThrottleNotifications { true };
 };
     
 } // namespace WebCore

Modified: branches/safari-604-branch/Source/WebCore/testing/Internals.cpp (223093 => 223094)


--- branches/safari-604-branch/Source/WebCore/testing/Internals.cpp	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Source/WebCore/testing/Internals.cpp	2017-10-10 00:07:57 UTC (rev 223094)
@@ -467,8 +467,6 @@
 #if USE(LIBWEBRTC)
     WebCore::useRealRTCPeerConnectionFactory();
 #endif
-    
-    ResourceLoadObserver::shared().setShouldThrottleObserverNotifications(true);
 
     printContextForTesting() = nullptr;
 }
@@ -3871,11 +3869,6 @@
     Settings::setResourceLoadStatisticsEnabled(enable);
 }
 
-void Internals::setResourceLoadStatisticsShouldThrottleObserverNotifications(bool enable)
-{
-    ResourceLoadObserver::shared().setShouldThrottleObserverNotifications(enable);
-}
-    
 String Internals::composedTreeAsText(Node& node)
 {
     if (!is<ContainerNode>(node))

Modified: branches/safari-604-branch/Source/WebCore/testing/Internals.h (223093 => 223094)


--- branches/safari-604-branch/Source/WebCore/testing/Internals.h	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Source/WebCore/testing/Internals.h	2017-10-10 00:07:57 UTC (rev 223094)
@@ -539,7 +539,6 @@
 
     String resourceLoadStatisticsForOrigin(const String& origin);
     void setResourceLoadStatisticsEnabled(bool);
-    void setResourceLoadStatisticsShouldThrottleObserverNotifications(bool);
 
 #if ENABLE(STREAMS_API)
     bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);

Modified: branches/safari-604-branch/Source/WebCore/testing/Internals.idl (223093 => 223094)


--- branches/safari-604-branch/Source/WebCore/testing/Internals.idl	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Source/WebCore/testing/Internals.idl	2017-10-10 00:07:57 UTC (rev 223094)
@@ -498,7 +498,6 @@
 
     DOMString resourceLoadStatisticsForOrigin(DOMString domain);
     void setResourceLoadStatisticsEnabled(boolean enable);
-    void setResourceLoadStatisticsShouldThrottleObserverNotifications(boolean enable);
 
     [MayThrowException] void setCanShowModalDialogOverride(boolean allow);
 

Modified: branches/safari-604-branch/Source/WebKit/ChangeLog (223093 => 223094)


--- branches/safari-604-branch/Source/WebKit/ChangeLog	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Source/WebKit/ChangeLog	2017-10-10 00:07:57 UTC (rev 223094)
@@ -1,5 +1,23 @@
 2017-10-02  Jason Marcell  <[email protected]>
 
+        Cherry-pick r220302. rdar://problem/34770803
+
+    2017-08-04  John Wilander  <[email protected]>
+
+            Resource Load Statistics: Report user interaction immediately, but only when needed
+            https://bugs.webkit.org/show_bug.cgi?id=175090
+            <rdar://problem/33685546>
+
+            Reviewed by Chris Dumez.
+
+            * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+            (WKBundleClearResourceLoadStatistics):
+                Test infrastructure. Ends up calling
+                WebCore::ResourceLoadObserver::clearState().
+            * WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
+
+2017-10-02  Jason Marcell  <[email protected]>
+
         Cherry-pick r220718. rdar://problem/34771041
 
     2017-08-14  Andy Estes  <[email protected]>

Modified: branches/safari-604-branch/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp (223093 => 223094)


--- branches/safari-604-branch/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2017-10-10 00:07:57 UTC (rev 223094)
@@ -39,6 +39,7 @@
 #include "WebPage.h"
 #include "WebPageGroupProxy.h"
 #include <WebCore/DatabaseTracker.h>
+#include <WebCore/ResourceLoadObserver.h>
 
 using namespace WebCore;
 using namespace WebKit;
@@ -276,3 +277,8 @@
 {
     toImpl(bundleRef)->setTabKeyCyclesThroughElements(toImpl(pageRef), enabled);
 }
+
+void WKBundleClearResourceLoadStatistics(WKBundleRef)
+{
+    ResourceLoadObserver::shared().clearState();
+}

Modified: branches/safari-604-branch/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h (223093 => 223094)


--- branches/safari-604-branch/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePrivate.h	2017-10-10 00:07:57 UTC (rev 223094)
@@ -91,6 +91,8 @@
 
 WK_EXPORT void WKBundleSetTabKeyCyclesThroughElements(WKBundleRef bundle, WKBundlePageRef page, bool enabled);
 
+WK_EXPORT void WKBundleClearResourceLoadStatistics(WKBundleRef);
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/safari-604-branch/Tools/ChangeLog (223093 => 223094)


--- branches/safari-604-branch/Tools/ChangeLog	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Tools/ChangeLog	2017-10-10 00:07:57 UTC (rev 223094)
@@ -1,3 +1,19 @@
+2017-10-02  Jason Marcell  <[email protected]>
+
+        Cherry-pick r220302. rdar://problem/34770803
+
+    2017-08-04  John Wilander  <[email protected]>
+
+            Resource Load Statistics: Report user interaction immediately, but only when needed
+            https://bugs.webkit.org/show_bug.cgi?id=175090
+            <rdar://problem/33685546>
+
+            Reviewed by Chris Dumez.
+
+            * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+            (WTR::InjectedBundle::beginTesting):
+                Now calls WebCore::ResourceLoadObserver::clearState().
+
 2017-10-05  Matthew Hanson  <[email protected]>
 
         Revert r222431. rdar://problem/34826998

Modified: branches/safari-604-branch/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (223093 => 223094)


--- branches/safari-604-branch/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2017-10-10 00:07:52 UTC (rev 223093)
+++ branches/safari-604-branch/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2017-10-10 00:07:57 UTC (rev 223094)
@@ -367,6 +367,7 @@
     WKBundleClearAllDatabases(m_bundle);
     WKBundlePageClearApplicationCache(page()->page());
     WKBundleResetOriginAccessWhitelists(m_bundle);
+    WKBundleClearResourceLoadStatistics(m_bundle);
 
     // [WK2] REGRESSION(r128623): It made layout tests extremely slow
     // https://bugs.webkit.org/show_bug.cgi?id=96862
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to