Commit 88036fe3 authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

[serial] Make options parameter to requestPort() optional

Unlike Web Bluetooth or WebUSB where developers are expected to filter
devices based on model or capability it is common to not be able to
determine the device connected to a serial port and so many applications
will want to match all ports. This change makes the requestPort()
options parameter optional.

Bug: 884928
Change-Id: If3017c7331020fdb4a62c9b195bef8ba0ef0169e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1749460Reviewed-by: default avatarOvidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686112}
parent 2d5f16fe
...@@ -15,5 +15,5 @@ ...@@ -15,5 +15,5 @@
Promise<sequence<SerialPort>> getPorts(); Promise<sequence<SerialPort>> getPorts();
[CallWith=ScriptState, MeasureAs=SerialRequestPort, Exposed=Window] [CallWith=ScriptState, MeasureAs=SerialRequestPort, Exposed=Window]
Promise<SerialPort> requestPort(SerialPortRequestOptions options); Promise<SerialPort> requestPort(optional SerialPortRequestOptions options);
}; };
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<script> <script>
promise_test((t) => { promise_test((t) => {
return promise_rejects(t, 'SecurityError', navigator.serial.requestPort({})); return promise_rejects(t, 'SecurityError', navigator.serial.requestPort());
}, 'requestPort() rejects without a user gesture'); }, 'requestPort() rejects without a user gesture');
promise_test(async (t) => { promise_test(async (t) => {
...@@ -22,7 +22,7 @@ promise_test(async (t) => { ...@@ -22,7 +22,7 @@ promise_test(async (t) => {
await trustedClick(); await trustedClick();
try { try {
await promise_rejects(t, 'NotFoundError', navigator.serial.requestPort({})); await promise_rejects(t, 'NotFoundError', navigator.serial.requestPort());
} finally { } finally {
interceptor.stop(); interceptor.stop();
} }
...@@ -30,7 +30,7 @@ promise_test(async (t) => { ...@@ -30,7 +30,7 @@ promise_test(async (t) => {
serial_test(async (t, fake) => { serial_test(async (t, fake) => {
await trustedClick(); await trustedClick();
return promise_rejects(t, 'NotFoundError', navigator.serial.requestPort({})); return promise_rejects(t, 'NotFoundError', navigator.serial.requestPort());
}, 'requestPort() rejects if no port has been selected'); }, 'requestPort() rejects if no port has been selected');
serial_test(async (t, fake) => { serial_test(async (t, fake) => {
...@@ -38,7 +38,7 @@ serial_test(async (t, fake) => { ...@@ -38,7 +38,7 @@ serial_test(async (t, fake) => {
fake.setSelectedPort(guid); fake.setSelectedPort(guid);
await trustedClick(); await trustedClick();
let port = await navigator.serial.requestPort({}); let port = await navigator.serial.requestPort();
assert_true(port instanceof SerialPort); assert_true(port instanceof SerialPort);
// TODO: Assert that product IDs (if provided) are passed through. // TODO: Assert that product IDs (if provided) are passed through.
}, 'requestPort() returns the selected port'); }, 'requestPort() returns the selected port');
...@@ -48,9 +48,9 @@ serial_test(async (t, fake) => { ...@@ -48,9 +48,9 @@ serial_test(async (t, fake) => {
fake.setSelectedPort(guid); fake.setSelectedPort(guid);
await trustedClick(); await trustedClick();
let firstPort = await navigator.serial.requestPort({}); let firstPort = await navigator.serial.requestPort();
assert_true(firstPort instanceof SerialPort); assert_true(firstPort instanceof SerialPort);
let secondPort = await navigator.serial.requestPort({}); let secondPort = await navigator.serial.requestPort();
assert_true(secondPort instanceof SerialPort); assert_true(secondPort instanceof SerialPort);
assert_true(firstPort === secondPort); assert_true(firstPort === secondPort);
}, 'requestPort() returns the same port object every time'); }, 'requestPort() returns the same port object every time');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment