Commit 98ba5fa0 authored by bsheedy's avatar bsheedy Committed by Commit Bot

Remove async_test from XR instrumentation

Removes use of testharness.js's async_test from all XR instrumentation
test files. testharness.js supports single-page tests, where not calling
test() or async_test() will allow asserts to work without having to be
wrapped in a step. This new approach is both cleaner and less confusing,
as it was not obvious to new users that asserts needed to be wrapped.

Bug: 909948
Change-Id: If945571ef414953c538596da08976483ab39b3f9
Reviewed-on: https://chromium-review.googlesource.com/c/1356021Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612808}
parent 9bece2a1
...@@ -42,23 +42,20 @@ Tests that the reported device capabilities match expectations. ...@@ -42,23 +42,20 @@ Tests that the reported device capabilities match expectations.
} }
}, },
} }
var t = async_test("Device capabilities match expectations");
function stepCheckDeviceCapabilities(device) { function stepCheckDeviceCapabilities(device) {
if (!(device in expectations)) { if (!(device in expectations)) {
t.step_func_done( () => { assert_unreached("Given device " + device + " not in expectations");
assert_unreached("Given device " + device + " not in expectations"); done();
})();
return; return;
} }
let expectation = expectations[device]; let expectation = expectations[device];
t.step_func_done( () => { assert_equals(vrDisplay["isPresenting"], expectation["isPresenting"]);
assert_equals(vrDisplay["isPresenting"], expectation["isPresenting"]); for (var capability in expectation["capabilities"]) {
for (var capability in expectation["capabilities"]) { assert_equals(vrDisplay["capabilities"][capability],
assert_equals(vrDisplay["capabilities"][capability], expectation["capabilities"][capability],
expectation["capabilities"][capability], capability);
capability); }
} done();
})();
} }
</script> </script>
</body> </body>
......
...@@ -14,7 +14,6 @@ View. ...@@ -14,7 +14,6 @@ View.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("Screen taps/clicks registered when in VR");
var pressed = false; var pressed = false;
var index = -1; var index = -1;
var canStartTest = false; var canStartTest = false;
...@@ -23,9 +22,7 @@ View. ...@@ -23,9 +22,7 @@ View.
var lastInputValue = false; var lastInputValue = false;
window.addEventListener("gamepadconnected", function(e) { window.addEventListener("gamepadconnected", function(e) {
t.step( () => { assert_equals(index, -1, "Should only have one connected controller");
assert_equals(index, -1, "Should only have one connected controller");
});
index = e.gamepad.index; index = e.gamepad.index;
}); });
...@@ -58,7 +55,7 @@ View. ...@@ -58,7 +55,7 @@ View.
finishJavaScriptStep(); finishJavaScriptStep();
} }
if (pressed && gp.buttons[0].pressed == false) { if (pressed && gp.buttons[0].pressed == false) {
t.done(); done();
} }
} }
</script> </script>
......
...@@ -14,17 +14,14 @@ vrdisplayactivate event ...@@ -14,17 +14,14 @@ vrdisplayactivate event
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("NFC scan fires the vrdisplayactivate event");
function addListener() { function addListener() {
window.addEventListener("vrdisplayactivate", () => { window.addEventListener("vrdisplayactivate", () => {
vrDisplay.requestPresent([{source: webglCanvas}]).then( () => { vrDisplay.requestPresent([{source: webglCanvas}]).then( () => {
// Do nothing // Do nothing
}, (err) => { }, (err) => {
t.step( () => { assert_unreached(
assert_unreached( "Was unable to present with vrdisplayactivate: " + err);
"Was unable to present with vrdisplayactivate: " + err); }).then( () => { done() });
});
}).then( () => {t.done()});
}, false); }, false);
} }
// NFC scan triggered after page loaded and listener added // NFC scan triggered after page loaded and listener added
......
...@@ -13,7 +13,6 @@ is active, but resumes afterwards. ...@@ -13,7 +13,6 @@ is active, but resumes afterwards.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Non-immersive rAF stops during immersive session");
let counter = 0; let counter = 0;
function stepBeforeImmersive() { function stepBeforeImmersive() {
...@@ -22,10 +21,8 @@ is active, but resumes afterwards. ...@@ -22,10 +21,8 @@ is active, but resumes afterwards.
// are not done while there is an immersive session. // are not done while there is an immersive session.
onMagicWindowXRFrameCallback = function() { onMagicWindowXRFrameCallback = function() {
if (sessionInfos[sessionTypes.IMMERSIVE].currentSession !== null) { if (sessionInfos[sessionTypes.IMMERSIVE].currentSession !== null) {
t.step( () => { assert_unreached(
assert_unreached( "Non-immersive rAF called during immersive session");
"Non-immersive rAF called during immersive session");
});
} }
} }
finishJavaScriptStep(); finishJavaScriptStep();
...@@ -49,7 +46,7 @@ is active, but resumes afterwards. ...@@ -49,7 +46,7 @@ is active, but resumes afterwards.
function stepAfterImmersive() { function stepAfterImmersive() {
// Make sure we fire at least once after exiting the immersive session // Make sure we fire at least once after exiting the immersive session
onMagicWindowXRFrameCallback = function() { onMagicWindowXRFrameCallback = function() {
t.done(); done();
}; };
} }
</script> </script>
......
...@@ -11,8 +11,6 @@ Browser. ...@@ -11,8 +11,6 @@ Browser.
<script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script> <script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script> <script>
var t = async_test("Payment Request API disabled while in VR Browser");
// Arbitrary but valid data to pass to PaymentRequest to trigger the // Arbitrary but valid data to pass to PaymentRequest to trigger the
// native Payment Request UI. // native Payment Request UI.
var methods = [ var methods = [
...@@ -62,15 +60,11 @@ Browser. ...@@ -62,15 +60,11 @@ Browser.
function stepRequestPayment() { function stepRequestPayment() {
request.show().then(() => { request.show().then(() => {
t.step(() => { assert_unreached("Payment request was shown and accepted");
assert_unreached("Payment request was shown and accepted");
});
}, (err) => { }, (err) => {
t.step(() => { assert_true(err instanceof DOMException,
assert_true(err instanceof DOMException, "Payment request denied, but not for expected reason");
"Payment request denied, but not for expected reason"); done();
});
t.done();
}); });
} }
</script> </script>
......
...@@ -7,18 +7,14 @@ Tests that permissions granted in 2D Chrome persist in the VR Browser. ...@@ -7,18 +7,14 @@ Tests that permissions granted in 2D Chrome persist in the VR Browser.
<script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script> <script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script> <script>
var t = async_test("Permissions granted in 2D persist in VR Browser");
function stepRequestPermission() { function stepRequestPermission() {
navigator.getUserMedia( navigator.getUserMedia(
{audio: true, video: true}, {audio: true, video: true},
() => { () => {
t.done(); done();
}, },
(err) => { (err) => {
t.step(() => { assert_unreached("Permission request rejected: " + err);
assert_unreached("Permission request rejected: " + err);
});
}); });
} }
</script> </script>
......
...@@ -12,7 +12,6 @@ Tests that WebVR doesn't update frame data when the tab is not focused ...@@ -12,7 +12,6 @@ Tests that WebVR doesn't update frame data when the tab is not focused
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("Test pose data in unfocused tab");
var fd = null; var fd = null;
let counter = 0; let counter = 0;
...@@ -28,14 +27,12 @@ Tests that WebVR doesn't update frame data when the tab is not focused ...@@ -28,14 +27,12 @@ Tests that WebVR doesn't update frame data when the tab is not focused
return; return;
} }
fd = new VRFrameData(); fd = new VRFrameData();
t.step( () => { assert_true(vrDisplay.getFrameData(fd),
assert_true(vrDisplay.getFrameData(fd), "getFrameData says it updated the object");
"getFrameData says it updated the object"); assert_true(fd != null,
assert_true(fd != null, "frame data is no longer null");
"frame data is no longer null"); assert_true(fd.pose != null,
assert_true(fd.pose != null, "frame data's pose is non-null");
"frame data's pose is non-null");
});
finishJavaScriptStep(); finishJavaScriptStep();
} }
// Make sure at least one rAF call has happened so we get valid data // Make sure at least one rAF call has happened so we get valid data
...@@ -43,10 +40,9 @@ Tests that WebVR doesn't update frame data when the tab is not focused ...@@ -43,10 +40,9 @@ Tests that WebVR doesn't update frame data when the tab is not focused
} }
function stepCheckFrameDataWhileNonFocusedTab() { function stepCheckFrameDataWhileNonFocusedTab() {
t.step_func_done( () => { assert_false(vrDisplay.getFrameData(fd),
assert_false(vrDisplay.getFrameData(fd), "getFrameData shouldn't provide new data when tab not focused");
"getFrameData shouldn't provide new data when tab not focused"); done();
})();
} }
</script> </script>
</body> </body>
......
...@@ -13,7 +13,6 @@ focus, that the presenting frame still receives input. ...@@ -13,7 +13,6 @@ focus, that the presenting frame still receives input.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("Focus is locked to presentation");
var rafCount = 0; var rafCount = 0;
function stepSetupFocusLoss() { function stepSetupFocusLoss() {
...@@ -26,7 +25,7 @@ focus, that the presenting frame still receives input. ...@@ -26,7 +25,7 @@ focus, that the presenting frame still receives input.
window.onblur = function() { window.onblur = function() {
onPresentingAnimationFrameCallback = function() { onPresentingAnimationFrameCallback = function() {
if (rafCount == 3) { if (rafCount == 3) {
t.done(); done();
} }
rafCount++; rafCount++;
} }
......
...@@ -13,16 +13,13 @@ the DON flow is canceled. ...@@ -13,16 +13,13 @@ the DON flow is canceled.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("Presentation promise is rejected after DON canceled");
function onVrRequestPresentWithDon() { function onVrRequestPresentWithDon() {
vrDisplay.requestPresent([{source: webglCanvas}]).then( () => { vrDisplay.requestPresent([{source: webglCanvas}]).then( () => {
t.step( () => { assert_unreached("requestPresent promise resolved");
assert_unreached("requestPresent promise resolved");
});
}, () => { }, () => {
// Do nothing when the promise is rejected // Do nothing when the promise is rejected
}).then( () => { }).then( () => {
t.done(); done();
}); });
} }
webglCanvas.onclick = onVrRequestPresentWithDon; webglCanvas.onclick = onVrRequestPresentWithDon;
......
...@@ -13,18 +13,13 @@ resolved or rejected while the DON flow is active. ...@@ -13,18 +13,13 @@ resolved or rejected while the DON flow is active.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("Presentation promise is unresolved during DON flow");
function onVrRequestPresentWithDon() { function onVrRequestPresentWithDon() {
vrDisplay.requestPresent([{source: webglCanvas}]).then( () => { vrDisplay.requestPresent([{source: webglCanvas}]).then( () => {
t.step( () => { assert_unreached("requestPresent promise resolved");
assert_unreached("requestPresent promise resolved");
});
}, () => { }, () => {
t.step( () => { assert_unreached("requestPresent promise rejected");
assert_unreached("requestPresent promise rejected");
});
}); });
window.setTimeout( () => {t.done();}, 2000); window.setTimeout( () => { done(); }, 2000);
} }
webglCanvas.onclick = onVrRequestPresentWithDon; webglCanvas.onclick = onVrRequestPresentWithDon;
</script> </script>
......
...@@ -12,8 +12,7 @@ Tests that requestPresent actually enters VR from Chrome's view ...@@ -12,8 +12,7 @@ Tests that requestPresent actually enters VR from Chrome's view
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("A successful requestPresent call actually enters VR"); window.addEventListener("vrdisplaypresentchange", () => { done(); }, false);
window.addEventListener("vrdisplaypresentchange", () => {t.done();}, false);
</script> </script>
</body> </body>
</html> </html>
...@@ -12,23 +12,19 @@ Tests that screen taps aren't registered while in VR ...@@ -12,23 +12,19 @@ Tests that screen taps aren't registered while in VR
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("Screen taps not registered when in VR");
var numTaps = 0; var numTaps = 0;
webglCanvas.addEventListener("click", () => {numTaps++;}, false); webglCanvas.addEventListener("click", () => {numTaps++;}, false);
function stepVerifyNoInitialTaps() { function stepVerifyNoInitialTaps() {
t.step( () => { assert_equals(numTaps, 0, "No initial taps");
assert_equals(numTaps, 0, "No initial taps");
});
finishJavaScriptStep(); finishJavaScriptStep();
} }
function stepVerifyNoAdditionalTaps() { function stepVerifyNoAdditionalTaps() {
t.step_func_done( () => { // We expect 1 tap from entering VR
// We expect 1 tap from entering VR assert_equals(numTaps, 1,
assert_equals(numTaps, 1, "Only one tap registered after two taps given");
"Only one tap registered after two taps given"); done();
})();
} }
</script> </script>
......
...@@ -8,16 +8,12 @@ working Android selection dialog. ...@@ -8,16 +8,12 @@ working Android selection dialog.
<script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script> <script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script> <script>
var t = async_test("<select> tag works properly in VR browser.");
function onSelectChange(newValue) { function onSelectChange(newValue) {
t.step(() => { assert_not_equals(newValue, "initial_option",
assert_not_equals(newValue, "initial_option", "Newly selected value is the starting value");
"Newly selected value is the starting value"); assert_true(newValue.startsWith("option"),
assert_true(newValue.startsWith("option"), "Didn't get initial option, but didn't get valid option either");
"Didn't get initial option, but didn't get valid option either"); done();
});
t.done();
} }
</script> </script>
<select id="selectbox" onchange="onSelectChange(this.value)"> <select id="selectbox" onchange="onSelectChange(this.value)">
......
...@@ -13,47 +13,39 @@ ...@@ -13,47 +13,39 @@
<input id="textfield" type="text" style="width:100%" oninput="finishJavaScriptStep()" onclick="finishJavaScriptStep()"></input> <input id="textfield" type="text" style="width:100%" oninput="finishJavaScriptStep()" onclick="finishJavaScriptStep()"></input>
</body> </body>
<script> <script>
var t = async_test("Cursor can be repositioned for web text input");
function stepVerifyInitialString(expectedString) { function stepVerifyInitialString(expectedString) {
t.step(() => { let actualString = document.getElementById("textfield").value;
let actualString = document.getElementById("textfield").value; assert_equals(actualString, expectedString,
assert_equals(actualString, expectedString, "Initial text input did not work");
"Initial text input did not work");
});
finishJavaScriptStep(); finishJavaScriptStep();
} }
function stepVerifyDeletedString(expectedString) { function stepVerifyDeletedString(expectedString) {
t.step(() => { let actualString = document.getElementById("textfield").value;
let actualString = document.getElementById("textfield").value; assert_equals(actualString, expectedString,
assert_equals(actualString, expectedString, "Text deletion at repositioned cursor did not work");
"Text deletion at repositioned cursor did not work");
});
finishJavaScriptStep(); finishJavaScriptStep();
} }
function stepVerifyInsertedString(baseString, modifiedCharacter) { function stepVerifyInsertedString(baseString, modifiedCharacter) {
// The actual and given base string should only differ by the single // The actual and given base string should only differ by the single
// given character. // given character.
t.step(() => { let actualString = document.getElementById("textfield").value;
let actualString = document.getElementById("textfield").value; assert_equals(actualString.length, baseString.length,
assert_equals(actualString.length, baseString.length, "Actual and base string lengths differ");
"Actual and base string lengths differ"); let foundModifiedCharacter = false;
let foundModifiedCharacter = false; for (let i = 0; i < baseString.length; i++) {
for (let i = 0; i < baseString.length; i++) { if (baseString.charAt(i) != actualString.charAt(i)) {
if (baseString.charAt(i) != actualString.charAt(i)) { assert_false(foundModifiedCharacter,
assert_false(foundModifiedCharacter, "Found multiple modified characters");
"Found multiple modified characters"); assert_equals(actualString.charAt(i), modifiedCharacter,
assert_equals(actualString.charAt(i), modifiedCharacter, "Found modified character, but did not match expected character");
"Found modified character, but did not match expected character"); foundModifiedCharacter = true;
foundModifiedCharacter = true;
}
} }
assert_true(foundModifiedCharacter, }
"Did not find modified character in string"); assert_true(foundModifiedCharacter,
}); "Did not find modified character in string");
t.done(); done();
} }
</script> </script>
</html> </html>
...@@ -13,34 +13,27 @@ ...@@ -13,34 +13,27 @@
<input id="textfield" type="text" style="width:100%" oninput="finishJavaScriptStep()"> <input id="textfield" type="text" style="width:100%" oninput="finishJavaScriptStep()">
</body> </body>
<script> <script>
var t = async_test("Web input text can be selected");
var numExpectedClicks = 1; var numExpectedClicks = 1;
function stepVerifyInitialString(expectedString) { function stepVerifyInitialString(expectedString) {
t.step(() => { let actualString = document.getElementById("textfield").value;
let actualString = document.getElementById("textfield").value; assert_equals(actualString, expectedString,
assert_equals(actualString, expectedString, "Initial text input did not work");
"Initial text input did not work");
});
finishJavaScriptStep(); finishJavaScriptStep();
} }
function stepVerifyDeletedString(expectedString) { function stepVerifyDeletedString(expectedString) {
t.step(() => { let actualString = document.getElementById("textfield").value;
let actualString = document.getElementById("textfield").value; assert_equals(actualString, expectedString,
assert_equals(actualString, expectedString, "Text deletion at via text selection did not work");
"Text deletion at via text selection did not work");
});
finishJavaScriptStep(); finishJavaScriptStep();
} }
function stepVerifyClearedString() { function stepVerifyClearedString() {
t.step(() => { let actualString = document.getElementById("textfield").value;
let actualString = document.getElementById("textfield").value; assert_equals(actualString.length, 0,
assert_equals(actualString.length, 0, "Text field was not fully cleared by triple click + backspace");
"Text field was not fully cleared by triple click + backspace"); done();
});
t.done();
} }
function onClick(evt) { function onClick(evt) {
......
...@@ -13,8 +13,6 @@ the need for a user gesture. ...@@ -13,8 +13,6 @@ the need for a user gesture.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("Trusted intents allow auto present");
// We need to wait for vrDisplay to be non-null before adding the // We need to wait for vrDisplay to be non-null before adding the
// listener, so poll it // listener, so poll it
function pollVrDisplay() { function pollVrDisplay() {
...@@ -26,11 +24,9 @@ the need for a user gesture. ...@@ -26,11 +24,9 @@ the need for a user gesture.
vrDisplay.requestPresent([{source: webglCanvas}]).then( () => { vrDisplay.requestPresent([{source: webglCanvas}]).then( () => {
// Do nothing // Do nothing
}, () => { }, () => {
t.step( () => { assert_unreached("requestPresent promise rejected");
assert_unreached("requestPresent promise rejected");
});
}).then( () => { }).then( () => {
t.done(); done();
}); });
}, false); }, false);
} }
......
...@@ -12,12 +12,9 @@ Tests that the WebVR API is not present if the flag to enable it is not set. ...@@ -12,12 +12,9 @@ Tests that the WebVR API is not present if the flag to enable it is not set.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
</body> </body>
<script> <script>
var t = async_test("WebVR API is not visible");
if (navigator.getVRDisplays) { if (navigator.getVRDisplays) {
t.step( () => { assert_unreached("API is visible");
assert_unreached("API is visible");
});
} }
t.done(); done();
</script> </script>
</html> </html>
...@@ -12,9 +12,8 @@ Tests WebVR pixel data is submitted correctly. ...@@ -12,9 +12,8 @@ Tests WebVR pixel data is submitted correctly.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("Pixel data is correct");
function finishTest() { function finishTest() {
t.done(); done();
} }
</script> </script>
</body> </body>
......
...@@ -13,8 +13,6 @@ presentation from the VR browser. ...@@ -13,8 +13,6 @@ presentation from the VR browser.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("rAFs continue to fire after presentation re-entry");
function stepVerifyFirstPresent() { function stepVerifyFirstPresent() {
onPresentingAnimationFrameCallback = () => { onPresentingAnimationFrameCallback = () => {
onPresentingAnimationFrameCallback = null; onPresentingAnimationFrameCallback = null;
...@@ -31,7 +29,7 @@ presentation from the VR browser. ...@@ -31,7 +29,7 @@ presentation from the VR browser.
function stepVerifySecondPresent() { function stepVerifySecondPresent() {
onPresentingAnimationFrameCallback = () => { onPresentingAnimationFrameCallback = () => {
t.done(); done();
}; };
} }
</script> </script>
......
...@@ -18,13 +18,11 @@ Tests that the provided WebXR device has the expected capabilities ...@@ -18,13 +18,11 @@ Tests that the provided WebXR device has the expected capabilities
"non-immersive": true, "non-immersive": true,
} }
}; };
var t = async_test("XRDevice capabilities match expectations");
function stepCheckCapabilities(device) { function stepCheckCapabilities(device) {
if (!(device in expectations)) { if (!(device in expectations)) {
t.step_func_done( () => { assert_unreached("Given device " + device + " not in expectations");
assert_unreached("Given device " + device + " not in expectations"); done();
})();
return; return;
} }
...@@ -43,13 +41,11 @@ Tests that the provided WebXR device has the expected capabilities ...@@ -43,13 +41,11 @@ Tests that the provided WebXR device has the expected capabilities
}, () => { }, () => {
supportsImmersive = false; supportsImmersive = false;
}).then( () => { }).then( () => {
t.step( () => { assert_equals(supportsNonImmersive, expected["non-immersive"],
assert_equals(supportsNonImmersive, expected["non-immersive"], 'Device supports non-immersive sessions');
'Device supports non-immersive sessions'); assert_equals(supportsImmersive, expected["immersive"],
assert_equals(supportsImmersive, expected["immersive"], 'Device supports immersive sessions');
'Device supports immersive sessions'); done();
});
t.done();
}); });
}); });
} }
......
...@@ -12,12 +12,9 @@ Tests that the WebXR API is not present if the flag to enable it is not set. ...@@ -12,12 +12,9 @@ Tests that the WebXR API is not present if the flag to enable it is not set.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
</body> </body>
<script> <script>
var t = async_test("WebXR API is not visible");
if (navigator.xr) { if (navigator.xr) {
t.step( () => { assert_unreached("API is visible");
assert_unreached("API is visible");
});
} }
t.done(); done();
</script> </script>
</html> </html>
...@@ -11,13 +11,10 @@ Tests that WebXR returns no devices when OpenVR is disabled. ...@@ -11,13 +11,10 @@ Tests that WebXR returns no devices when OpenVR is disabled.
<script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script> <script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script> <script>
var t = async_test("WebXR returns no devices when OpenVR disabled");
navigator.xr.requestDevice().then( () => { navigator.xr.requestDevice().then( () => {
t.step( () => { assert_unreached("WebXR returned a device");
assert_unreached("WebXR returned a device");
});
}, () => { }, () => {
t.done(); done();
}); });
</script> </script>
</body> </body>
......
...@@ -13,8 +13,6 @@ circumstances. ...@@ -13,8 +13,6 @@ circumstances.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Gamepad returned while using WebXR when expected.");
// We apparently need to register a listener, otherwise all gamepads are // We apparently need to register a listener, otherwise all gamepads are
// always null. // always null.
window.addEventListener("gamepadconnected", function(e) {}); window.addEventListener("gamepadconnected", function(e) {});
...@@ -26,11 +24,9 @@ circumstances. ...@@ -26,11 +24,9 @@ circumstances.
numGamepads++; numGamepads++;
} }
} }
t.step( () => { assert_equals(numGamepads, numExpectedGamepads,
assert_equals(numGamepads, numExpectedGamepads, "Number of returned gamepads matches expectation");
"Number of returned gamepads matches expectation"); done();
});
t.done();
} }
</script> </script>
</body> </body>
......
...@@ -12,8 +12,6 @@ circumstances. Does not have WebXR code. ...@@ -12,8 +12,6 @@ circumstances. Does not have WebXR code.
<script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script> <script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script> <script>
var t = async_test("Gamepad returned while using WebXR when expected.");
// We apparently need to register a listener, otherwise all gamepads are // We apparently need to register a listener, otherwise all gamepads are
// always null. // always null.
window.addEventListener("gamepadconnected", function(e) {}); window.addEventListener("gamepadconnected", function(e) {});
...@@ -25,11 +23,9 @@ circumstances. Does not have WebXR code. ...@@ -25,11 +23,9 @@ circumstances. Does not have WebXR code.
numGamepads++; numGamepads++;
} }
} }
t.step( () => { assert_equals(numGamepads, numExpectedGamepads,
assert_equals(numGamepads, numExpectedGamepads, "Number of returned gamepads matches expectation");
"Number of returned gamepads matches expectation"); done();
});
t.done();
} }
</script> </script>
</body> </body>
......
...@@ -13,8 +13,6 @@ that Daydream controller input is registered when using Daydream View. ...@@ -13,8 +13,6 @@ that Daydream controller input is registered when using Daydream View.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Screen taps/clicks registered as input when in WebXR immersive session");
var selectStartCount = 0; var selectStartCount = 0;
var selectEndCount = 0; var selectEndCount = 0;
var selectCount = 0; var selectCount = 0;
...@@ -24,38 +22,32 @@ that Daydream controller input is registered when using Daydream View. ...@@ -24,38 +22,32 @@ that Daydream controller input is registered when using Daydream View.
function onSelectStart() { function onSelectStart() {
// selectstart should always be fired first, so check that // selectstart should always be fired first, so check that
t.step( () => { assert_true(selectStartCount == selectEndCount,
assert_true(selectStartCount == selectEndCount, 'selectstart fired before selectend');
'selectstart fired before selectend'); assert_true(selectStartCount == selectCount,
assert_true(selectStartCount == selectCount, 'selectstart fired before select');
'selectstart fired before select');
});
selectStartCount++; selectStartCount++;
} }
function onSelectEnd() { function onSelectEnd() {
// selectend should always be fired between selectstart and select // selectend should always be fired between selectstart and select
t.step( () => { assert_true(selectEndCount + 1 == selectStartCount,
assert_true(selectEndCount + 1 == selectStartCount, 'selectend fired after selectstart');
'selectend fired after selectstart'); assert_true(selectEndCount == selectCount,
assert_true(selectEndCount == selectCount, 'selectend fired before select');
'selectend fired before select');
});
selectEndCount++; selectEndCount++;
} }
function onSelect() { function onSelect() {
// select should always be fired last // select should always be fired last
selectCount++; selectCount++;
t.step( () => { assert_true(selectCount == selectStartCount,
assert_true(selectCount == selectStartCount, 'select fired after selectstart');
'select fired after selectstart'); assert_true(selectCount == selectEndCount,
assert_true(selectCount == selectEndCount, 'select fired after selectend');
'select fired after selectend');
});
currentIteration++; currentIteration++;
if (currentIteration == iterations) { if (currentIteration == iterations) {
t.done(); done();
} else if (finishAfterEachInput) { } else if (finishAfterEachInput) {
finishJavaScriptStep(); finishJavaScriptStep();
} }
......
...@@ -12,9 +12,8 @@ Tests WebXR pixel data is submitted correctly. ...@@ -12,9 +12,8 @@ Tests WebXR pixel data is submitted correctly.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Pixel data is correct");
function finishTest() { function finishTest() {
t.done(); done();
} }
</script> </script>
</body> </body>
......
...@@ -15,7 +15,6 @@ test can query for whether each submitted frame used the correct pose. ...@@ -15,7 +15,6 @@ test can query for whether each submitted frame used the correct pose.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Pose data is correct");
var frame_id = 0; var frame_id = 0;
var frame_data_array = {}; var frame_data_array = {};
// We exit presentation before checking stuff that needs the frame of // We exit presentation before checking stuff that needs the frame of
...@@ -80,7 +79,7 @@ test can query for whether each submitted frame used the correct pose. ...@@ -80,7 +79,7 @@ test can query for whether each submitted frame used the correct pose.
} }
function finishTest() { function finishTest() {
t.done(); done();
} }
</script> </script>
</body> </body>
......
...@@ -13,8 +13,6 @@ presentation from the VR browser. ...@@ -13,8 +13,6 @@ presentation from the VR browser.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("rAFs continue to fire after presentation re-entry");
function stepVerifyFirstPresent() { function stepVerifyFirstPresent() {
onImmersiveXRFrameCallback = () => { onImmersiveXRFrameCallback = () => {
onImmersiveXRFrameCallback = null; onImmersiveXRFrameCallback = null;
...@@ -30,7 +28,7 @@ presentation from the VR browser. ...@@ -30,7 +28,7 @@ presentation from the VR browser.
function stepVerifySecondPresent() { function stepVerifySecondPresent() {
onImmersiveXRFrameCallback = () => { onImmersiveXRFrameCallback = () => {
t.done(); done();
}; };
} }
</script> </script>
......
...@@ -12,11 +12,9 @@ Tests that window.rAF continues to fire during a non-immersive session. ...@@ -12,11 +12,9 @@ Tests that window.rAF continues to fire during a non-immersive session.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("window.rAF fires during a non-immersive session");
onMagicWindowXRFrameCallback = function() { onMagicWindowXRFrameCallback = function() {
window.requestAnimationFrame( () => { window.requestAnimationFrame( () => {
t.done(); done();
}); });
} }
</script> </script>
......
...@@ -13,8 +13,6 @@ presentation on Windows/desktop ...@@ -13,8 +13,6 @@ presentation on Windows/desktop
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("window.rAF keeps firing while presenting");
function stepVerifyBeforePresent() { function stepVerifyBeforePresent() {
window.requestAnimationFrame( () => { window.requestAnimationFrame( () => {
finishJavaScriptStep(); finishJavaScriptStep();
...@@ -29,7 +27,7 @@ presentation on Windows/desktop ...@@ -29,7 +27,7 @@ presentation on Windows/desktop
function stepVerifyAfterPresent() { function stepVerifyAfterPresent() {
window.requestAnimationFrame( () => { window.requestAnimationFrame( () => {
t.done(); done();
}); });
} }
</script> </script>
......
...@@ -13,7 +13,6 @@ on Android. ...@@ -13,7 +13,6 @@ on Android.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script> <script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("window.rAF stops while presenting");
var numWindowRafs = 0; var numWindowRafs = 0;
function stepVerifyBeforePresent() { function stepVerifyBeforePresent() {
...@@ -25,12 +24,10 @@ on Android. ...@@ -25,12 +24,10 @@ on Android.
function stepVerifyDuringPresent() { function stepVerifyDuringPresent() {
let handle = window.requestAnimationFrame( () => { let handle = window.requestAnimationFrame( () => {
numWindowRafs++; numWindowRafs++;
t.step( () => { // Even though we wait for setVSyncPaused to be called Java-side,
// Even though we wait for setVSyncPaused to be called Java-side, // 1-2 frames might still get window rAFs due to the call to the
// 1-2 frames might still get window rAFs due to the call to the // renderer being asynchronous.
// renderer being asynchronous. assert_less_than(numWindowRafs, 3);
assert_less_than(numWindowRafs, 3);
});
}); });
window.setTimeout( () => { window.setTimeout( () => {
window.cancelAnimationFrame(handle); window.cancelAnimationFrame(handle);
...@@ -40,7 +37,7 @@ on Android. ...@@ -40,7 +37,7 @@ on Android.
function stepVerifyAfterPresent() { function stepVerifyAfterPresent() {
window.requestAnimationFrame( () => { window.requestAnimationFrame( () => {
t.done(); done();
}); });
} }
</script> </script>
......
...@@ -12,7 +12,6 @@ Tests that WebXR doesn't update frame data when the tab is not focused ...@@ -12,7 +12,6 @@ Tests that WebXR doesn't update frame data when the tab is not focused
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Test pose data in unfocused tab");
var pose = null; var pose = null;
let counter = 0; let counter = 0;
...@@ -28,12 +27,10 @@ Tests that WebXR doesn't update frame data when the tab is not focused ...@@ -28,12 +27,10 @@ Tests that WebXR doesn't update frame data when the tab is not focused
} }
onMagicWindowXRFrameCallback = null; onMagicWindowXRFrameCallback = null;
pose = frame.getDevicePose(sessionInfos[sessionTypes.MAGIC_WINDOW].currentFrameOfRef); pose = frame.getDevicePose(sessionInfos[sessionTypes.MAGIC_WINDOW].currentFrameOfRef);
t.step( () => { assert_true(pose != null,
assert_true(pose != null, "getDevicePose returned a non-null object");
"getDevicePose returned a non-null object"); assert_true(pose instanceof XRDevicePose,
assert_true(pose instanceof XRDevicePose, "getDevicePose returned an XRDevicePose")
"getDevicePose returned an XRDevicePose")
});
finishJavaScriptStep(); finishJavaScriptStep();
} }
// Make sure at least one rAF call has happened so we get valid data // Make sure at least one rAF call has happened so we get valid data
...@@ -43,12 +40,10 @@ Tests that WebXR doesn't update frame data when the tab is not focused ...@@ -43,12 +40,10 @@ Tests that WebXR doesn't update frame data when the tab is not focused
function stepCheckFrameDataWhileNonFocusedTab() { function stepCheckFrameDataWhileNonFocusedTab() {
// Unlike WebVR, WebXR doesn't fire rAFs when in a different tab // Unlike WebVR, WebXR doesn't fire rAFs when in a different tab
onMagicWindowXRFrameCallback = function() { onMagicWindowXRFrameCallback = function() {
t.step( () => { assert_unreached("Magic window fired rAF while in a different tab");
assert_unreached("Magic window fired rAF while in a different tab");
});
} }
window.setTimeout( () => { window.setTimeout( () => {
t.done(); done();
}, 1000); }, 1000);
} }
</script> </script>
......
...@@ -13,7 +13,6 @@ focus, that the presenting frame still receives input. ...@@ -13,7 +13,6 @@ focus, that the presenting frame still receives input.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Focus is locked to immersive session");
var rafCount = 0; var rafCount = 0;
function stepSetupFocusLoss() { function stepSetupFocusLoss() {
...@@ -26,7 +25,7 @@ focus, that the presenting frame still receives input. ...@@ -26,7 +25,7 @@ focus, that the presenting frame still receives input.
window.onblur = function() { window.onblur = function() {
onImmersiveXRFrameCallback = function() { onImmersiveXRFrameCallback = function() {
if (rafCount == 3) { if (rafCount == 3) {
t.done(); done();
} }
rafCount++; rafCount++;
} }
......
...@@ -13,16 +13,13 @@ the DON flow is canceled. ...@@ -13,16 +13,13 @@ the DON flow is canceled.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Presentation promise is rejected after DON canceled");
function onImmersiveRequestWithDon() { function onImmersiveRequestWithDon() {
xrDevice.requestSession({immersive: true}).then( (session) => { xrDevice.requestSession({immersive: true}).then( (session) => {
t.step( () => { assert_unreached("requestPresent promise resolved");
assert_unreached("requestPresent promise resolved");
});
}, () => { }, () => {
// Do nothing when the promise is rejected // Do nothing when the promise is rejected
}).then( () => { }).then( () => {
t.done(); done();
}); });
} }
webglCanvas.onclick = onImmersiveRequestWithDon; webglCanvas.onclick = onImmersiveRequestWithDon;
......
...@@ -13,18 +13,13 @@ resolved or rejected while the DON flow is active. ...@@ -13,18 +13,13 @@ resolved or rejected while the DON flow is active.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Presentation promise is unresolved during DON flow");
function onImmersiveRequestWithDon() { function onImmersiveRequestWithDon() {
xrDevice.requestSession({immersive: true}).then( (session) => { xrDevice.requestSession({immersive: true}).then( (session) => {
t.step( () => { assert_unreached("requestSession promise resolved");
assert_unreached("requestSession promise resolved");
});
}, () => { }, () => {
t.step( () => { assert_unreached("requestSession promise rejected");
assert_unreached("requestSession promise rejected");
});
}); });
window.setTimeout( () => {t.done();}, 2000); window.setTimeout( () => { done(); }, 2000);
} }
webglCanvas.onclick = onImmersiveRequestWithDon; webglCanvas.onclick = onImmersiveRequestWithDon;
</script> </script>
......
...@@ -12,23 +12,19 @@ Tests that screen taps aren't registered while in an immersive WebXR session. ...@@ -12,23 +12,19 @@ Tests that screen taps aren't registered while in an immersive WebXR session.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("Screen taps not registered when in immersive session");
var numTaps = 0; var numTaps = 0;
webglCanvas.addEventListener("click", () => {numTaps++;}, false); webglCanvas.addEventListener("click", () => {numTaps++;}, false);
function stepVerifyNoInitialTaps() { function stepVerifyNoInitialTaps() {
t.step( () => { assert_equals(numTaps, 0, "No initial taps");
assert_equals(numTaps, 0, "No initial taps");
});
finishJavaScriptStep(); finishJavaScriptStep();
} }
function stepVerifyNoAdditionalTaps() { function stepVerifyNoAdditionalTaps() {
t.step_func_done( () => { // We expect 1 tap from entering VR
// We expect 1 tap from entering VR assert_equals(numTaps, 1,
assert_equals(numTaps, 1, "Only one tap registered after two taps given");
"Only one tap registered after two taps given"); done();
})();
} }
</script> </script>
......
...@@ -13,8 +13,6 @@ immersive session on Windows/desktop ...@@ -13,8 +13,6 @@ immersive session on Windows/desktop
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("window.rAF keeps firing while in immersive session");
function stepVerifyBeforePresent() { function stepVerifyBeforePresent() {
window.requestAnimationFrame( () => { window.requestAnimationFrame( () => {
finishJavaScriptStep(); finishJavaScriptStep();
...@@ -29,7 +27,7 @@ immersive session on Windows/desktop ...@@ -29,7 +27,7 @@ immersive session on Windows/desktop
function stepVerifyAfterPresent() { function stepVerifyAfterPresent() {
window.requestAnimationFrame( () => { window.requestAnimationFrame( () => {
t.done(); done();
}); });
} }
</script> </script>
......
...@@ -13,8 +13,6 @@ on Android. ...@@ -13,8 +13,6 @@ on Android.
<script src="../resources/webxr_e2e.js"></script> <script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script> <script src="../resources/webxr_boilerplate.js"></script>
<script> <script>
var t = async_test("window.rAF stops while presenting");
function stepVerifyBeforePresent() { function stepVerifyBeforePresent() {
window.requestAnimationFrame( () => { window.requestAnimationFrame( () => {
finishJavaScriptStep(); finishJavaScriptStep();
...@@ -24,12 +22,10 @@ on Android. ...@@ -24,12 +22,10 @@ on Android.
function stepVerifyDuringPresent() { function stepVerifyDuringPresent() {
let handle = window.requestAnimationFrame( () => { let handle = window.requestAnimationFrame( () => {
numWindowRafs++; numWindowRafs++;
t.step( () => { // Even though we wait for setVSyncPaused to be called Java-side,
// Even though we wait for setVSyncPaused to be called Java-side, // 1-2 frames might still get window rAFs due to the call to the
// 1-2 frames might still get window rAFs due to the call to the // renderer being asynchronous.
// renderer being asynchronous. assert_less_than(numWindowRafs, 3);
assert_less_than(numWindowRafs, 3);
});
}); });
window.setTimeout( () => { window.setTimeout( () => {
window.cancelAnimationFrame(handle); window.cancelAnimationFrame(handle);
...@@ -39,7 +35,7 @@ on Android. ...@@ -39,7 +35,7 @@ on Android.
function stepVerifyAfterPresent() { function stepVerifyAfterPresent() {
window.requestAnimationFrame( () => { window.requestAnimationFrame( () => {
t.done(); done();
}); });
} }
</script> </script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment