Diff
Modified: trunk/LayoutTests/ChangeLog (219283 => 219284)
--- trunk/LayoutTests/ChangeLog 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/LayoutTests/ChangeLog 2017-07-10 02:18:56 UTC (rev 219284)
@@ -1,3 +1,17 @@
+2017-07-08 John Wilander <[email protected]>
+
+ Resource Load Statistics: User interaction should always go to top document
+ https://bugs.webkit.org/show_bug.cgi?id=174120
+ <rdar://problem/33117899>
+
+ Reviewed by Chris Dumez.
+
+ * http/tests/loading/resourceLoadStatistics/resources/dummy.html: Added.
+ * http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame-expected.txt: Added.
+ * http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html: Added.
+ * platform/mac-wk2/TestExpectations:
+ Added as [ Pass ].
+
2017-07-08 Antoine Quint <[email protected]>
REGRESSION: "visibility:hidden" does not hide play button for video elements
Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/resources/dummy.html (0 => 219284)
--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/resources/dummy.html (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/resources/dummy.html 2017-07-10 02:18:56 UTC (rev 219284)
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<html>
+<body>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame-expected.txt (0 => 219284)
--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame-expected.txt 2017-07-10 02:18:56 UTC (rev 219284)
@@ -0,0 +1,24 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+frame "testFrame" - didStartProvisionalLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+frame "testFrame" - didCommitLoadForFrame
+frame "testFrame" - didFinishDocumentLoadForFrame
+frame "testFrame" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+frame "testFrame" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+Tests that user interaction is always logged for the top document/frame.
+
+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 successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html (0 => 219284)
--- trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html 2017-07-10 02:18:56 UTC (rev 219284)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+<script>
+description("Tests that user interaction is always logged for the top document/frame.");
+jsTestIsAsync = true;
+
+const topFrameOrigin = "http://127.0.0.1:8000";
+const subFrameOrigin = "http://localhost:8000";
+
+function activateElement(elementId) {
+ var element = document.getElementById(elementId);
+ var centerX = element.offsetLeft + element.offsetWidth / 2;
+ var centerY = element.offsetTop + element.offsetHeight / 2;
+ UIHelper.activateAt(centerX, centerY);
+}
+
+function finishTest() {
+ shouldBeTrue("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+ shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
+
+ finishJSTest();
+}
+
+_onload_ = function() {
+ if (internals) {
+ internals.setResourceLoadStatisticsEnabled(true);
+ internals.setResourceLoadStatisticsShouldThrottleObserverNotifications(false);
+ }
+
+ if (testRunner) {
+ testRunner.setStatisticsNotifyPagesWhenDataRecordsWereScanned(true);
+ testRunner.installStatisticsDidScanDataRecordsCallback(finishTest);
+ }
+
+ shouldBe("document.location.origin", "topFrameOrigin");
+
+ if (testRunner) {
+ shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(topFrameOrigin)");
+ shouldBeFalse("testRunner.isStatisticsHasHadUserInteraction(subFrameOrigin)");
+
+ activateElement("testFrame");
+ }
+};
+</script>
+<iframe id="testFrame" src=""
+</body>
+</html>
\ No newline at end of file
Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (219283 => 219284)
--- trunk/LayoutTests/platform/ios-wk2/TestExpectations 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations 2017-07-10 02:18:56 UTC (rev 219284)
@@ -1679,6 +1679,8 @@
transitions/zero-duration-in-list.html [ Failure Pass ]
transitions/zero-duration-with-non-zero-delay-end.html [ Failure Pass ]
+http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html [ Pass ]
+
# Skip flaky/timeout tests
fast/css-grid-layout/flex-content-sized-columns-resize.html [ Skip ]
fast/history/page-cache-geolocation-active-oneshot.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (219283 => 219284)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-07-10 02:18:56 UTC (rev 219284)
@@ -710,3 +710,5 @@
webkit.org/b/172397 [ Sierra Debug ] animations/needs-layout.html [ Pass ImageOnlyFailure ]
+# Currently only tests with click, not tap.
+http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html [ Pass ]
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (219283 => 219284)
--- trunk/Source/WebCore/ChangeLog 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/Source/WebCore/ChangeLog 2017-07-10 02:18:56 UTC (rev 219284)
@@ -1,3 +1,39 @@
+2017-07-08 John Wilander <[email protected]>
+
+ Resource Load Statistics: User interaction should always go to top document
+ https://bugs.webkit.org/show_bug.cgi?id=174120
+ <rdar://problem/33117899>
+
+ Reviewed by Chris Dumez.
+
+ Test: http/tests/loading/resourceLoadStatistics/user-interaction-in-cross-origin-sub-frame.html
+
+ * dom/UserGestureIndicator.cpp:
+ (WebCore::UserGestureIndicator::UserGestureIndicator):
+ Now logs user interaction for the top document.
+ * loader/ResourceLoadObserver.cpp:
+ (WebCore::ResourceLoadObserver::setThrottledObserverNotifications):
+ Test infrastructure.
+ (WebCore::ResourceLoadObserver::setNotificationCallback):
+ Callback now takes a ResourceLoadObserver::NotificationType.
+ (WebCore::ResourceLoadObserver::logFrameNavigation):
+ Submits the configured ResourceLoadObserver::NotificationType.
+ (WebCore::ResourceLoadObserver::logSubresourceLoading):
+ Submits the configured ResourceLoadObserver::NotificationType.
+ (WebCore::ResourceLoadObserver::logWebSocketLoading):
+ Submits the configured ResourceLoadObserver::NotificationType.
+ (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+ Submits the configured ResourceLoadObserver::NotificationType.
+ * loader/ResourceLoadObserver.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::resetToConsistentState):
+ Resets to throttled notifications.
+ (WebCore::Internals::setResourceLoadStatisticsThrottledObserverNotifications):
+ Test infrastructure.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+ Added internals.setResourceLoadStatisticsThrottledObserverNotifications().
+
2017-07-09 Brady Eidson <[email protected]>
Remove some obsolete WebKitVersionChecks.
Modified: trunk/Source/WebCore/dom/UserGestureIndicator.cpp (219283 => 219284)
--- trunk/Source/WebCore/dom/UserGestureIndicator.cpp 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.cpp 2017-07-10 02:18:56 UTC (rev 219284)
@@ -57,7 +57,7 @@
if (document && currentToken()->processingUserGesture()) {
document->updateLastHandledUserGestureTimestamp(MonotonicTime::now());
- ResourceLoadObserver::shared().logUserInteractionWithReducedTimeResolution(*document);
+ ResourceLoadObserver::shared().logUserInteractionWithReducedTimeResolution(document->topDocument());
document->topDocument().setUserDidInteractWithPage(true);
}
}
Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (219283 => 219284)
--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp 2017-07-10 02:18:56 UTC (rev 219284)
@@ -54,6 +54,19 @@
return resourceLoadObserver;
}
+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);
@@ -232,7 +245,7 @@
}
if (!m_notificationTimer.isActive())
- m_notificationTimer.startOneShot(minimumNotificationInterval);
+ m_notificationTimer.startOneShot(m_shouldThrottleNotifications ? minimumNotificationInterval : 0_s);
}
void ResourceLoadObserver::notificationTimerFired()
Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (219283 => 219284)
--- trunk/Source/WebCore/loader/ResourceLoadObserver.h 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h 2017-07-10 02:18:56 UTC (rev 219284)
@@ -50,6 +50,8 @@
friend class WTF::NeverDestroyed<ResourceLoadObserver>;
public:
WEBCORE_EXPORT static ResourceLoadObserver& shared();
+
+ WEBCORE_EXPORT void setShouldThrottleObserverNotifications(bool);
void logFrameNavigation(const Frame&, const Frame& topFrame, const ResourceRequest& newRequest);
void logSubresourceLoading(const Frame*, const ResourceRequest& newRequest, const ResourceResponse& redirectResponse);
@@ -73,6 +75,7 @@
HashMap<String, ResourceLoadStatistics> m_resourceStatisticsMap;
WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback;
Timer m_notificationTimer;
+ bool m_shouldThrottleNotifications { true };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.cpp (219283 => 219284)
--- trunk/Source/WebCore/testing/Internals.cpp 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/Source/WebCore/testing/Internals.cpp 2017-07-10 02:18:56 UTC (rev 219284)
@@ -469,6 +469,8 @@
#if USE(LIBWEBRTC)
WebCore::useRealRTCPeerConnectionFactory();
#endif
+
+ ResourceLoadObserver::shared().setShouldThrottleObserverNotifications(true);
}
Internals::Internals(Document& document)
@@ -3892,6 +3894,11 @@
Settings::setResourceLoadStatisticsEnabled(enable);
}
+void Internals::setResourceLoadStatisticsShouldThrottleObserverNotifications(bool enable)
+{
+ ResourceLoadObserver::shared().setShouldThrottleObserverNotifications(enable);
+}
+
String Internals::composedTreeAsText(Node& node)
{
if (!is<ContainerNode>(node))
Modified: trunk/Source/WebCore/testing/Internals.h (219283 => 219284)
--- trunk/Source/WebCore/testing/Internals.h 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/Source/WebCore/testing/Internals.h 2017-07-10 02:18:56 UTC (rev 219284)
@@ -538,6 +538,7 @@
String resourceLoadStatisticsForOrigin(const String& origin);
void setResourceLoadStatisticsEnabled(bool);
+ void setResourceLoadStatisticsShouldThrottleObserverNotifications(bool);
#if ENABLE(STREAMS_API)
bool isReadableStreamDisturbed(JSC::ExecState&, JSC::JSValue);
Modified: trunk/Source/WebCore/testing/Internals.idl (219283 => 219284)
--- trunk/Source/WebCore/testing/Internals.idl 2017-07-09 21:26:15 UTC (rev 219283)
+++ trunk/Source/WebCore/testing/Internals.idl 2017-07-10 02:18:56 UTC (rev 219284)
@@ -497,6 +497,7 @@
DOMString resourceLoadStatisticsForOrigin(DOMString domain);
void setResourceLoadStatisticsEnabled(boolean enable);
+ void setResourceLoadStatisticsShouldThrottleObserverNotifications(boolean enable);
[MayThrowException] void setCanShowModalDialogOverride(boolean allow);