aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/web-locks/idlharness.tentative.https.any.js
blob: 168f57328b839ed7f9dbf17e98bbbd5deedc146a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: global=window,dedicatedworker,sharedworker,serviceworker

'use strict';

promise_test(async t => {
  const srcs = ['./web-locks.idl', '/interfaces/html.idl'];
  const [weblocks, html] = await Promise.all(
    srcs.map(i => fetch(i).then(r => r.text())));

  const idl_array = new IdlArray();
  idl_array.add_idls(weblocks);
  idl_array.add_dependency_idls(html);

  try {
    await navigator.locks.request('name', l => { self.lock = l; });
  } catch (e) {
    // Surfaced in idlharness.js's test_object below.
  }

  idl_array.add_objects({
    LockManager: ['navigator.locks'],
    Lock: ['lock'],
  });

  if (self.Window) {
    idl_array.add_objects({ Navigator: ['navigator'] });
  } else {
    idl_array.add_objects({ WorkerNavigator: ['navigator'] });
  }

  idl_array.test();
});