Title: [189290] trunk/LayoutTests
Revision
189290
Author
[email protected]
Date
2015-09-03 14:51:41 -0700 (Thu, 03 Sep 2015)

Log Message

Add a test for swiping back after a same-document navigation
https://bugs.webkit.org/show_bug.cgi?id=148751

Reviewed by Beth Dakin.

* swipe/pushState-cached-back-swipe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (189289 => 189290)


--- trunk/LayoutTests/ChangeLog	2015-09-03 21:48:27 UTC (rev 189289)
+++ trunk/LayoutTests/ChangeLog	2015-09-03 21:51:41 UTC (rev 189290)
@@ -1,3 +1,12 @@
+2015-09-03  Tim Horton  <[email protected]>
+
+        Add a test for swiping back after a same-document navigation
+        https://bugs.webkit.org/show_bug.cgi?id=148751
+
+        Reviewed by Beth Dakin.
+
+        * swipe/pushState-cached-back-swipe.html: Added.
+
 2015-09-03  Andy Estes  <[email protected]>
 
         REGRESSION: http/tests/contentfiltering/block-after-redirect.html is flaky

Added: trunk/LayoutTests/swipe/pushState-cached-back-swipe-expected.txt (0 => 189290)


--- trunk/LayoutTests/swipe/pushState-cached-back-swipe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/swipe/pushState-cached-back-swipe-expected.txt	2015-09-03 21:51:41 UTC (rev 189290)
@@ -0,0 +1,11 @@
+swipe event (delta 0 0, phase 'maybegin')
+scroll event (delta 1 0, phase 'began')
+scroll event (delta 1 0, phase 'changed')
+didBeginSwipe
+swipe event (delta 1 0, phase 'changed')
+swipe event (delta 256 0, phase 'changed')
+swipe event (delta 0 0, phase 'ended')
+willEndSwipe
+didEndSwipe
+didRemoveSwipeSnapshot
+

Added: trunk/LayoutTests/swipe/pushState-cached-back-swipe.html (0 => 189290)


--- trunk/LayoutTests/swipe/pushState-cached-back-swipe.html	                        (rev 0)
+++ trunk/LayoutTests/swipe/pushState-cached-back-swipe.html	2015-09-03 21:51:41 UTC (rev 189290)
@@ -0,0 +1,107 @@
+<head>
+<style>
+html {
+    font-size: 32pt;
+}
+</style>
+<script src=""
+<script>
+function startSwipeGesture()
+{
+    eventSender.mouseMoveTo(100, 100);
+
+    eventQueue.enqueueSwipeEvent(0, 0, 'maybegin');
+    eventQueue.enqueueScrollEvent(1, 0, 'began');
+    eventQueue.enqueueScrollEvent(1, 0, 'changed');
+}
+
+function completeSwipeGesture()
+{
+    eventQueue.enqueueSwipeEvent(1, 0, 'changed');
+    eventQueue.enqueueSwipeEvent(256, 0, 'changed');
+    eventQueue.enqueueSwipeEvent(0, 0, 'ended');
+}
+
+function didBeginSwipeCallback()
+{
+    log("didBeginSwipe");
+
+    shouldBe(false, eventQueue.hasPendingEvents(), "Event queue should be empty. Both scroll events should be required to start the swipe because of the swipe-start hysteresis.");
+
+    completeSwipeGesture();
+}
+
+function willEndSwipeCallback()
+{
+    log("willEndSwipe");
+
+    shouldBe(false, isFirstPage(), "The swipe should not yet have navigated away from the second page.");
+}
+
+function didEndSwipeCallback()
+{
+    log("didEndSwipe");
+
+    shouldBe(0, eventQueue.hasPendingEvents(), "Event queue should be empty. The swipe isn't complete until we see the end of the gesture.");
+    startMeasuringDuration("snapshotRemoval");
+}
+
+function didRemoveSwipeSnapshotCallback()
+{
+    log("didRemoveSwipeSnapshot");
+    
+    shouldBe(true, isFirstPage(), "The swipe should have navigated back to the first page.");
+    measuredDurationShouldBeLessThan("snapshotRemoval", 1000, "Because we're using the page cache, it shouldn't be long between the gesture completing and the snapshot being removed.")
+
+    dumpLog();
+    testRunner.notifyDone();
+}
+
+function isFirstPage()
+{
+    return window.location.href.indexOf("second") == -1;
+}
+
+function updateContent()
+{
+    document.body.innerHTML = isFirstPage() ? "first" : "second";
+}
+
+window._onload_ = function () {
+    if (!window.eventSender || !window.testRunner) {
+        document.body.innerHTML = "This test must be run in WebKitTestRunner.";
+        return;
+    }
+
+    updateContent();
+
+    initializeLog();
+
+    testRunner.setNavigationGesturesEnabled(true);
+
+    testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
+    testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
+    testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
+    testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);
+
+    testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+
+    window.addEventListener("popstate", function(e) {
+        updateContent();
+    });
+
+    setTimeout(function () { 
+        history.pushState(null, null, "/second");
+        updateContent();
+
+        setTimeout(function () {
+            startSwipeGesture();
+        }, 0);
+    }, 0);
+};
+</script>
+</head>
+<body>
+</body>
\ No newline at end of file
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to