Bug 1632435 [wpt PR 23200] - Improve web engine detection in webxr_util.js, a=testonly

Automatic update from web-platform-tests
Improve web engine detection in webxr_util.js (#23200)

The check (window.XRTest === undefined) is not valid to discriminate between Chromium and other browsers. Improve engine detection so that we don't end up accessing entities that do not exist in other engines (like navigator.xr.test.Debug).
--

wpt-commits: d9312410d445b129727af4fbd4aa8733e99b0e64
wpt-pr: 23200
This commit is contained in:
Sergio 2020-04-28 11:47:03 +00:00
Родитель 84a4bea45d
Коммит 04020c83f0
1 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -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;
}