Bug 1630741 [wpt PR 23031] - Add WebKit support for WebXR tests, a=testonly
authorSergio <svillar@igalia.com>
Tue, 28 Apr 2020 11:33:16 +0000
changeset 527522 fbd868c8613c7e913785d57e9c2c6728c869a967
parent 527521 d8414923398ea820da780d25e92e8ac9011d8090
child 527523 bc8c1032a6b280da60d0d9de02d8186e8a72a2cc
push id37368
push userbtara@mozilla.com
push dateFri, 01 May 2020 21:45:51 +0000
treeherdermozilla-central@0f9c5a59e45d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1630741, 23031
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1630741 [wpt PR 23031] - Add WebKit support for WebXR tests, a=testonly Automatic update from web-platform-tests Add WebKit support for WebXR tests (#23031) WebXR and the WebXR testing API are in the process of being implemented. The way we designed the integration of the test API with the rest of the engine is by adding WebXRTest to an object called Internals which is injected in JSC and that provides JS access to WebKit's internal APIs. That Internals object is only available for testing so we can ensure that WebXRTest is never exposed to the Web. -- wpt-commits: 603ea91ccada76c2796bc51d1cf027882582cd83 wpt-pr: 23031
testing/web-platform/tests/lint.whitelist
testing/web-platform/tests/webxr/resources/webxr_util.js
--- a/testing/web-platform/tests/lint.whitelist
+++ b/testing/web-platform/tests/lint.whitelist
@@ -679,16 +679,17 @@ MISSING-LINK: css/filter-effects/*.any.j
 LAYOUTTESTS APIS: import-maps/common/resources/common-test-helper.js
 LAYOUTTESTS APIS: resources/chromium/enable-hyperlink-auditing.js
 LAYOUTTESTS APIS: resources/chromium/generic_sensor_mocks.js
 LAYOUTTESTS APIS: resources/chromium/nfc-mock.js
 LAYOUTTESTS APIS: resources/chromium/webxr-test.js
 LAYOUTTESTS APIS: web-nfc/NDEFReader-document-hidden-manual.https.html
 LAYOUTTESTS APIS: web-nfc/NDEFReader_scan.https.html
 LAYOUTTESTS APIS: web-nfc/NDEFWriter_write.https.html
+LAYOUTTESTS APIS: webxr/resources/webxr_util.js
 
 # Signed Exchange files have hard-coded URLs in the certUrl field
 WEB-PLATFORM.TEST:signed-exchange/resources/*.sxg
 WEB-PLATFORM.TEST:signed-exchange/appcache/resources/*.sxg
 WEB-PLATFORM.TEST:signed-exchange/resources/generate-test-sxgs.sh
 
 # Web Bundle files have hard-coded URLs
 WEB-PLATFORM.TEST:web-bundle/resources/generate-test-wbns.sh
--- a/testing/web-platform/tests/webxr/resources/webxr_util.js
+++ b/testing/web-platform/tests/webxr/resources/webxr_util.js
@@ -17,16 +17,21 @@ function xr_promise_test(name, func, pro
     xr_debug(name, 'setup');
 
     if (window.XRTest === undefined) {
       // Chrome setup
       await loadChromiumResources;
       xr_debug = navigator.xr.test.Debug;
     }
 
+    if (self.internals && internals.xrTest && navigator.xr) {
+      // WebKit setup
+      await setupWebKitWebXRTestAPI;
+    }
+
     // Ensure that any devices are disconnected when done. If this were done in
     // a .then() for the success case, a test that expected failure would
     // already be marked done at the time that runs and the shutdown would
     // interfere with the next test.
     t.add_cleanup(async () => {
       // Ensure system state is cleaned up.
       xr_debug(name, 'cleanup');
       await navigator.xr.test.disconnectAllDevices();
@@ -194,8 +199,21 @@ let loadChromiumResources = Promise.reso
       chain = chain.then(() => new Promise(resolve => {
                            script.onload = () => resolve();
                          }));
       document.head.appendChild(script);
   });
 
   return chain;
 });
+
+let setupWebKitWebXRTestAPI = Promise.resolve().then(() => {
+  if (!self.internals) {
+    // Do nothing on non-WebKit-based browsers.
+    return;
+  }
+
+  // WebKit setup. The internals object is used by the WebKit test runner
+  // to provide JS access to internal APIs. In this case it's used to
+  // ensure that XRTest is only exposed to wpt tests.
+  navigator.xr.test = internals.xrTest;
+  return Promise.resolve();
+});