Skip to content

Commit

Permalink
Bug 1659606 [wpt PR 25062] - [WPT] Only load *.mojom.js through loadM…
Browse files Browse the repository at this point in the history
…ojoResources, a=testonly

Automatic update from web-platform-tests
[WPT] Only load *.mojom.js through loadMojoResources

* Load other resources separately
* Throw from loadMojoResources when a path is not /gen/.../*.mojom.js

Bug: 1116600
Change-Id: I4f9dbc4459583480ce202e65c789397422a282fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2358904
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798922}

--

wpt-commits: db9a10cb04de8883c4c04dd57683436f6bb47917
wpt-pr: 25062
  • Loading branch information
Hexcles authored and moz-wptsync-bot committed Aug 25, 2020
1 parent 79c68bd commit 33e5067
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
18 changes: 11 additions & 7 deletions testing/web-platform/tests/bluetooth/resources/bluetooth-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ function loadScript(path) {
* @returns {Promise<void>} Resolves when Chromium specific setup is complete.
*/
async function performChromiumSetup() {
const chromiumResources = [
'/gen/content/test/data/mojo_web_test_helper_test.mojom.js',
'/gen/device/bluetooth/public/mojom/uuid.mojom.js',
'/gen/url/mojom/origin.mojom.js',
'/gen/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.js',
'/gen/content/shell/common/web_test/fake_bluetooth_chooser.mojom.js',
];
// Determine path prefixes.
let resPrefix = '/resources';
let extra = ['/resources/chromium/web-bluetooth-test.js'];
Expand All @@ -47,13 +54,10 @@ async function performChromiumSetup() {
return;
}

await loadMojoResources([
'/gen/content/test/data/mojo_web_test_helper_test.mojom.js',
'/gen/device/bluetooth/public/mojom/uuid.mojom.js',
'/gen/url/mojom/origin.mojom.js',
'/gen/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.js',
'/gen/content/shell/common/web_test/fake_bluetooth_chooser.mojom.js',
].concat(extra));
await loadMojoResources(chromiumResources);
for (const path of extra) {
await loadScript(path);
}

// Call setBluetoothFakeAdapter() to clean up any fake adapters left over by
// legacy tests. Legacy tests that use setBluetoothFakeAdapter() sometimes
Expand Down
21 changes: 11 additions & 10 deletions testing/web-platform/tests/resources/test-only-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ function loadScript(path) {
*
* @param {Array.<string>} resources - A list of scripts to load: Mojo JS
* bindings should be of the form '/gen/../*.mojom.js', the ordering of which
* does not matter. Do not include mojo_bindings.js in this list. You may
* include other non-mojom.js scripts for convenience.
* does not matter. Do not include mojo_bindings.js in this list.
* @returns {Promise}
*/
async function loadMojoResources(resources) {
Expand All @@ -66,18 +65,20 @@ async function loadMojoResources(resources) {
genPrefix = 'file://';
}

// We want to load mojo_bindings.js separately to set mojo.config.
if (resources.some(p => p.endsWith('/mojo_bindings.js'))) {
throw new Error('Do not load mojo_bindings.js explicitly.');
for (const path of resources) {
// We want to load mojo_bindings.js separately to set mojo.config.
if (path.endsWith('/mojo_bindings.js')) {
throw new Error('Do not load mojo_bindings.js explicitly.');
}
if (! /^\/gen\/.*\.mojom\.js$/.test(path)) {
throw new Error(`Unrecognized resource path: ${path}`);
}
}

await loadScript(genPrefix + '/gen/layout_test_data/mojo/public/js/mojo_bindings.js');
mojo.config.autoLoadMojomDeps = false;

for (const path of resources) {
if (path.startsWith('/gen/')) {
await loadScript(genPrefix + path);
} else {
await loadScript(path);
}
await loadScript(genPrefix + path);
}
}
12 changes: 8 additions & 4 deletions testing/web-platform/tests/webxr/resources/webxr_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function forEachWebxrObject(callback) {

// Code for loading test API in Chromium.
async function loadChromiumResources() {
let chromiumResources = [
const chromiumResources = [
'/gen/mojo/public/mojom/base/time.mojom.js',
'/gen/mojo/public/mojom/base/shared_memory.mojom.js',
'/gen/mojo/public/mojom/base/unguessable_token.mojom.js',
Expand All @@ -217,22 +217,26 @@ async function loadChromiumResources() {
'/gen/ui/display/mojom/display.mojom.js',
'/gen/device/gamepad/public/mojom/gamepad.mojom.js',
'/gen/device/vr/public/mojom/vr_service.mojom.js',
];

let extraResources = [
'/resources/chromium/webxr-test-math-helper.js',
'/resources/chromium/webxr-test.js',
// Required only by resources/chromium/webxr-test.js
'/resources/testdriver.js',
'/resources/testdriver-vendor.js',
];

// This infrastructure is also used by Chromium-specific internal tests that
// may need additional resources (e.g. internal API extensions), this allows
// those tests to rely on this infrastructure while ensuring that no tests
// make it into public WPTs that rely on APIs outside of the webxr test API.
if (typeof(additionalChromiumResources) !== 'undefined') {
chromiumResources = chromiumResources.concat(additionalChromiumResources);
extraResources = extraResources.concat(additionalChromiumResources);
}

await loadMojoResources(chromiumResources);
for (const path of extraResources) {
await loadScript(path);
}

xr_debug = navigator.xr.test.Debug;
}
Expand Down

0 comments on commit 33e5067

Please sign in to comment.