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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/page-visibility-bubble.html

Issue 1435893003: PageVisibility API: Ensure bubbling events are generated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary comments Created 5 years, 1 month 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 | third_party/WebKit/LayoutTests/fast/events/page-visibility-bubble-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
(Empty)
1 <html>
2 <body onload='startTest()'>
3
4 <script src="../../resources/js-test.js"></script>
5
6 <script>
7
8 // 'visibilitychange' event should bubble as defined in http://www.w3.org/TR/pag e-visibility/#sec-processing-model
9 // See: http://crbug.com/501821
10 description("This test checks that 'visibilitychange' event bubbles.");
11
12 var jsTestIsAsync = true;
13
14 function makePageVisible() {
15 if (window.testRunner)
16 testRunner.setPageVisibility("visible");
17 }
18
19 function makePageHidden() {
20 if (window.testRunner)
21 testRunner.setPageVisibility("hidden");
22 }
23
24 function checkIsPageVisible() {
25 shouldBeEqualToString("document.visibilityState", "visible");
26 shouldBeFalse("document.hidden");
27 }
28
29 function checkIsPageHidden() {
30 shouldBeEqualToString("document.visibilityState", "hidden");
31 shouldBeTrue("document.hidden");
32 }
33
34 // We will try to change the visibility states as:
35 // 0 - visible. (Initial - i.e. on load).
36 // 1 - hidden (should fire event and bubbles).
37 // 2 - visible (should fire event and bubbles).
38 var numVisibilityChanges = 0;
39
40 function startTest() {
41 // Document listener will be fired first
42 document.addEventListener(
43 "visibilitychange", onVisibilityChangeDocument, false);
44 window.addEventListener(
45 "visibilitychange", onVisibilityChangeWindow, false);
46 checkIsPageVisible();
47 numVisibilityChanges++;
48 makePageHidden();
49 }
50
51 function onVisibilityChangeDocument(event) {
52 shouldBeTrue("event.bubbles");
53 }
54
55 function onVisibilityChangeWindow(event) {
56 shouldBeTrue("event.bubbles");
57 if (numVisibilityChanges == 1) {
58 numVisibilityChanges++;
59 checkIsPageHidden();
60 makePageVisible();
61 } else if (numVisibilityChanges == 2) {
62 finishJSTest();
63 } else {
64 testFailed("Invalid number of visibility transitions");
65 finishJSTest();
66 }
67 }
68
69 </script>
70
71
72 </body>
73 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/events/page-visibility-bubble-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698