media/W3C/video/events/event_progress_manual.html is a flaky failure
[WebKit-https.git] / LayoutTests / swipe / pushState-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
10 function didBeginSwipeCallback()
11 {
12     log("didBeginSwipe");
13
14     completeSwipeGesture();
15 }
16
17 function willEndSwipeCallback()
18 {
19     log("willEndSwipe");
20
21     shouldBe(false, isFirstPage(), "The swipe should not yet have navigated away from the second page.");
22 }
23
24 function didEndSwipeCallback()
25 {
26     log("didEndSwipe");
27
28     startMeasuringDuration("snapshotRemoval");
29 }
30
31 function didRemoveSwipeSnapshotCallback()
32 {
33     log("didRemoveSwipeSnapshot");
34     
35     shouldBe(true, isFirstPage(), "The swipe should have navigated back to the first page.");
36     measuredDurationShouldBeLessThan("snapshotRemoval", 1000, "Because we're using the page cache, it shouldn't be long between the gesture completing and the snapshot being removed.")
37
38     testComplete();
39 }
40
41 function isFirstPage()
42 {
43     return window.location.href.indexOf("second") == -1;
44 }
45
46 function updateContent()
47 {
48     document.body.innerHTML = isFirstPage() ? "first" : "second";
49 }
50
51 window.onload = function () {
52     if (!window.eventSender || !window.testRunner) {
53         document.body.innerHTML = "This test must be run in WebKitTestRunner.";
54         return;
55     }
56
57     updateContent();
58
59     initializeSwipeTest();
60
61     testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
62     testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
63     testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
64     testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);
65
66     testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
67     testRunner.dumpAsText();
68     testRunner.waitUntilDone();
69
70     window.addEventListener("popstate", function(e) {
71         updateContent();
72     });
73
74     setTimeout(function () { 
75         history.pushState(null, null, "/second");
76         updateContent();
77
78         setTimeout(function () {
79             startSwipeGesture();
80         }, 0);
81     }, 0);
82 };
83 </script>
84 </head>
85 <body>
86 </body>