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

Unified Diff: LayoutTests/fast/dom/DeviceOrientation/script-tests/add-listener-from-callback.js

Issue 22599005: Blink-side layout tests for the new Device Orientation API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased once more 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
Index: LayoutTests/fast/dom/DeviceOrientation/script-tests/add-listener-from-callback.js
diff --git a/LayoutTests/fast/dom/DeviceOrientation/script-tests/add-listener-from-callback.js b/LayoutTests/fast/dom/DeviceOrientation/script-tests/add-listener-from-callback.js
index b42af4f60f2bc292345d18bfb0cabbc6bc48f90c..b3194a275f3b81492144557f479db672fd1b6fa2 100644
--- a/LayoutTests/fast/dom/DeviceOrientation/script-tests/add-listener-from-callback.js
+++ b/LayoutTests/fast/dom/DeviceOrientation/script-tests/add-listener-from-callback.js
@@ -3,9 +3,10 @@ description('Tests that adding a new event listener from a callback works as exp
var mockAlpha = 1.1;
var mockBeta = 2.2;
var mockGamma = 3.3;
+var mockAbsolute = true;
if (window.testRunner)
- testRunner.setMockDeviceOrientation(true, mockAlpha, true, mockBeta, true, mockGamma);
+ testRunner.setMockDeviceOrientation(true, mockAlpha, true, mockBeta, true, mockGamma, true, mockAbsolute);
else
debug('This test can not be run without the TestRunner');
@@ -15,29 +16,24 @@ function checkOrientation(event) {
shouldBe('deviceOrientationEvent.alpha', 'mockAlpha');
shouldBe('deviceOrientationEvent.beta', 'mockBeta');
shouldBe('deviceOrientationEvent.gamma', 'mockGamma');
+ shouldBe('deviceOrientationEvent.absolute', 'mockAbsolute');
}
var firstListenerEvents = 0;
function firstListener(event) {
checkOrientation(event);
+ window.removeEventListener('deviceorientation', firstListener);
if (++firstListenerEvents == 1)
window.addEventListener('deviceorientation', secondListener);
- else if (firstListenerEvents > 2)
- testFailed('Too many events for first listener.');
- maybeFinishTest();
}
var secondListenerEvents = 0;
function secondListener(event) {
checkOrientation(event);
- if (++secondListenerEvents > 1)
- testFailed('Too many events for second listener.');
- maybeFinishTest();
-}
-
-function maybeFinishTest() {
- if (firstListenerEvents == 2 && secondListenerEvents == 1)
- finishJSTest();
+ ++secondListenerEvents;
+ if (firstListenerEvents != 1 || secondListenerEvents != 1)
+ testFailed('Too many events fired for first or second listener');
+ finishJSTest();
}
window.addEventListener('deviceorientation', firstListener);

Powered by Google App Engine
This is Rietveld 408576698