Title: [200908] trunk
Revision
200908
Author
wei...@apple.com
Date
2016-05-13 19:17:31 -0700 (Fri, 13 May 2016)

Log Message

ScriptController::processingUserGesture should propagate across postMessage boundaries
<rdar://problem/26273173>
https://bugs.webkit.org/show_bug.cgi?id=157686

Reviewed by Anders Carlsson.

Source/WebCore:

Test: fast/dom/Window/post-message-user-action.html

* dom/UserGestureIndicator.h:
Export processingUserGesture() for testing.

* page/DOMWindow.cpp:
(WebCore::PostMessageTimer::PostMessageTimer):
(WebCore::PostMessageTimer::event):
Maintain the processingUserGesture bit through postMessage.

* testing/Internals.cpp:
(WebCore::Internals::setResourceTimingSupport):
(WebCore::Internals::isProcessingUserGesture):
* testing/Internals.h:
* testing/Internals.idl:
Add new internals function to get the current state of the UseGestureIndicator for testing.

LayoutTests:

* fast/dom/Window/post-message-user-action-expected.txt: Added.
* fast/dom/Window/post-message-user-action.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (200907 => 200908)


--- trunk/LayoutTests/ChangeLog	2016-05-14 02:10:27 UTC (rev 200907)
+++ trunk/LayoutTests/ChangeLog	2016-05-14 02:17:31 UTC (rev 200908)
@@ -1,3 +1,14 @@
+2016-05-13  Sam Weinig  <s...@webkit.org>
+
+        ScriptController::processingUserGesture should propagate across postMessage boundaries
+        <rdar://problem/26273173>
+        https://bugs.webkit.org/show_bug.cgi?id=157686
+
+        Reviewed by Anders Carlsson.
+
+        * fast/dom/Window/post-message-user-action-expected.txt: Added.
+        * fast/dom/Window/post-message-user-action.html: Added.
+
 2016-05-13  Chris Dumez  <cdu...@apple.com>
 
         Align window.scroll() / scrollTo() / scrollBy() with the CSSOM specification

Added: trunk/LayoutTests/fast/dom/Window/post-message-user-action-expected.txt (0 => 200908)


--- trunk/LayoutTests/fast/dom/Window/post-message-user-action-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/post-message-user-action-expected.txt	2016-05-14 02:17:31 UTC (rev 200908)
@@ -0,0 +1,15 @@
+Test that the processing user gesture bit is maintained through postMessage.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing that isProcessingUserGesture() is false on load.
+PASS window.internals.isProcessingUserGesture() is false
+Testing that isProcessingUserGesture() is true in response to a click.
+PASS window.internals.isProcessingUserGesture() is true
+Testing that isProcessingUserGesture() is true after processing a postMessage.
+PASS window.internals.isProcessingUserGesture() is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Click

Added: trunk/LayoutTests/fast/dom/Window/post-message-user-action.html (0 => 200908)


--- trunk/LayoutTests/fast/dom/Window/post-message-user-action.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/post-message-user-action.html	2016-05-14 02:17:31 UTC (rev 200908)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<button id="clicker" _onclick_="go()">Click</button>
+<script>
+
+description("Test that the processing user gesture bit is maintained through postMessage.");
+
+window.jsTestIsAsync = true;
+
+function go()
+{
+    debug("Testing that isProcessingUserGesture() is true in response to a click.")
+    shouldBeTrue("window.internals.isProcessingUserGesture()");
+    window.postMessage("go", "*");
+}
+
+window._onmessage_ = function(evt)
+{
+    if (evt.data == "go") {
+        if (window.internals) {
+            debug("Testing that isProcessingUserGesture() is true after processing a postMessage.")
+            shouldBeTrue("window.internals.isProcessingUserGesture()");
+        }
+        finishJSTest();
+    }
+}
+
+debug("Testing that isProcessingUserGesture() is false on load.")
+shouldBeFalse("window.internals.isProcessingUserGesture()");
+
+if (window.eventSender) {
+    var element = document.getElementById('clicker');
+    eventSender.mouseMoveTo(element.offsetLeft + 5, element.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (200907 => 200908)


--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-05-14 02:10:27 UTC (rev 200907)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-05-14 02:17:31 UTC (rev 200908)
@@ -1842,6 +1842,7 @@
 # eventSender.mouseDown is not implemented
 fast/loader/location-hash-user-gesture.html [ Skip ]
 imported/blink/editing/selection/selectstart-event-crash.html [ Skip ]
+fast/dom/Window/post-message-user-action.html [ Skip ]
 
 # No touch events
 http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (200907 => 200908)


--- trunk/Source/WebCore/ChangeLog	2016-05-14 02:10:27 UTC (rev 200907)
+++ trunk/Source/WebCore/ChangeLog	2016-05-14 02:17:31 UTC (rev 200908)
@@ -1,3 +1,28 @@
+2016-05-13  Sam Weinig  <s...@webkit.org>
+
+        ScriptController::processingUserGesture should propagate across postMessage boundaries
+        <rdar://problem/26273173>
+        https://bugs.webkit.org/show_bug.cgi?id=157686
+
+        Reviewed by Anders Carlsson.
+
+        Test: fast/dom/Window/post-message-user-action.html
+
+        * dom/UserGestureIndicator.h:
+        Export processingUserGesture() for testing.
+
+        * page/DOMWindow.cpp:
+        (WebCore::PostMessageTimer::PostMessageTimer):
+        (WebCore::PostMessageTimer::event):
+        Maintain the processingUserGesture bit through postMessage.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::setResourceTimingSupport):
+        (WebCore::Internals::isProcessingUserGesture):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        Add new internals function to get the current state of the UseGestureIndicator for testing.
+
 2016-05-13  Chris Dumez  <cdu...@apple.com>
 
         Align window.scroll() / scrollTo() / scrollBy() with the CSSOM specification

Modified: trunk/Source/WebCore/dom/UserGestureIndicator.h (200907 => 200908)


--- trunk/Source/WebCore/dom/UserGestureIndicator.h	2016-05-14 02:10:27 UTC (rev 200907)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.h	2016-05-14 02:17:31 UTC (rev 200908)
@@ -42,7 +42,7 @@
 class UserGestureIndicator {
     WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
 public:
-    static bool processingUserGesture();
+    WEBCORE_EXPORT static bool processingUserGesture();
     static bool processingUserGestureForMedia();
 
     // If a document is provided, its last known user gesture timestamp is updated.

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (200907 => 200908)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2016-05-14 02:10:27 UTC (rev 200907)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2016-05-14 02:17:31 UTC (rev 200908)
@@ -97,6 +97,7 @@
 #include "StyleResolver.h"
 #include "SuddenTermination.h"
 #include "URL.h"
+#include "UserGestureIndicator.h"
 #include "WebKitPoint.h"
 #include "WindowFeatures.h"
 #include "WindowFocusAllowedIndicator.h"
@@ -152,6 +153,7 @@
         , m_channels(WTFMove(channels))
         , m_targetOrigin(WTFMove(targetOrigin))
         , m_stackTrace(stackTrace)
+        , m_wasProcessingUserGesture(UserGestureIndicator::processingUserGesture())
     {
     }
 
@@ -159,6 +161,7 @@
     {
         return MessageEvent::create(MessagePort::entanglePorts(context, WTFMove(m_channels)), WTFMove(m_message), m_origin, { }, m_source.ptr());
     }
+
     SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); }
     ScriptCallStack* stackTrace() const { return m_stackTrace.get(); }
 
@@ -167,6 +170,8 @@
     {
         // This object gets deleted when std::unique_ptr falls out of scope..
         std::unique_ptr<PostMessageTimer> timer(this);
+        
+        UserGestureIndicator userGestureIndicator(m_wasProcessingUserGesture ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
         m_window->postMessageTimerFired(*timer);
     }
 
@@ -177,6 +182,7 @@
     std::unique_ptr<MessagePortChannelArray> m_channels;
     RefPtr<SecurityOrigin> m_targetOrigin;
     RefPtr<ScriptCallStack> m_stackTrace;
+    bool m_wasProcessingUserGesture;
 };
 
 typedef HashCountedSet<DOMWindow*> DOMWindowSet;

Modified: trunk/Source/WebCore/testing/Internals.cpp (200907 => 200908)


--- trunk/Source/WebCore/testing/Internals.cpp	2016-05-14 02:10:27 UTC (rev 200907)
+++ trunk/Source/WebCore/testing/Internals.cpp	2016-05-14 02:17:31 UTC (rev 200908)
@@ -119,6 +119,7 @@
 #include "TextIterator.h"
 #include "TreeScope.h"
 #include "TypeConversions.h"
+#include "UserGestureIndicator.h"
 #include "UserMediaController.h"
 #include "ViewportArguments.h"
 #include "WebCoreJSClientData.h"
@@ -3333,4 +3334,9 @@
     RuntimeEnabledFeatures::sharedFeatures().setResourceTimingEnabled(enable);
 }
 
+bool Internals::isProcessingUserGesture()
+{
+    return UserGestureIndicator::processingUserGesture();
 }
+
+}

Modified: trunk/Source/WebCore/testing/Internals.h (200907 => 200908)


--- trunk/Source/WebCore/testing/Internals.h	2016-05-14 02:10:27 UTC (rev 200907)
+++ trunk/Source/WebCore/testing/Internals.h	2016-05-14 02:17:31 UTC (rev 200908)
@@ -483,6 +483,8 @@
     void setWebGL2Enabled(bool);
 #endif
 
+    bool isProcessingUserGesture();
+
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (200907 => 200908)


--- trunk/Source/WebCore/testing/Internals.idl	2016-05-14 02:10:27 UTC (rev 200907)
+++ trunk/Source/WebCore/testing/Internals.idl	2016-05-14 02:17:31 UTC (rev 200908)
@@ -459,4 +459,6 @@
 #endif
 
     void setResourceTimingSupport(boolean scalable);
+    
+    boolean isProcessingUserGesture();
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to