<!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>[189392] 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/189392">189392</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-09-04 15:09:57 -0700 (Fri, 04 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add a test for <a href="http://trac.webkit.org/projects/webkit/changeset/179736">r179736</a> (programmatic navigation during swipe causing a crash)
https://bugs.webkit.org/show_bug.cgi?id=148830

Reviewed by Beth Dakin.

* swipe/basic-cached-back-swipe.html:
* swipe/pushState-cached-back-swipe.html:
* swipe/resources/swipe-test.js:
(eventQueue.callAfterEventDispatch):
(initializeSwipeTest):
(initializeLog): Deleted.
* swipe/swipe-start-hysteresis-failures.html:
Refactor some things.
Make sure that we reset the back forward list before testing, because we expect
to start at the &quot;first&quot; item, but there is actually a about:blank before us.

* swipe/pushState-programmatic-back-while-swiping-crash-expected.txt: Added.
* swipe/pushState-programmatic-back-while-swiping-crash.html: Added.
Add a test that ensures that <a href="http://trac.webkit.org/projects/webkit/changeset/179736">r179736</a> does not recur.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::beginTesting):
Make sure that TestRunner callbacks don't leak between tests!</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsswipebasiccachedbackswipehtml">trunk/LayoutTests/swipe/basic-cached-back-swipe.html</a></li>
<li><a href="#trunkLayoutTestsswipepushStatecachedbackswipehtml">trunk/LayoutTests/swipe/pushState-cached-back-swipe.html</a></li>
<li><a href="#trunkLayoutTestsswiperesourcesswipetestjs">trunk/LayoutTests/swipe/resources/swipe-test.js</a></li>
<li><a href="#trunkLayoutTestsswipeswipestarthysteresisfailureshtml">trunk/LayoutTests/swipe/swipe-start-hysteresis-failures.html</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlecpp">trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsswipepushStateprogrammaticbackwhileswipingcrashexpectedtxt">trunk/LayoutTests/swipe/pushState-programmatic-back-while-swiping-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestsswipepushStateprogrammaticbackwhileswipingcrashhtml">trunk/LayoutTests/swipe/pushState-programmatic-back-while-swiping-crash.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (189391 => 189392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-09-04 22:08:28 UTC (rev 189391)
+++ trunk/LayoutTests/ChangeLog        2015-09-04 22:09:57 UTC (rev 189392)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2015-09-04  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Add a test for r179736 (programmatic navigation during swipe causing a crash)
+        https://bugs.webkit.org/show_bug.cgi?id=148830
+
+        Reviewed by Beth Dakin.
+
+        * swipe/basic-cached-back-swipe.html:
+        * swipe/pushState-cached-back-swipe.html:
+        * swipe/resources/swipe-test.js:
+        (eventQueue.callAfterEventDispatch):
+        (initializeSwipeTest):
+        (initializeLog): Deleted.
+        * swipe/swipe-start-hysteresis-failures.html:
+        Refactor some things.
+        Make sure that we reset the back forward list before testing, because we expect
+        to start at the &quot;first&quot; item, but there is actually a about:blank before us.
+
+        * swipe/pushState-programmatic-back-while-swiping-crash-expected.txt: Added.
+        * swipe/pushState-programmatic-back-while-swiping-crash.html: Added.
+        Add a test that ensures that r179736 does not recur.
+
</ins><span class="cx"> 2015-09-04  Beth Dakin  &lt;bdakin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Should have a test for selection behavior when force clicking text
</span></span></pre></div>
<a id="trunkLayoutTestsswipebasiccachedbackswipehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/swipe/basic-cached-back-swipe.html (189391 => 189392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/swipe/basic-cached-back-swipe.html        2015-09-04 22:08:28 UTC (rev 189391)
+++ trunk/LayoutTests/swipe/basic-cached-back-swipe.html        2015-09-04 22:09:57 UTC (rev 189392)
</span><span class="lines">@@ -70,10 +70,8 @@
</span><span class="cx">     document.body.innerHTML = isFirstPage() ? &quot;first&quot; : &quot;second&quot;;
</span><span class="cx"> 
</span><span class="cx">     if (isFirstPage()) {
</span><del>-        initializeLog();
</del><ins>+        initializeSwipeTest();
</ins><span class="cx"> 
</span><del>-        testRunner.setNavigationGesturesEnabled(true);
-
</del><span class="cx">         testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
</span><span class="cx">         testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
</span><span class="cx">         testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
</span></span></pre></div>
<a id="trunkLayoutTestsswipepushStatecachedbackswipehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/swipe/pushState-cached-back-swipe.html (189391 => 189392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/swipe/pushState-cached-back-swipe.html        2015-09-04 22:08:28 UTC (rev 189391)
+++ trunk/LayoutTests/swipe/pushState-cached-back-swipe.html        2015-09-04 22:09:57 UTC (rev 189392)
</span><span class="lines">@@ -74,10 +74,8 @@
</span><span class="cx"> 
</span><span class="cx">     updateContent();
</span><span class="cx"> 
</span><del>-    initializeLog();
</del><ins>+    initializeSwipeTest();
</ins><span class="cx"> 
</span><del>-    testRunner.setNavigationGesturesEnabled(true);
-
</del><span class="cx">     testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
</span><span class="cx">     testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
</span><span class="cx">     testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
</span></span></pre></div>
<a id="trunkLayoutTestsswipepushStateprogrammaticbackwhileswipingcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/swipe/pushState-programmatic-back-while-swiping-crash-expected.txt (0 => 189392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/swipe/pushState-programmatic-back-while-swiping-crash-expected.txt                                (rev 0)
+++ trunk/LayoutTests/swipe/pushState-programmatic-back-while-swiping-crash-expected.txt        2015-09-04 22:09:57 UTC (rev 189392)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+swipe event (delta 0 0, phase 'maybegin')
+scroll event (delta 1 0, phase 'began')
+scroll event (delta 1 0, phase 'changed')
+swipe event (delta 1 0, phase 'changed')
+swipe event (delta 256 0, phase 'changed')
+swipe event (delta 0 0, phase 'ended')
+
</ins></span></pre></div>
<a id="trunkLayoutTestsswipepushStateprogrammaticbackwhileswipingcrashhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/swipe/pushState-programmatic-back-while-swiping-crash.html (0 => 189392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/swipe/pushState-programmatic-back-while-swiping-crash.html                                (rev 0)
+++ trunk/LayoutTests/swipe/pushState-programmatic-back-while-swiping-crash.html        2015-09-04 22:09:57 UTC (rev 189392)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+&lt;head&gt;
+&lt;style&gt;
+html {
+    font-size: 32pt;
+}
+&lt;/style&gt;
+&lt;script src=&quot;resources/swipe-test.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function startSwipeGesture()
+{
+    eventSender.mouseMoveTo(100, 100);
+
+    eventQueue.enqueueSwipeEvent(0, 0, 'maybegin');
+    eventQueue.enqueueScrollEvent(1, 0, 'began');
+    
+    eventQueue.callAfterEventDispatch(goBack);
+}
+
+function goBack()
+{
+    window.history.back();
+
+    eventQueue.callAfterEventDispatch(continueSwipeGesture);
+}
+
+function continueSwipeGesture()
+{
+    eventQueue.enqueueScrollEvent(1, 0, 'changed');
+
+    eventQueue.callAfterEventDispatch(completeSwipeGesture);
+}
+
+function completeSwipeGesture()
+{
+    eventQueue.enqueueSwipeEvent(1, 0, 'changed');
+    eventQueue.enqueueSwipeEvent(256, 0, 'changed');
+    eventQueue.enqueueSwipeEvent(0, 0, 'ended');
+
+    eventQueue.callAfterEventDispatch(testComplete);
+}
+
+function didBeginSwipeCallback()
+{
+    log(&quot;Failed. Should not begin swipe; we've already navigated away from the item where the swipe started, and there is no other back item.&quot;);
+}
+
+function isFirstPage()
+{
+    return window.location.href.indexOf(&quot;second&quot;) == -1;
+}
+
+function updateContent()
+{
+    document.body.innerHTML = isFirstPage() ? &quot;first&quot; : &quot;second&quot;;
+}
+
+window.onload = function () {
+    if (!window.eventSender || !window.testRunner) {
+        document.body.innerHTML = &quot;This test must be run in WebKitTestRunner.&quot;;
+        return;
+    }
+
+    updateContent();
+
+    initializeSwipeTest();
+
+    testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
+
+    testRunner.overridePreference(&quot;WebKitUsesPageCachePreferenceKey&quot;, 1);
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+
+    window.addEventListener(&quot;popstate&quot;, function(e) {
+        updateContent();
+    });
+
+    setTimeout(function () { 
+        history.pushState(null, null, &quot;/second&quot;);
+        updateContent();
+
+        setTimeout(function () {
+            startSwipeGesture();
+        }, 0);
+    }, 0);
+};
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;/body&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsswiperesourcesswipetestjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/swipe/resources/swipe-test.js (189391 => 189392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/swipe/resources/swipe-test.js        2015-09-04 22:08:28 UTC (rev 189391)
+++ trunk/LayoutTests/swipe/resources/swipe-test.js        2015-09-04 22:09:57 UTC (rev 189392)
</span><span class="lines">@@ -19,6 +19,15 @@
</span><span class="cx">         return this._queue.length != 0;
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    callAfterEventDispatch: function (callback) {
+        var interval = setInterval(function () { 
+        if (!eventQueue.hasPendingEvents()) {
+            clearInterval(interval);
+            callback();
+        }
+    }, 0);
+    },
+
</ins><span class="cx">     _queue: [],
</span><span class="cx"> 
</span><span class="cx">     _processEventQueue: function () {
</span><span class="lines">@@ -58,9 +67,11 @@
</span><span class="cx">     window.testRunner.notifyDone();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function initializeLog()
</del><ins>+function initializeSwipeTest()
</ins><span class="cx"> {
</span><span class="cx">     window.localStorage[&quot;swipeLogging&quot;] = &quot;&quot;;
</span><ins>+    testRunner.setNavigationGesturesEnabled(true);
+    testRunner.clearBackForwardList();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function startMeasuringDuration(key)
</span></span></pre></div>
<a id="trunkLayoutTestsswipeswipestarthysteresisfailureshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/swipe/swipe-start-hysteresis-failures.html (189391 => 189392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/swipe/swipe-start-hysteresis-failures.html        2015-09-04 22:08:28 UTC (rev 189391)
+++ trunk/LayoutTests/swipe/swipe-start-hysteresis-failures.html        2015-09-04 22:09:57 UTC (rev 189392)
</span><span class="lines">@@ -16,7 +16,7 @@
</span><span class="cx">     eventQueue.enqueueScrollEvent(0, 0, 'changed');
</span><span class="cx">     eventQueue.enqueueScrollEvent(0, 0, 'ended');
</span><span class="cx"> 
</span><del>-    waitForEventDispatch(doDiagonalSwipeGesture);
</del><ins>+    eventQueue.callAfterEventDispatch(doDiagonalSwipeGesture);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function doDiagonalSwipeGesture()
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx">     eventQueue.enqueueScrollEvent(0, 0, 'changed');
</span><span class="cx">     eventQueue.enqueueScrollEvent(0, 0, 'ended');
</span><span class="cx"> 
</span><del>-    waitForEventDispatch(doVerticalSwipeGesture);
</del><ins>+    eventQueue.callAfterEventDispatch(doVerticalSwipeGesture);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function doVerticalSwipeGesture()
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx">     eventQueue.enqueueScrollEvent(0, 0, 'changed');
</span><span class="cx">     eventQueue.enqueueScrollEvent(0, 0, 'ended');
</span><span class="cx"> 
</span><del>-    waitForEventDispatch(doHorizontalThenVerticalSwipeGesture);
</del><ins>+    eventQueue.callAfterEventDispatch(doHorizontalThenVerticalSwipeGesture);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function doHorizontalThenVerticalSwipeGesture()
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">     eventQueue.enqueueScrollEvent(0, 2, 'changed');
</span><span class="cx">     eventQueue.enqueueScrollEvent(0, 0, 'ended');
</span><span class="cx"> 
</span><del>-    waitForEventDispatch(doRegularSwipeGesture);
</del><ins>+    eventQueue.callAfterEventDispatch(doRegularSwipeGesture);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function doRegularSwipeGesture()
</span><span class="lines">@@ -78,16 +78,6 @@
</span><span class="cx">     eventQueue.enqueueScrollEvent(0, 0, 'ended');
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function waitForEventDispatch(callback)
-{
-    var interval = setInterval(function () { 
-        if (!eventQueue.hasPendingEvents()) {
-            clearInterval(interval);
-            callback();
-        }
-    }, 0);
-}
-
</del><span class="cx"> function didBeginSwipeNotReachedCallback()
</span><span class="cx"> {
</span><span class="cx">     log(&quot;Failure. Should never begin a swipe, because all of the attempted swipes should fail due to the swipe-start hysteresis.&quot;);
</span><span class="lines">@@ -107,10 +97,8 @@
</span><span class="cx">     document.body.innerHTML = isFirstPage() ? &quot;first&quot; : &quot;second&quot;;
</span><span class="cx"> 
</span><span class="cx">     if (isFirstPage()) {
</span><del>-        initializeLog();
</del><ins>+        initializeSwipeTest();
</ins><span class="cx"> 
</span><del>-        testRunner.setNavigationGesturesEnabled(true);
-
</del><span class="cx">         testRunner.installDidBeginSwipeCallback(didBeginSwipeNotReachedCallback);
</span><span class="cx"> 
</span><span class="cx">         testRunner.overridePreference(&quot;WebKitUsesPageCachePreferenceKey&quot;, 1);
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (189391 => 189392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-09-04 22:08:28 UTC (rev 189391)
+++ trunk/Tools/ChangeLog        2015-09-04 22:09:57 UTC (rev 189392)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-09-04  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Add a test for r179736 (programmatic navigation during swipe causing a crash)
+        https://bugs.webkit.org/show_bug.cgi?id=148830
+
+        Reviewed by Beth Dakin.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::beginTesting):
+        Make sure that TestRunner callbacks don't leak between tests!
+
</ins><span class="cx"> 2015-09-04  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         It should be possible to pass relative HTTP test paths to DumpRenderTree
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerInjectedBundleInjectedBundlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (189391 => 189392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp        2015-09-04 22:08:28 UTC (rev 189391)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp        2015-09-04 22:09:57 UTC (rev 189392)
</span><span class="lines">@@ -289,6 +289,7 @@
</span><span class="cx">     m_testRunner-&gt;setCloseRemainingWindowsWhenComplete(false);
</span><span class="cx">     m_testRunner-&gt;setAcceptsEditing(true);
</span><span class="cx">     m_testRunner-&gt;setTabKeyCyclesThroughElements(true);
</span><ins>+    m_testRunner-&gt;clearTestRunnerCallbacks();
</ins><span class="cx"> 
</span><span class="cx">     if (m_timeout &gt; 0)
</span><span class="cx">         m_testRunner-&gt;setCustomTimeout(m_timeout);
</span></span></pre>
</div>
</div>

</body>
</html>