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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/events/page-visibility-bubble.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/page-visibility-bubble.html b/third_party/WebKit/LayoutTests/fast/events/page-visibility-bubble.html
new file mode 100644
index 0000000000000000000000000000000000000000..6a486eb9cd1edeb629340f5334887b57cfd90c53
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/page-visibility-bubble.html
@@ -0,0 +1,73 @@
+<html>
+<body onload='startTest()'>
+
+<script src="../../resources/js-test.js"></script>
+
+<script>
+
+// 'visibilitychange' event should bubble as defined in http://www.w3.org/TR/page-visibility/#sec-processing-model
+// See: http://crbug.com/501821
+description("This test checks that 'visibilitychange' event bubbles.");
+
+var jsTestIsAsync = true;
+
+function makePageVisible() {
+ if (window.testRunner)
+ testRunner.setPageVisibility("visible");
+}
+
+function makePageHidden() {
+ if (window.testRunner)
+ testRunner.setPageVisibility("hidden");
+}
+
+function checkIsPageVisible() {
+ shouldBeEqualToString("document.visibilityState", "visible");
+ shouldBeFalse("document.hidden");
+}
+
+function checkIsPageHidden() {
+ shouldBeEqualToString("document.visibilityState", "hidden");
+ shouldBeTrue("document.hidden");
+}
+
+// We will try to change the visibility states as:
+// 0 - visible. (Initial - i.e. on load).
+// 1 - hidden (should fire event and bubbles).
+// 2 - visible (should fire event and bubbles).
+var numVisibilityChanges = 0;
+
+function startTest() {
+ // Document listener will be fired first
+ document.addEventListener(
+ "visibilitychange", onVisibilityChangeDocument, false);
+ window.addEventListener(
+ "visibilitychange", onVisibilityChangeWindow, false);
+ checkIsPageVisible();
+ numVisibilityChanges++;
+ makePageHidden();
+}
+
+function onVisibilityChangeDocument(event) {
+ shouldBeTrue("event.bubbles");
+}
+
+function onVisibilityChangeWindow(event) {
+ shouldBeTrue("event.bubbles");
+ if (numVisibilityChanges == 1) {
+ numVisibilityChanges++;
+ checkIsPageHidden();
+ makePageVisible();
+ } else if (numVisibilityChanges == 2) {
+ finishJSTest();
+ } else {
+ testFailed("Invalid number of visibility transitions");
+ finishJSTest();
+ }
+}
+
+</script>
+
+
+</body>
+</html>
« 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