<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[200908] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/200908">200908</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2016-05-13 19:17:31 -0700 (Fri, 13 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>ScriptController::processingUserGesture should propagate across postMessage boundaries
&lt;rdar://problem/26273173&gt;
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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomUserGestureIndicatorh">trunk/Source/WebCore/dom/UserGestureIndicator.h</a></li>
<li><a href="#trunkSourceWebCorepageDOMWindowcpp">trunk/Source/WebCore/page/DOMWindow.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomWindowpostmessageuseractionexpectedtxt">trunk/LayoutTests/fast/dom/Window/post-message-user-action-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomWindowpostmessageuseractionhtml">trunk/LayoutTests/fast/dom/Window/post-message-user-action.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (200907 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-05-14 02:10:27 UTC (rev 200907)
+++ trunk/LayoutTests/ChangeLog        2016-05-14 02:17:31 UTC (rev 200908)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-05-13  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        ScriptController::processingUserGesture should propagate across postMessage boundaries
+        &lt;rdar://problem/26273173&gt;
+        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.
+
</ins><span class="cx"> 2016-05-13  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Align window.scroll() / scrollTo() / scrollBy() with the CSSOM specification
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomWindowpostmessageuseractionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Window/post-message-user-action-expected.txt (0 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+Test that the processing user gesture bit is maintained through postMessage.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomWindowpostmessageuseractionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/Window/post-message-user-action.html (0 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta charset=&quot;utf-8&quot;&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;button id=&quot;clicker&quot; onclick=&quot;go()&quot;&gt;Click&lt;/button&gt;
+&lt;script&gt;
+
+description(&quot;Test that the processing user gesture bit is maintained through postMessage.&quot;);
+
+window.jsTestIsAsync = true;
+
+function go()
+{
+    debug(&quot;Testing that isProcessingUserGesture() is true in response to a click.&quot;)
+    shouldBeTrue(&quot;window.internals.isProcessingUserGesture()&quot;);
+    window.postMessage(&quot;go&quot;, &quot;*&quot;);
+}
+
+window.onmessage = function(evt)
+{
+    if (evt.data == &quot;go&quot;) {
+        if (window.internals) {
+            debug(&quot;Testing that isProcessingUserGesture() is true after processing a postMessage.&quot;)
+            shouldBeTrue(&quot;window.internals.isProcessingUserGesture()&quot;);
+        }
+        finishJSTest();
+    }
+}
+
+debug(&quot;Testing that isProcessingUserGesture() is false on load.&quot;)
+shouldBeFalse(&quot;window.internals.isProcessingUserGesture()&quot;);
+
+if (window.eventSender) {
+    var element = document.getElementById('clicker');
+    eventSender.mouseMoveTo(element.offsetLeft + 5, element.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (200907 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1842,6 +1842,7 @@
</span><span class="cx"> # eventSender.mouseDown is not implemented
</span><span class="cx"> fast/loader/location-hash-user-gesture.html [ Skip ]
</span><span class="cx"> imported/blink/editing/selection/selectstart-event-crash.html [ Skip ]
</span><ins>+fast/dom/Window/post-message-user-action.html [ Skip ]
</ins><span class="cx"> 
</span><span class="cx"> # No touch events
</span><span class="cx"> http/tests/contentdispositionattachmentsandbox/referer-header-stripped-with-meta-referer-always.html [ Skip ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200907 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-05-13  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        ScriptController::processingUserGesture should propagate across postMessage boundaries
+        &lt;rdar://problem/26273173&gt;
+        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.
+
</ins><span class="cx"> 2016-05-13  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Align window.scroll() / scrollTo() / scrollBy() with the CSSOM specification
</span></span></pre></div>
<a id="trunkSourceWebCoredomUserGestureIndicatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/UserGestureIndicator.h (200907 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> class UserGestureIndicator {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
</span><span class="cx"> public:
</span><del>-    static bool processingUserGesture();
</del><ins>+    WEBCORE_EXPORT static bool processingUserGesture();
</ins><span class="cx">     static bool processingUserGestureForMedia();
</span><span class="cx"> 
</span><span class="cx">     // If a document is provided, its last known user gesture timestamp is updated.
</span></span></pre></div>
<a id="trunkSourceWebCorepageDOMWindowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DOMWindow.cpp (200907 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -97,6 +97,7 @@
</span><span class="cx"> #include &quot;StyleResolver.h&quot;
</span><span class="cx"> #include &quot;SuddenTermination.h&quot;
</span><span class="cx"> #include &quot;URL.h&quot;
</span><ins>+#include &quot;UserGestureIndicator.h&quot;
</ins><span class="cx"> #include &quot;WebKitPoint.h&quot;
</span><span class="cx"> #include &quot;WindowFeatures.h&quot;
</span><span class="cx"> #include &quot;WindowFocusAllowedIndicator.h&quot;
</span><span class="lines">@@ -152,6 +153,7 @@
</span><span class="cx">         , m_channels(WTFMove(channels))
</span><span class="cx">         , m_targetOrigin(WTFMove(targetOrigin))
</span><span class="cx">         , m_stackTrace(stackTrace)
</span><ins>+        , m_wasProcessingUserGesture(UserGestureIndicator::processingUserGesture())
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -159,6 +161,7 @@
</span><span class="cx">     {
</span><span class="cx">         return MessageEvent::create(MessagePort::entanglePorts(context, WTFMove(m_channels)), WTFMove(m_message), m_origin, { }, m_source.ptr());
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); }
</span><span class="cx">     ScriptCallStack* stackTrace() const { return m_stackTrace.get(); }
</span><span class="cx"> 
</span><span class="lines">@@ -167,6 +170,8 @@
</span><span class="cx">     {
</span><span class="cx">         // This object gets deleted when std::unique_ptr falls out of scope..
</span><span class="cx">         std::unique_ptr&lt;PostMessageTimer&gt; timer(this);
</span><ins>+        
+        UserGestureIndicator userGestureIndicator(m_wasProcessingUserGesture ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
</ins><span class="cx">         m_window-&gt;postMessageTimerFired(*timer);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -177,6 +182,7 @@
</span><span class="cx">     std::unique_ptr&lt;MessagePortChannelArray&gt; m_channels;
</span><span class="cx">     RefPtr&lt;SecurityOrigin&gt; m_targetOrigin;
</span><span class="cx">     RefPtr&lt;ScriptCallStack&gt; m_stackTrace;
</span><ins>+    bool m_wasProcessingUserGesture;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef HashCountedSet&lt;DOMWindow*&gt; DOMWindowSet;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (200907 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -119,6 +119,7 @@
</span><span class="cx"> #include &quot;TextIterator.h&quot;
</span><span class="cx"> #include &quot;TreeScope.h&quot;
</span><span class="cx"> #include &quot;TypeConversions.h&quot;
</span><ins>+#include &quot;UserGestureIndicator.h&quot;
</ins><span class="cx"> #include &quot;UserMediaController.h&quot;
</span><span class="cx"> #include &quot;ViewportArguments.h&quot;
</span><span class="cx"> #include &quot;WebCoreJSClientData.h&quot;
</span><span class="lines">@@ -3333,4 +3334,9 @@
</span><span class="cx">     RuntimeEnabledFeatures::sharedFeatures().setResourceTimingEnabled(enable);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Internals::isProcessingUserGesture()
+{
+    return UserGestureIndicator::processingUserGesture();
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (200907 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -483,6 +483,8 @@
</span><span class="cx">     void setWebGL2Enabled(bool);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    bool isProcessingUserGesture();
+
</ins><span class="cx"> private:
</span><span class="cx">     explicit Internals(Document&amp;);
</span><span class="cx">     Document* contextDocument() const;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (200907 => 200908)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -459,4 +459,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     void setResourceTimingSupport(boolean scalable);
</span><ins>+    
+    boolean isProcessingUserGesture();
</ins><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>