summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resources/chromium/fake-serial.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/resources/chromium/fake-serial.js')
-rw-r--r--testing/web-platform/tests/resources/chromium/fake-serial.js30
1 files changed, 27 insertions, 3 deletions
diff --git a/testing/web-platform/tests/resources/chromium/fake-serial.js b/testing/web-platform/tests/resources/chromium/fake-serial.js
index 29c8168fb5..8614b4d64f 100644
--- a/testing/web-platform/tests/resources/chromium/fake-serial.js
+++ b/testing/web-platform/tests/resources/chromium/fake-serial.js
@@ -356,6 +356,10 @@ class FakeSerialService {
portInfo.hasUsbProductId = true;
portInfo.usbProductId = info.usbProductId;
}
+ portInfo.connected = true;
+ if (info?.connected !== undefined) {
+ portInfo.connected = info.connected;
+ }
let token = ++this.nextToken_;
portInfo.token = {high: 0n, low: BigInt(token)};
@@ -366,8 +370,10 @@ class FakeSerialService {
};
this.ports_.set(token, record);
- for (let client of this.clients_) {
- client.onPortAdded(portInfo);
+ if (portInfo.connected) {
+ for (let client of this.clients_) {
+ client.onPortConnectedStateChanged(portInfo);
+ }
}
return token;
@@ -381,8 +387,26 @@ class FakeSerialService {
this.ports_.delete(token);
+ record.portInfo.connected = false;
+ for (let client of this.clients_) {
+ client.onPortConnectedStateChanged(record.portInfo);
+ }
+ }
+
+ setPortConnectedState(token, connected) {
+ let record = this.ports_.get(token);
+ if (record === undefined) {
+ return;
+ }
+
+ let was_connected = record.portInfo.connected;
+ if (was_connected === connected) {
+ return;
+ }
+
+ record.portInfo.connected = connected;
for (let client of this.clients_) {
- client.onPortRemoved(record.portInfo);
+ client.onPortConnectedStateChanged(record.portInfo);
}
}