Flaky Test: fast/events/resize-subframe-in-rendering-update.html
[WebKit-https.git] / LayoutTests / swipe / pushState-cached-back-swipe.html
1 <!-- webkit-test-runner [ enableBackForwardCache=true ] -->
2 <head>
3 <style>
4 html {
5     font-size: 32pt;
6 }
7 </style>
8 <script src="resources/swipe-test.js"></script>
9 <script>
10
11 function didBeginSwipeCallback()
12 {
13     log("didBeginSwipe");
14
15     completeSwipeGesture();
16 }
17
18 function willEndSwipeCallback()
19 {
20     log("willEndSwipe");
21
22     shouldBe(false, isFirstPage(), "The swipe should not yet have navigated away from the second page.");
23 }
24
25 function didEndSwipeCallback()
26 {
27     log("didEndSwipe");
28
29     startMeasuringDuration("snapshotRemoval");
30 }
31
32 function didRemoveSwipeSnapshotCallback()
33 {
34     log("didRemoveSwipeSnapshot");
35     
36     shouldBe(true, isFirstPage(), "The swipe should have navigated back to the first page.");
37     measuredDurationShouldBeLessThan("snapshotRemoval", 1000, "Because we're using the page cache, it shouldn't be long between the gesture completing and the snapshot being removed.")
38
39     testComplete();
40 }
41
42 function isFirstPage()
43 {
44     return window.location.href.indexOf("second") == -1;
45 }
46
47 function updateContent()
48 {
49     document.body.innerHTML = isFirstPage() ? "first" : "second";
50 }
51
52 window.onload = function () {
53     if (!window.eventSender || !window.testRunner) {
54         document.body.innerHTML = "This test must be run in WebKitTestRunner.";
55         return;
56     }
57
58     updateContent();
59
60     initializeSwipeTest();
61
62     testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
63     testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
64     testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
65     testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);
66
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>