@@ -18,19 +18,6 @@ function loadScript(path) {
18
18
return promise ;
19
19
}
20
20
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
-
34
21
/**
35
22
* Performs the Chromium specific setup necessary to run the tests in the
36
23
* Chromium browser. This test file is shared between Web Platform Tests and
@@ -42,36 +29,30 @@ async function loadScripts(paths) {
42
29
* @returns {Promise<void> } Resolves when Chromium specific setup is complete.
43
30
*/
44
31
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' ] ;
54
35
const pathname = window . location . pathname ;
55
- if ( pathname . includes ( '/LayoutTests/' ) || pathname . includes ( '/ web_tests/') ) {
56
- let root = pathname . match ( / .* (?: L a y o u t T e s t s | w e b _ t e s t s ) / ) ;
57
- prefix = `${ root } /external/wpt/resources/chromium ` ;
36
+ if ( pathname . includes ( '/web_tests/' ) ) {
37
+ let root = pathname . match ( / .* (?: w e b _ t e s t s ) / ) ;
38
+ resPrefix = `${ root } /external/wpt/resources` ;
58
39
extra = [
40
+ `${ root } /external/wpt/resources/chromium/web-bluetooth-test.js` ,
59
41
`${ root } /resources/bluetooth/bluetooth-fake-adapter.js` ,
60
42
] ;
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
- ] ;
66
43
}
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' ,
75
56
] . concat ( extra ) ) ;
76
57
77
58
// Call setBluetoothFakeAdapter() to clean up any fake adapters left over by
@@ -98,8 +79,10 @@ async function performChromiumSetup() {
98
79
*/
99
80
function bluetooth_test ( test_function , name , properties ) {
100
81
return promise_test ( async ( t ) => {
82
+ assert_implements ( navigator . bluetooth , 'missing navigator.bluetooth' ) ;
101
83
// Trigger Chromium-specific setup.
102
84
await performChromiumSetup ( ) ;
85
+ assert_implements ( navigator . bluetooth . test , 'missing navigator.bluetooth.test' ) ;
103
86
await test_function ( t ) ;
104
87
let consumed = await navigator . bluetooth . test . allResponsesConsumed ( ) ;
105
88
assert_true ( consumed ) ;
0 commit comments