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
|
<!DOCTYPE html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="resources/webxr_util.js"></script>
<script src="resources/webxr_test_constants.js"></script>
<script>
let immersiveTestName = "XRSession resetpose from a device properly fires off " +
"the right events for immersive sessions";
let watcherDone = new Event("watcherdone");
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let testFunction = function(session, fakeDeviceController, t) {
let resetPromise = session.requestReferenceSpace('local')
.then((refSpace) => {
let eventWatcher = new EventWatcher(
t, refSpace, ["reset", "watcherdone"]);
refSpace.addEventListener("reset", (event) => {
t.step(() => {
assert_equals(event.referenceSpace, refSpace);
// Also make sure the same objects are returned each time these
// attributes are accessed.
let eventRefSpace = event.referenceSpace;
let transform = event.transform;
assert_equals(eventRefSpace, event.referenceSpace,
"XRReferenceSpaceEvent.referenceSpace returns the same object.");
assert_equals(transform, event.transform,
"XRReferenceSpaceEvent.transform returns the same object.");
});
refSpace.dispatchEvent(watcherDone);
}, false);
return eventWatcher.wait_for(["reset", "watcherdone"]);
});
fakeDeviceController.simulateResetPose();
// The triggered resetPose event should arrive after the next Animation Frame
requestSkipAnimationFrame(session, () => {});
return resetPromise;
};
xr_session_promise_test(
immersiveTestName, testFunction, fakeDeviceInitParams, 'immersive-vr');
</script>
|