Skip to content

Commit 9172051

Browse files
Uzlopakgithub-actions[bot]
authored andcommitted
chore: update WPT
1 parent 6bb527e commit 9172051

File tree

3 files changed

+107
-1
lines changed

3 files changed

+107
-1
lines changed

test/fixtures/wpt/resources/testharness.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4788,7 +4788,8 @@
47884788
return META_TITLE;
47894789
}
47904790
if ('location' in global_scope && 'pathname' in location) {
4791-
return location.pathname.substring(location.pathname.lastIndexOf('/') + 1, location.pathname.indexOf('.'));
4791+
var filename = location.pathname.substring(location.pathname.lastIndexOf('/') + 1);
4792+
return filename.substring(0, filename.indexOf('.'));
47924793
}
47934794
return "Untitled";
47944795
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
'use strict'
2+
3+
// Convert `manufacturerData` to an array of bluetooth.BluetoothManufacturerData
4+
// defined in
5+
// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-bidi-definitions.
6+
function convertToBidiManufacturerData(manufacturerData) {
7+
const bidiManufacturerData = [];
8+
for (const key in manufacturerData) {
9+
bidiManufacturerData.push(
10+
{key: parseInt(key), data: btoa(manufacturerData[key].buffer)})
11+
}
12+
return bidiManufacturerData;
13+
}
14+
15+
class FakeBluetooth {
16+
constructor() {
17+
this.fake_central_ = null;
18+
}
19+
20+
// Returns a promise that resolves with a FakeCentral that clients can use
21+
// to simulate events that a device in the Central/Observer role would
22+
// receive as well as monitor the operations performed by the device in the
23+
// Central/Observer role.
24+
//
25+
// A "Central" object would allow its clients to receive advertising events
26+
// and initiate connections to peripherals i.e. operations of two roles
27+
// defined by the Bluetooth Spec: Observer and Central.
28+
// See Bluetooth 4.2 Vol 3 Part C 2.2.2 "Roles when Operating over an
29+
// LE Physical Transport".
30+
async simulateCentral({state}) {
31+
if (this.fake_central_) {
32+
throw 'simulateCentral() should only be called once';
33+
}
34+
35+
await test_driver.bidi.bluetooth.simulate_adapter({state: state});
36+
this.fake_central_ = new FakeCentral();
37+
return this.fake_central_;
38+
}
39+
}
40+
41+
// FakeCentral allows clients to simulate events that a device in the
42+
// Central/Observer role would receive as well as monitor the operations
43+
// performed by the device in the Central/Observer role.
44+
class FakeCentral {
45+
constructor() {
46+
this.peripherals_ = new Map();
47+
}
48+
49+
// Simulates a peripheral with |address|, |name|, |manufacturerData| and
50+
// |known_service_uuids| that has already been connected to the system. If the
51+
// peripheral existed already it updates its name, manufacturer data, and
52+
// known UUIDs. |known_service_uuids| should be an array of
53+
// BluetoothServiceUUIDs
54+
// https://webbluetoothcg.github.io/web-bluetooth/#typedefdef-bluetoothserviceuuid
55+
//
56+
// Platforms offer methods to retrieve devices that have already been
57+
// connected to the system or weren't connected through the UA e.g. a user
58+
// connected a peripheral through the system's settings. This method is
59+
// intended to simulate peripherals that those methods would return.
60+
async simulatePreconnectedPeripheral(
61+
{address, name, manufacturerData = {}, knownServiceUUIDs = []}) {
62+
await test_driver.bidi.bluetooth.simulate_preconnected_peripheral({
63+
address: address,
64+
name: name,
65+
manufacturerData: convertToBidiManufacturerData(manufacturerData),
66+
knownServiceUuids: knownServiceUUIDs
67+
});
68+
69+
return this.fetchOrCreatePeripheral_(address);
70+
}
71+
72+
// Create a fake_peripheral object from the given address.
73+
fetchOrCreatePeripheral_(address) {
74+
let peripheral = this.peripherals_.get(address);
75+
if (peripheral === undefined) {
76+
peripheral = new FakePeripheral(address);
77+
this.peripherals_.set(address, peripheral);
78+
}
79+
return peripheral;
80+
}
81+
}
82+
83+
class FakePeripheral {
84+
constructor(address) {
85+
this.address = address;
86+
}
87+
}
88+
89+
function initializeBluetoothBidiResources() {
90+
navigator.bluetooth.test = new FakeBluetooth();
91+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>Assures navigator.serviceWorker.register() doesn't crash when rejecting being called in a detached frame</title>
4+
<link rel="author" href="mailto:[email protected]">
5+
<link rel="help" href="http://crbug.com/398910931">
6+
<body>
7+
<iframe></iframe>
8+
<script>
9+
const frame = document.getElementsByTagName("iframe")[0];
10+
const container = frame.contentWindow.navigator.serviceWorker;
11+
frame.remove();
12+
container.register("data:,");
13+
</script>
14+
</body>

0 commit comments

Comments
 (0)