Unreviewed, speculative fix for build failure
[WebKit-https.git] / LayoutTests / swipe / main-frame-pinning-requirement.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 runTest()
11 {
12     // The first swipe should fail because we're scrolled to the middle of the document
13     // and this is all a single gesture. We can only start swipes if we *begin*
14     // pinned to the edge.
15     startSwipeGesture(function () {
16         completeSwipeGesture(function () {
17             testRunner.clearTestRunnerCallbacks();
18             testRunner.installDidBeginSwipeCallback(didBeginSwipeCallback);
19             testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
20             testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
21             testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);    
22
23             // The second swipe should succeed because we are now scrolled to the left edge.
24             startSwipeGesture(function () { completeSwipeGesture(); });
25         });
26     });
27 }
28
29 function didBeginSwipeNotReachedCallback()
30 {
31     log("Failure. Should never begin a swipe, because we were in the middle of a scrolling gesture that started when the main frame was not pinned to the left.");
32 }
33
34 function didBeginSwipeCallback()
35 {
36     log("didBeginSwipe");
37 }
38
39 function willEndSwipeCallback()
40 {
41     log("willEndSwipe");
42
43     shouldBe(false, isFirstPage(), "The swipe should not yet have navigated away from the second page.");
44 }
45
46 function didEndSwipeCallback()
47 {
48     log("didEndSwipe");
49
50     startMeasuringDuration("snapshotRemoval");
51 }
52
53 function didRemoveSwipeSnapshotCallback()
54 {
55     log("didRemoveSwipeSnapshot");
56
57     shouldBe(true, isFirstPage(), "The swipe should have navigated back to the first page.");
58     measuredDurationShouldBeLessThan("snapshotRemoval", 1000, "Because we're using the page cache, it shouldn't be long between the gesture completing and the snapshot being removed.")
59
60     testComplete();
61 }
62
63 function isFirstPage()
64 {
65     return window.location.href.indexOf("second") == -1;
66 }
67
68 window.onload = function () {
69     if (!window.eventSender || !window.testRunner) {
70         document.getElementById("large").innerHTML = "This test must be run in WebKitTestRunner.";
71         return;
72     }
73
74     document.getElementById("large").innerHTML = isFirstPage() ? "first" : "second";
75
76     if (isFirstPage()) {
77         initializeSwipeTest();
78
79         testRunner.installDidBeginSwipeCallback(didBeginSwipeNotReachedCallback);
80         testRunner.installWillEndSwipeCallback(willEndSwipeCallback);
81         testRunner.installDidEndSwipeCallback(didEndSwipeCallback);
82         testRunner.installDidRemoveSwipeSnapshotCallback(didRemoveSwipeSnapshotCallback);
83
84         testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
85         testRunner.dumpAsText();
86         testRunner.waitUntilDone();
87
88         setTimeout(function () {
89             window.location.href = window.location.href + "?second";
90         }, 0);
91         return;
92     }
93
94     // Second page loaded.
95     window.scrollTo(100, 0);
96
97     runTest();
98 };
99 </script>
100 </head>
101 <body>
102 <div id="large" style="width: 2000px; height: 2000px;"></div>
103 </body>