summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/orientation-event/orientation/optional-event-properties.https.html
blob: 150ce5ca1d22306f4b5e952f1249f8b1f044e401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict';

test(test => {
  event = document.createEvent('DeviceOrientationEvent');
  assert_equals(event.type, "");
  assert_equals(event.alpha, null);
  assert_equals(event.beta, null);
  assert_equals(event.gamma, null);
  assert_false(event.absolute);
}, 'Tests creating a DeviceOrientationEvent.');

test(test => {
  event = new DeviceOrientationEvent('foo', {alpha: 0, beta: 1, gamma: 2, absolute: false});
  assert_equals(event.type, "foo");
  assert_equals(event.alpha, 0);
  assert_equals(event.beta, 1);
  assert_equals(event.gamma, 2);
  assert_false(event.absolute);
}, 'Tests no missing value (absolute field is false).');

test(test => {
  event = new DeviceOrientationEvent('', {alpha: 0, beta: 1, gamma: 2, absolute: true});
  assert_equals(event.alpha, 0);
  assert_equals(event.beta, 1);
  assert_equals(event.gamma, 2);
  assert_true(event.absolute);
}, 'Tests no missing value (absolute field is true).');

test(test => {
  event = new DeviceOrientationEvent('');
  assert_equals(event.alpha, null);
  assert_equals(event.beta, null);
  assert_equals(event.gamma, null);
  assert_false(event.absolute);
}, 'Tests DeviceOrientationEvent default constructor.');

test(test => {
  event = new DeviceOrientationEvent('', {alpha: [], beta: [], gamma: [], absolute: []});
  assert_equals(event.alpha, 0);
  assert_equals(event.beta, 0);
  assert_equals(event.gamma, 0);
  assert_true(event.absolute);
}, 'Tests all values are empty array.');

test(test => {
  event = new DeviceOrientationEvent('', {alpha: undefined, beta: undefined, gamma: undefined, absolute: undefined});
  assert_equals(event.alpha, null);
  assert_equals(event.beta, null);
  assert_equals(event.gamma, null);
  assert_false(event.absolute);
}, 'Tests all values are undefined.');

test(test => {
  event = new DeviceOrientationEvent('', {alpha: '', beta: '', gamma: '', absolute: ''});
  assert_equals(event.alpha, 0);
  assert_equals(event.beta, 0);
  assert_equals(event.gamma, 0);
  assert_false(event.absolute);
}, 'Tests all values are empty string.');


test(test => {
  event = new DeviceOrientationEvent('', {alpha: null, beta: null, gamma: null, absolute: null});
  assert_equals(event.alpha, null);
  assert_equals(event.beta, null);
  assert_equals(event.gamma, null);
  assert_false(event.absolute);
}, 'Tests all values are null.');
</script>