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 527145 4ccc79413bc06d847d41d0a35a7fc58d8940ad06
parent 527144 eca719b7e4ac86ec2e7fff7ed182aa30a0b0dcea
child 527146 897d8f75940cfbd4e1f1675f0899ff9f7601e71c
push id114648
push userwptsync@mozilla.com
push dateThu, 30 Apr 2020 19:15:02 +0000
treeherderautoland@2545233d9410 [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();
+});