Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1156)

Side by Side Diff: LayoutTests/fast/events/page-visibility-transition-test.html

Issue 7121007: Merge 88174 - 2011-06-06 Shishir Agrawal <shishir@chromium.org> (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/events/page-visibility-transition-test-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <body onload='startTest()'> 2 <body onload='startTest()'>
3 3
4 <p id="description"></p> 4 <p id="description"></p>
5 <div id="console"></div> 5 <div id="console"></div>
6 6
7 <script src="../js/resources/js-test-pre.js"></script> 7 <script src="../js/resources/js-test-pre.js"></script>
8 8
9 <script> 9 <script>
10 10
11 description("This test checks that Page Visibility state values are correct and the event changes are fired correctly."); 11 description("This test checks that Page Visibility state values are correct and the event changes are fired correctly.");
12 12
13 var jsTestIsAsync = true; 13 var jsTestIsAsync = true;
14 14
15 function makePageVisible() { 15 function makePageVisible() {
16 if (window.layoutTestController) 16 if (window.layoutTestController)
17 layoutTestController.setPageVisibility("visible"); 17 layoutTestController.setPageVisibility("visible");
18 } 18 }
19 19
20 function makePageHidden() { 20 function makePageHidden() {
21 if (window.layoutTestController) 21 if (window.layoutTestController)
22 layoutTestController.setPageVisibility("hidden"); 22 layoutTestController.setPageVisibility("hidden");
23 } 23 }
24 24
25 function makePagePrerender() {
26 if (window.layoutTestController)
27 layoutTestController.setPageVisibility("prerender");
28 }
29
25 function checkIsPageVisible() { 30 function checkIsPageVisible() {
26 shouldBeEqualToString("document.webkitVisibilityState", "visible"); 31 shouldBeEqualToString("document.webkitVisibilityState", "visible");
27 shouldBeFalse("document.webkitHidden"); 32 shouldBeFalse("document.webkitHidden");
28 } 33 }
29 34
30 function checkIsPageHidden() { 35 function checkIsPageHidden() {
31 shouldBeEqualToString("document.webkitVisibilityState", "hidden"); 36 shouldBeEqualToString("document.webkitVisibilityState", "hidden");
32 shouldBeTrue("document.webkitHidden"); 37 shouldBeTrue("document.webkitHidden");
33 } 38 }
34 39
40 function checkIsPagePrerendering() {
41 shouldBeEqualToString("document.webkitVisibilityState", "prerender");
42 shouldBeTrue("document.webkitHidden");
43 }
44
35 // We will try to change the visibility states as: 45 // We will try to change the visibility states as:
36 // 0 - visible. (Initial - i.e. on load). 46 // 0 - visible. (Initial - i.e. on load).
37 // 1 - hidden (should fire event). 47 // 1 - hidden (should fire event).
38 // 2 - hidden (no event). 48 // 2 - hidden (no event).
39 // 3 - visible (should fire event). 49 // 3 - prerender (should fire event).
50 // 4 - visible (should fire event).
40 var numVisibilityChanges = 0; 51 var numVisibilityChanges = 0;
41 52
42 function startTest() { 53 function startTest() {
43 document.addEventListener( 54 document.addEventListener(
44 "webkitvisibilitychange", onVisibilityChange, false); 55 "webkitvisibilitychange", onVisibilityChange, false);
45 checkIsPageVisible(); 56 checkIsPageVisible();
46 numVisibilityChanges++; 57 numVisibilityChanges++;
47 makePageHidden(); 58 makePageHidden();
48 } 59 }
49 60
50 function finishTest() { 61 function finishTest() {
51 if (window.layoutTestController) { 62 if (window.layoutTestController) {
52 layoutTestController.resetPageVisibility(); 63 layoutTestController.resetPageVisibility();
53 } 64 }
54 finishJSTest(); 65 finishJSTest();
55 } 66 }
56 67
57 function onVisibilityChange() { 68 function onVisibilityChange() {
58 if (numVisibilityChanges == 1) { 69 if (numVisibilityChanges == 1) {
59 checkIsPageHidden(); 70 checkIsPageHidden();
60 numVisibilityChanges++; 71 numVisibilityChanges++;
61 makePageHidden(); 72 makePageHidden();
62 checkIsPageHidden(); 73 checkIsPageHidden();
63 numVisibilityChanges++; 74 numVisibilityChanges++;
64 makePageVisible(); 75 makePagePrerender();
65 return; 76 return;
66 } else if (numVisibilityChanges == 2) { 77 } else if (numVisibilityChanges == 2) {
67 testFailed("Invalid event fired on same state change."); 78 testFailed("Invalid event fired on same state change.");
68 finishTest(); 79 finishTest();
69 return; 80 return;
70 } else if (numVisibilityChanges == 3) { 81 } else if (numVisibilityChanges == 3) {
82 checkIsPagePrerendering();
83 numVisibilityChanges++;
84 makePageVisible();
85 return;
86 } else if (numVisibilityChanges == 4) {
71 checkIsPageVisible(); 87 checkIsPageVisible();
72 numVisibilityChanges++; 88 numVisibilityChanges++;
73 finishTest(); 89 finishTest();
74 return; 90 return;
75 } else { 91 } else {
76 testFailed("Too many visibility transitions"); 92 testFailed("Too many visibility transitions");
77 finishTest(); 93 finishTest();
78 return; 94 return;
79 } 95 }
80 } 96 }
81 97
82 var successfullyParsed = true; 98 var successfullyParsed = true;
83 99
84 </script> 100 </script>
85 101
86 <script src="../js/resources/js-test-post.js"></script> 102 <script src="../js/resources/js-test-post.js"></script>
87 103
88 </body> 104 </body>
89 </html> 105 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/events/page-visibility-transition-test-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698