diff --git a/testing/web-platform/tests/webxr/resources/webxr_util.js b/testing/web-platform/tests/webxr/resources/webxr_util.js index 188284e5ec4c..20585ef73797 100644 --- a/testing/web-platform/tests/webxr/resources/webxr_util.js +++ b/testing/web-platform/tests/webxr/resources/webxr_util.js @@ -10,19 +10,21 @@ // Debugging message helper, by default does nothing. Implementations can // override this. var xr_debug = function(name, msg) {} +var isChromiumBased = 'MojoInterfaceInterceptor' in self; +var isWebKitBased = 'internals' in self && 'xrTest' in internals; function xr_promise_test(name, func, properties) { promise_test(async (t) => { // Perform any required test setup: xr_debug(name, 'setup'); - if (window.XRTest === undefined) { + if (isChromiumBased) { // Chrome setup await loadChromiumResources; xr_debug = navigator.xr.test.Debug; } - if (self.internals && internals.xrTest && navigator.xr) { + if (isWebKitBased) { // WebKit setup await setupWebKitWebXRTestAPI; } @@ -161,7 +163,7 @@ function forEachWebxrObject(callback) { // Code for loading test API in Chromium. let loadChromiumResources = Promise.resolve().then(() => { - if (!('MojoInterfaceInterceptor' in self)) { + if (!isChromiumBased) { // Do nothing on non-Chromium-based browsers or when the Mojo bindings are // not present in the global namespace. return; @@ -206,7 +208,7 @@ let loadChromiumResources = Promise.resolve().then(() => { }); let setupWebKitWebXRTestAPI = Promise.resolve().then(() => { - if (!self.internals || !internals.xrTest) { + if (!isWebKitBased) { // Do nothing on non-WebKit-based browsers. return; }