blob: 86a9a6f9d6f7ec37e6b92678a018765fe8b48803 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/device/vr/public/mojom/vr_service.mojom.js"></script>
<script src="../external/wpt/resources/chromium/webxr-test.js"></script>
<script src="../xr/resources/xr-internal-device-mocking.js"></script>
<script src="../xr/resources/xr-test-utils.js"></script>
<script src="../xr/resources/test-constants.js"></script>
<canvas id="webgl-canvas"></canvas>
<script>
let testName = "Outstanding promises get rejected if environmentProvider disconencts";
let fakeDeviceInitParams = { supportsImmersive: false,
supportsEnvironmentIntegration: true };
let requestSessionOptions = [ {mode: 'legacy-inline-ar' } ];
let refSpace = undefined;
let ray = new XRRay({x : 0.0, y : 0.0, z : 0.0}, {x : 1.0, y : 0.0, z: 0.0});
// Override the xr-internal-device-mock for requestHitTest so that we can
// also return a promise that never resolves or rejects.
// This is so that we can simulate a disconnect while the mojo call is still
// outstanding.
let immediatelyResolveHitTest = true;
MockRuntime.prototype.requestHitTest = function(Ray) {
if (immediatelyResolveHitTest) {
var hit = new device.mojom.XRHitResult();
hit.hitMatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
hit_results = {results: [hit]};
return Promise.resolve(hit_results);
}
return new Promise((resolve,reject) => { });
}
let testFunction = function(session, t, controller) {
return session.requestReferenceSpace({ type: "stationary", subtype: "eye-level" })
.then((referenceSpace) => {
refSpace = referenceSpace;
// Request a first hit test to ensure that all of the mojo connections are
// up and running.
return session.requestHitTest(ray, refSpace);
})
.then(() => {
immediatelyResolveHitTest = false;
let hitTestPromise = session.requestHitTest(ray, refSpace);
controller.closeEnvironmentIntegrationProvider();
return hitTestPromise;
})
.then(() => {
assert_unreached("HitTestPromise should not resolve");
},
(err) => {
assert_equals(err.name, "InvalidStateError");
});
};
xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionOptions, testName);
</script>