swipe-start-hysteresis-failures is flaky
[WebKit-https.git] / LayoutTests / swipe / basic-cached-back-swipe.html
1 <head>
2 <style>
3 html {
4     font-size: 32pt;
5 }
6 </style>
7 <script src="resources/swipe-test.js"></script>
8 <script>
9 function startSwipeGesture()
10 {
11     eventSender.mouseMoveTo(100, 100);
12
13     eventQueue.enqueueSwipeEvent(0, 0, 'maybegin');
14     eventQueue.enqueueScrollEvent(1, 0, 'began');
15     eventQueue.enqueueScrollEvent(1, 0, 'changed');
16 }
17
18 function completeSwipeGesture()
19 {
20     eventQueue.enqueueSwipeEvent(1, 0, 'changed');
21     eventQueue.enqueueSwipeEvent(256, 0, 'changed');
22     eventQueue.enqueueSwipeEvent(0, 0, 'ended');
23 }
24
25 function didBeginSwipeCallback()
26 {
27     log("didBeginSwipe");
28
29     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.");
30
31     completeSwipeGesture();
32 }
33
34 function willEndSwipeCallback()
35 {
36     log("willEndSwipe");
37
38     shouldBe(false, isFirstPage(), "The swipe should not yet have navigated away from the second page.");
39 }
40
41 function didEndSwipeCallback()
42 {
43     log("didEndSwipe");
44
45     shouldBe(0, eventQueue.hasPendingEvents(), "Event queue should be empty. The swipe isn't complete until we see the end of the gesture.");
46     startMeasuringDuration("snapshotRemoval");
47 }
48
49 function didRemoveSwipeSnapshotCallback()
50 {
51     log("didRemoveSwipeSnapshot");
52     
53     shouldBe(true, isFirstPage(), "The swipe should have navigated back to the first page.");
54     measuredDurationShouldBeLessThan("snapshotRemoval", 1000, "Because we're using the page cache, it shouldn't be long between the gesture completing and the snapshot being removed.")
55
56     testComplete();
57 }
58
59 function isFirstPage()
60 {
61     return window.location.href.indexOf("second") == -1;
62 }
63
64 window.onload = function () {
65     if (!window.eventSender || !window.testRunner) {
66         document.body.innerHTML = "This test must be run in WebKitTestRunner.";
67         return;
68     }
69
70     document.body.innerHTML = isFirstPage() ? "first" : "second";
71
72     if (isFirstPage()) {
73         initializeLog();
74
75         testRunner.setNavigationGesturesEnabled(true);
76
77         testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
78         testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
79         testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
80         testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);
81
82         testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
83         testRunner.dumpAsText();
84         testRunner.waitUntilDone();
85
86         setTimeout(function () { 
87             window.location.href = window.location.href + "?second";
88         }, 0);
89         return;
90     }
91
92     startSwipeGesture();
93 };
94 </script>
95 </head>
96 <body>
97 </body>