Skip to content

Commit 0273073

Browse files
Raphael Kubo da Costamoz-wptsync-bot
Raphael Kubo da Costa
authored andcommitted
Bug 1880062 [wpt PR 44557] - orientation-event: Test DeviceOrientationEvent's absolute value on error, a=testonly
Automatic update from web-platform-tests orientation-event: Test DeviceOrientationEvent's absolute value on error (#44557) Test for w3c/deviceorientation#139. When a reading cannot be provided, `absolute` needs to be set accordingly depending on the event type we are listening to. -- wpt-commits: fb4cd8f597e9b40725a51222b4627cbd6d94c528 wpt-pr: 44557
1 parent ef78b1d commit 0273073

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

testing/web-platform/tests/orientation-event/orientation/null-values.https.html

+26-15
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,32 @@
77
<script>
88
'use strict';
99

10-
promise_test(async (t) => {
11-
const helper = new SensorTestHelper(t, 'deviceorientation');
12-
await helper.grantSensorsPermissions();
13-
await helper.initializeSensors({disabledSensors: ['absolute-orientation', 'relative-orientation']});
10+
function test_null_orientation_data(eventType) {
11+
promise_test(async t => {
12+
const helper = new SensorTestHelper(t, eventType);
13+
await helper.grantSensorsPermissions();
14+
await helper.initializeSensors(
15+
{disabledSensors : [ 'absolute-orientation', 'relative-orientation' ]});
1416

15-
const orientationData1 = generateOrientationData(1.1, 2.2, 3.3, false);
16-
// Currently it is not possible to set individual values to null because the
17-
// parsing algorithms used by
18-
// https://w3c.github.io/sensors/#update-virtual-sensor-reading-command
19-
// always expect numbers.
20-
const orientationData2 = generateOrientationData(null, null, null, false);
17+
const inputData = generateOrientationData(1.1, 2.2, 3.3, false);
18+
// Currently it is not possible to set individual values to null because
19+
// the parsing algorithms used by
20+
// https://w3c.github.io/sensors/#update-virtual-sensor-reading-command
21+
// always expect numbers.
22+
const expectedData = generateOrientationData(
23+
null, null, null,
24+
/*absolute=*/ eventType === 'deviceorientationabsolute');
25+
const expectedEvent = eventType === 'deviceorientationabsolute'
26+
? getExpectedAbsoluteOrientationEvent
27+
: getExpectedOrientationEvent;
2128

22-
// An example how setting relative-orientation sensor as disabled will output
23-
// null values. Even if we try to set non null values to sensor.
24-
await helper.setData(orientationData1);
25-
await waitForEvent(getExpectedOrientationEvent(orientationData2));
26-
}, 'Tests using null values for some of the event properties.');
29+
// An example how setting the orientation sensors as disabled will always
30+
// output null values.
31+
await helper.setData(inputData);
32+
await waitForEvent(expectedEvent(expectedData));
33+
}, `${eventType}: Missing values are set to null or true/false accordingly`);
34+
}
35+
36+
test_null_orientation_data('deviceorientation');
37+
test_null_orientation_data('deviceorientationabsolute');
2738
</script>

0 commit comments

Comments
 (0)