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

Unified Diff: LayoutTests/fast/dom/DeviceMotion/page-visibility.html

Issue 23705010: Add page visibility observer support for Device Motion (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Improve the test Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/DeviceMotion/page-visibility-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/DeviceMotion/page-visibility.html
diff --git a/LayoutTests/fast/dom/DeviceMotion/page-visibility.html b/LayoutTests/fast/dom/DeviceMotion/page-visibility.html
new file mode 100644
index 0000000000000000000000000000000000000000..53fddfc4e9b6ba431a62a7aead636cbc0492ee8d
--- /dev/null
+++ b/LayoutTests/fast/dom/DeviceMotion/page-visibility.html
@@ -0,0 +1,60 @@
+<html>
+<head>
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+description('Tests to check that devicemotion events are not fired when the page is not visible.');
+window.jsTestIsAsync = true;
+
+function succeedAndFinish()
+{
+ testPassed("Received a devicemotion event");
+ finishJSTest();
+}
+
+function testWithPageVisible()
+{
+ testPassed("Did not receive a devicemotion event");
+ window.removeEventListener('devicemotion', failAndFinish);
+ if (window.testRunner)
+ testRunner.setPageVisibility("visible");
+ debug("* Page is visible");
+ window.addEventListener('devicemotion', succeedAndFinish);
+}
+
+function failAndFinish()
+{
+ testFailed('Should not have received a devicemotion event while the page was hidden');
+ finishJSTest();
+}
+
+function testWithPageHidden()
+{
+ testPassed("Received a devicemotion event");
+ window.removeEventListener('devicemotion', deviceMotionListener);
+ if (window.testRunner)
+ testRunner.setPageVisibility("hidden");
+ debug("* Page is hidden");
+ window.addEventListener('devicemotion', failAndFinish);
+
+ setTimeout(testWithPageVisible, 100);
+}
+
+function deviceMotionListener(event) {
+ setTimeout(testWithPageHidden, 0);
+}
+
+if (window.testRunner)
+ testRunner.setMockDeviceMotion(true, 0, true, 0, true, 0,
+ true, 0, true, 0, true, 0,
+ true, 0, true, 0, true, 0,
+ 0);
+
+debug("* Page is visible");
+window.addEventListener('devicemotion', deviceMotionListener);
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/DeviceMotion/page-visibility-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698