Skip to content

Commit

Permalink
Ensure all xr_promise_test calls wait for DOMContentLoaded when neces…
Browse files Browse the repository at this point in the history
…sary.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
  • Loading branch information
jdm authored and servo-wpt-sync committed Oct 9, 2024
1 parent c04ac8e commit a95f93a
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions webxr/resources/webxr_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// override this.
var xr_debug = function(name, msg) {};

let loaded = new Promise(resolve => document.addEventListener('DOMContentLoaded', resolve));

function xr_promise_test(name, func, properties, glContextType, glContextProperties) {
promise_test(async (t) => {
if (glContextType === 'webgl2') {
Expand Down Expand Up @@ -60,6 +62,7 @@ function xr_promise_test(name, func, properties, glContextType, glContextPropert
let canvas = null;
if (glContextType) {
canvas = document.createElement('canvas');
await loaded;
document.body.appendChild(canvas);
gl = canvas.getContext(glContextType, glContextProperties);
}
Expand Down Expand Up @@ -161,22 +164,20 @@ function xr_session_promise_test(
}));
}

document.addEventListener('DOMContentLoaded', () => {
xr_promise_test(
name + ' - webgl',
runTest,
properties,
'webgl',
{alpha: false, antialias: false, ...glcontextProperties}
);
xr_promise_test(
name + ' - webgl2',
runTest,
properties,
'webgl2',
{alpha: false, antialias: false, ...glcontextProperties}
);
});
xr_promise_test(
name + ' - webgl',
runTest,
properties,
'webgl',
{alpha: false, antialias: false, ...glcontextProperties}
);
xr_promise_test(
name + ' - webgl2',
runTest,
properties,
'webgl2',
{alpha: false, antialias: false, ...glcontextProperties}
);
}


Expand Down

0 comments on commit a95f93a

Please sign in to comment.