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

Unified Diff: LayoutTests/fast/dom/DeviceLight/script-tests/null-values.js

Issue 143823004: Implement DeviceLight (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: DeviceLight API working fine (make the flag back to status=experimental) Created 6 years, 10 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
Index: LayoutTests/fast/dom/DeviceLight/script-tests/null-values.js
diff --git a/LayoutTests/fast/dom/DeviceLight/script-tests/null-values.js b/LayoutTests/fast/dom/DeviceLight/script-tests/null-values.js
new file mode 100644
index 0000000000000000000000000000000000000000..f1499cfd9f30a7a474ab1303a31415d23d2a0600
--- /dev/null
+++ b/LayoutTests/fast/dom/DeviceLight/script-tests/null-values.js
@@ -0,0 +1,62 @@
+description('Tests using null values for some or all of the event properties.');
+
+var mockEvent;
+function setMockLight(value) {
+
+ mockEvent = {value: value};
+
+ if (window.testRunner)
+ testRunner.setMockDeviceLight(null != mockEvent.value, null == mockEvent.value ? 0 : mockEvent.value);
+ else
+ debug('This test can not be run without the TestRunner');
+}
+
+
+var deviceLightEvent;
+function checkLight(event) {
+ deviceLightEvent = event;
+ shouldBe('deviceLightEvent.value', 'mockEvent.value');
+}
+
+function firstListener(event) {
+ checkLight(event);
+ window.removeEventListener('devicelight', firstListener);
+ setTimeout(function(){initSecondListener();}, 0);
+}
+
+function initSecondListener() {
+ setMockLight(20);
+ window.addEventListener('devicelight', secondListener);
+}
+
+function secondListener(event) {
+ checkLight(event);
+ window.removeEventListener('devicelight', secondListener);
+ setTimeout(function(){initThirdListener();}, 0);
+}
+
+function initThirdListener() {
+ setMockLight(30);
+ window.addEventListener('devicelight', thirdListener);
+}
+
+function thirdListener(event) {
+ checkLight(event);
+ window.removeEventListener('devicelight', thirdListener);
+ setTimeout(function(){initFourthListener();}, 0);
+}
+
+function initFourthListener() {
+ setMockLight(40);
+ window.addEventListener('devicelight', fourthListener);
+}
+
+function fourthListener(event) {
+ checkLight(event);
+ finishJSTest();
+}
+
+setMockLight(50);
+window.addEventListener('devicelight', firstListener);
+
+window.jsTestIsAsync = true;

Powered by Google App Engine
This is Rietveld 408576698