From b68d4ed8096e5af77b06ee15fb803bf91a84b5a0 Mon Sep 17 00:00:00 2001 From: Sergio Date: Tue, 28 Apr 2020 11:33:16 +0000 Subject: [PATCH] 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 | 1 + .../tests/webxr/resources/webxr_util.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/testing/web-platform/tests/lint.whitelist b/testing/web-platform/tests/lint.whitelist index 526d6b765bd3..421022993961 100644 --- a/testing/web-platform/tests/lint.whitelist +++ b/testing/web-platform/tests/lint.whitelist @@ -684,6 +684,7 @@ 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 diff --git a/testing/web-platform/tests/webxr/resources/webxr_util.js b/testing/web-platform/tests/webxr/resources/webxr_util.js index c9f7e81b094a..65c39844b15d 100644 --- a/testing/web-platform/tests/webxr/resources/webxr_util.js +++ b/testing/web-platform/tests/webxr/resources/webxr_util.js @@ -22,6 +22,11 @@ function xr_promise_test(name, func, properties) { 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 @@ -199,3 +204,16 @@ let loadChromiumResources = Promise.resolve().then(() => { 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(); +});