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

Unified Diff: LayoutTests/fast/dom/DeviceLight/script-tests/add-during-dispatch.js

Issue 143823004: Implement DeviceLight (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Work in Adam's comments 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/add-during-dispatch.js
diff --git a/LayoutTests/fast/dom/DeviceLight/script-tests/add-during-dispatch.js b/LayoutTests/fast/dom/DeviceLight/script-tests/add-during-dispatch.js
new file mode 100644
index 0000000000000000000000000000000000000000..e741bcb74d72aa12d25699a3c1cad1f8c5aaeb80
--- /dev/null
+++ b/LayoutTests/fast/dom/DeviceLight/script-tests/add-during-dispatch.js
@@ -0,0 +1,40 @@
+description('Test no fire listeners added during event dispatch.');
+
+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);
+ window.addEventListener('devicelight', secondListener);
+ setTimeout(function(){finish();}, 100);
+}
+
+var numSecondListenerCalls = 0;
+function secondListener(event) {
+ ++numSecondListenerCalls;
+}
+
+function finish() {
+ shouldBe('numSecondListenerCalls', '1');
+ finishJSTest();
+}
+
+setMockLight(10);
+window.addEventListener('devicelight', firstListener);
+
+window.jsTestIsAsync = true;

Powered by Google App Engine
This is Rietveld 408576698