• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1description('Tests using null values for some of the event properties.');
2
3var mockEvent;
4function setMockOrientation(alpha, beta, gamma) {
5    mockEvent = {alpha: alpha, beta: beta, gamma: gamma};
6    if (window.layoutTestController)
7        layoutTestController.setMockDeviceOrientation(
8            null != mockEvent.alpha, null == mockEvent.alpha ? 0 : mockEvent.alpha,
9            null != mockEvent.beta, null == mockEvent.beta ? 0 : mockEvent.beta,
10            null != mockEvent.gamma, null == mockEvent.gamma ? 0 : mockEvent.gamma);
11    else
12        debug('This test can not be run without the LayoutTestController');
13}
14
15var deviceOrientationEvent;
16function checkOrientation(event) {
17    deviceOrientationEvent = event;
18    shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha');
19    shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta');
20    shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma');
21}
22
23function firstListener(event) {
24    checkOrientation(event);
25    window.removeEventListener('deviceorientation', firstListener);
26
27    setMockOrientation(1.1, null, null);
28    window.addEventListener('deviceorientation', secondListener);
29}
30
31function secondListener(event) {
32    checkOrientation(event);
33    window.removeEventListener('deviceorientation', secondListener);
34
35    setMockOrientation(null, 2.2, null);
36    window.addEventListener('deviceorientation', thirdListener);
37}
38
39function thirdListener(event) {
40    checkOrientation(event);
41    window.removeEventListener('deviceorientation', thirdListener);
42
43    setMockOrientation(null, null, 3.3);
44    window.addEventListener('deviceorientation', fourthListener);
45}
46
47function fourthListener(event) {
48    checkOrientation(event);
49    finishJSTest();
50}
51
52setMockOrientation(null, null, null);
53window.addEventListener('deviceorientation', firstListener);
54
55window.jsTestIsAsync = true;
56window.successfullyParsed = true;
57