blob: 4aa162e215ad133be8243223958eaab826b44dba [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../vr/resources/fake-vr-displays.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/device/vr/vr_service.mojom.js"></script>
<script src="../vr/resources/mock-vr-service.js"></script>
<canvas id="webgl-canvas"></canvas>
<script>
let fakeDisplays = fakeVRDisplays();
vr_test((t, mockService) => {
let watcherDone = new Event("watcherdone");
let eventWatcher = new EventWatcher(t, navigator.xr, ["devicechange",
"watcherdone"]);
eventWatcher.wait_for(["devicechange", "watcherdone"])
.then( () => {
t.done();
});
// The event should fire when a listener is added even if the devices are not
// explicity queried with navigator.xr.requestDevice().
function onDeviceChange() {
t.step( () => {
navigator.xr.dispatchEvent(watcherDone);
});
}
navigator.xr.addEventListener("devicechange", onDeviceChange, false);
}, [fakeDisplays["Pixel"]],
"Test devicechange fires when devices are connected.");
</script>