Skip to content

Commit ca3e490

Browse files
Hexcleschromium-wpt-export-bot
authored andcommitted
[WPT] Refactor WebBluetooth tests to use test-only-api.js
And remove unused mojom.js files. Bug: 1094512 Change-Id: Ibe8503d72fff30b96248c14647b65481c06c7b2f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2350482 Commit-Queue: Robert Ma <[email protected]> Reviewed-by: Reilly Grant <[email protected]> Auto-Submit: Robert Ma <[email protected]> Cr-Commit-Position: refs/heads/master@{#798691}
1 parent bb4b0c3 commit ca3e490

File tree

5 files changed

+42
-309
lines changed

5 files changed

+42
-309
lines changed

bluetooth/resources/bluetooth-test.js

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,6 @@ function loadScript(path) {
1818
return promise;
1919
}
2020

21-
/**
22-
* Loads the scripts in |paths|.
23-
* @param {string[]} paths
24-
* @returns {Promise<void>} A promise chain that resolves when all scripts have
25-
* finished loading.
26-
*/
27-
async function loadScripts(paths) {
28-
for (let path of paths) {
29-
await loadScript(path);
30-
}
31-
return;
32-
}
33-
3421
/**
3522
* Performs the Chromium specific setup necessary to run the tests in the
3623
* Chromium browser. This test file is shared between Web Platform Tests and
@@ -42,36 +29,30 @@ async function loadScripts(paths) {
4229
* @returns {Promise<void>} Resolves when Chromium specific setup is complete.
4330
*/
4431
async function performChromiumSetup() {
45-
// Make sure we are actually on Chromium with Mojo enabled.
46-
if (typeof Mojo === 'undefined') {
47-
return;
48-
}
49-
50-
// Load the Chromium-specific resources.
51-
let prefix = '/resources/chromium';
52-
let genPrefix = '/gen';
53-
let extra = [];
32+
// Determine path prefixes.
33+
let resPrefix = '/resources';
34+
let extra = ['/resources/chromium/web-bluetooth-test.js'];
5435
const pathname = window.location.pathname;
55-
if (pathname.includes('/LayoutTests/') || pathname.includes('/web_tests/')) {
56-
let root = pathname.match(/.*(?:LayoutTests|web_tests)/);
57-
prefix = `${root}/external/wpt/resources/chromium`;
36+
if (pathname.includes('/web_tests/')) {
37+
let root = pathname.match(/.*(?:web_tests)/);
38+
resPrefix = `${root}/external/wpt/resources`;
5839
extra = [
40+
`${root}/external/wpt/resources/chromium/web-bluetooth-test.js`,
5941
`${root}/resources/bluetooth/bluetooth-fake-adapter.js`,
6042
];
61-
genPrefix = 'file:///gen';
62-
} else if (window.location.pathname.startsWith('/bluetooth/https/')) {
63-
extra = [
64-
'/js-test-resources/bluetooth/bluetooth-fake-adapter.js',
65-
];
6643
}
67-
await loadScripts([
68-
`${genPrefix}/layout_test_data/mojo/public/js/mojo_bindings.js`,
69-
`${genPrefix}/content/test/data/mojo_web_test_helper_test.mojom.js`,
70-
`${genPrefix}/device/bluetooth/public/mojom/uuid.mojom.js`,
71-
`${genPrefix}/url/mojom/origin.mojom.js`,
72-
`${genPrefix}/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.js`,
73-
`${genPrefix}/content/shell/common/web_test/fake_bluetooth_chooser.mojom.js`,
74-
`${prefix}/web-bluetooth-test.js`,
44+
45+
await loadScript(`${resPrefix}/test-only-api.js`);
46+
if (!isChromiumBased) {
47+
return;
48+
}
49+
50+
await loadMojoResources([
51+
'/gen/content/test/data/mojo_web_test_helper_test.mojom.js',
52+
'/gen/device/bluetooth/public/mojom/uuid.mojom.js',
53+
'/gen/url/mojom/origin.mojom.js',
54+
'/gen/device/bluetooth/public/mojom/test/fake_bluetooth.mojom.js',
55+
'/gen/content/shell/common/web_test/fake_bluetooth_chooser.mojom.js',
7556
].concat(extra));
7657

7758
// Call setBluetoothFakeAdapter() to clean up any fake adapters left over by
@@ -98,8 +79,10 @@ async function performChromiumSetup() {
9879
*/
9980
function bluetooth_test(test_function, name, properties) {
10081
return promise_test(async (t) => {
82+
assert_implements(navigator.bluetooth, 'missing navigator.bluetooth');
10183
// Trigger Chromium-specific setup.
10284
await performChromiumSetup();
85+
assert_implements(navigator.bluetooth.test, 'missing navigator.bluetooth.test');
10386
await test_function(t);
10487
let consumed = await navigator.bluetooth.test.allResponsesConsumed();
10588
assert_true(consumed);

lint.ignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,12 +714,13 @@ WEB-PLATFORM.TEST:web-bundle/subresource-loading/subresource-loading-from-web-bu
714714
# Tests that depend on resources in /gen/ in Chromium:
715715
# https://github.com/web-platform-tests/wpt/issues/16455
716716
# Please consult with [email protected] before adding more.
717-
MISSING DEPENDENCY: resources/test-only-api.js
717+
MISSING DEPENDENCY: bluetooth/resources/bluetooth-test.js
718718
MISSING DEPENDENCY: contacts/resources/helpers.js
719719
MISSING DEPENDENCY: credential-management/support/otpcredential-helper.js
720720
MISSING DEPENDENCY: generic-sensor/resources/generic-sensor-helpers.js
721721
MISSING DEPENDENCY: idle-detection/interceptor.https.html
722722
MISSING DEPENDENCY: orientation-event/resources/orientation-event-helpers.js
723+
MISSING DEPENDENCY: resources/test-only-api.js
723724
MISSING DEPENDENCY: screen_enumeration/resources/screenenumeration-helpers.js
724725
MISSING DEPENDENCY: shape-detection/resources/shapedetection-helpers.js
725726
MISSING DEPENDENCY: web-nfc/resources/nfc-helpers.js
@@ -729,7 +730,6 @@ MISSING DEPENDENCY: webxr/resources/webxr_util.js
729730
# TODO(Hexcles): delete these files once we include them in mojojs.zip.
730731
MOJOM-JS: resources/chromium/image_capture.mojom.js
731732
MOJOM-JS: resources/chromium/sensor_provider.mojom.js
732-
MOJOM-JS: resources/chromium/mojo_web_test_helper_test.mojom.js
733733
MOJOM-JS: resources/chromium/sensor.mojom.js
734734

735735
# Tests that are false positives for using Ahem as a system font

resources/chromium/mojo_web_test_helper_test.mojom.js

Lines changed: 0 additions & 264 deletions
This file was deleted.

resources/chromium/mojo_web_test_helper_test.mojom.js.headers

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)