summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/DeviceOrientation/script-tests/updates.js
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/fast/dom/DeviceOrientation/script-tests/updates.js')
-rw-r--r--LayoutTests/fast/dom/DeviceOrientation/script-tests/updates.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/DeviceOrientation/script-tests/updates.js b/LayoutTests/fast/dom/DeviceOrientation/script-tests/updates.js
new file mode 100644
index 0000000..f5ec029
--- /dev/null
+++ b/LayoutTests/fast/dom/DeviceOrientation/script-tests/updates.js
@@ -0,0 +1,37 @@
+description('Tests that updates to the orientation causes new events to fire.');
+
+var mockEvent;
+function setMockOrientation(alpha, beta, gamma) {
+ mockEvent = {alpha: alpha, beta: beta, gamma: gamma};
+ if (window.layoutTestController)
+ layoutTestController.setMockDeviceOrientation(true, mockEvent.alpha, true, mockEvent.beta, true, mockEvent.gamma);
+ else
+ debug('This test can not be run without the LayoutTestController');
+}
+
+var deviceOrientationEvent;
+function checkOrientation(event) {
+ deviceOrientationEvent = event;
+ shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha');
+ shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta');
+ shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma');
+}
+
+function firstListener(event) {
+ checkOrientation(event);
+ window.removeEventListener('deviceorientation', firstListener);
+
+ setMockOrientation(11.1, 22.2, 33.3);
+ window.addEventListener('deviceorientation', updateListener);
+}
+
+function updateListener(event) {
+ checkOrientation(event);
+ finishJSTest();
+}
+
+setMockOrientation(1.1, 2.2, 3.3);
+window.addEventListener('deviceorientation', firstListener);
+
+window.jsTestIsAsync = true;
+window.successfullyParsed = true;