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..2c491be2abff20e1a08529b329f87607a0ba00d0 |
--- /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(lightValue) { |
+ |
+ mockEvent = {value: lightValue}; |
+ |
+ 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; |