Commit bb410933 authored by Reilly Grant's avatar Reilly Grant Committed by Chromium LUCI CQ

serial: Enable tests in workers

Enable most of the existing internal Web Platform Tests for the Web
Serial API in worker contexts. The easiest way to make them work in the
new context was to migrate to using test-only-api.js to load scripts at
runtime. This will also make it easier to upstream these to the WPT repo
later.

Bug: 884928
Change-Id: If5e4219bfc51c39f50d0188c7281ba325c0ab5e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2572693
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834512}
parent 49120be0
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
This is a testharness.js-based test.
PASS stopPropagation() during capturing
PASS Set cancelBubble during capturing
PASS stopPropagation() during bubbling
PASS Set cancelBubble during bubbling
PASS An event dispatched in an event handler is propagated before continuing
FAIL Capturing and bubbling events delivered to listeners in the expected order assert_array_equals: expected property 1 to be "capturing SerialPort" but got "bubbling SerialPort" (expected array ["capturing Serial", "capturing SerialPort", "bubbling SerialPort", "bubbling Serial"] got ["capturing Serial", "bubbling SerialPort", "capturing SerialPort", "bubbling Serial"])
Harness: the test ran to completion.
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/test-only-api.js
promise_test(async () => {
await loadMojoResources([
'/gen/mojo/public/mojom/base/unguessable_token.mojom.js',
'/gen/third_party/blink/public/mojom/serial/serial.mojom.js',
]);
let interceptor =
new MojoInterfaceInterceptor(blink.mojom.SerialService.name);
interceptor.oninterfacerequest = e => e.handle.close();
interceptor.start();
let ports = await navigator.serial.getPorts();
assert_equals(ports.length, 0);
interceptor.stop();
}, 'getPorts() returns empty list if Mojo service connection fails');
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
promise_test(async () => {
let interceptor =
new MojoInterfaceInterceptor(blink.mojom.SerialService.name);
interceptor.oninterfacerequest = e => e.handle.close();
interceptor.start();
let ports = await navigator.serial.getPorts();
assert_equals(ports.length, 0);
interceptor.stop();
}, 'getPorts() returns empty list if Mojo service connection fails');
serial_test(async (t, fake) => { serial_test(async (t, fake) => {
fake.addPort(); fake.addPort();
fake.addPort(); fake.addPort();
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testharness.js // META: script=/resources/test-only-api.js
// META: script=/resources/testharnessreport.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
......
// META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js
// META: script=/resources/test-only-api.js
// META: script=resources/automation.js
promise_test(async (t) => {
await loadMojoResources([
'/gen/mojo/public/mojom/base/unguessable_token.mojom.js',
'/gen/third_party/blink/public/mojom/serial/serial.mojom.js',
]);
let interceptor =
new MojoInterfaceInterceptor(blink.mojom.SerialService.name);
interceptor.oninterfacerequest = e => e.handle.close();
interceptor.start();
await trustedClick();
try {
await promise_rejects_dom(
t, 'NotFoundError', navigator.serial.requestPort());
} finally {
interceptor.stop();
}
}, 'requestPort() rejects if Mojo service connection fails');
// META: script=/resources/testharness.js
// META: script=/resources/testharnessreport.js
// META: script=/resources/testdriver.js // META: script=/resources/testdriver.js
// META: script=/resources/testdriver-vendor.js // META: script=/resources/testdriver-vendor.js
// META: script=/gen/layout_test_data/mojo/public/js/mojo_bindings.js // META: script=/resources/test-only-api.js
// META: script=/gen/mojo/public/mojom/base/unguessable_token.mojom.js
// META: script=/gen/third_party/blink/public/mojom/serial/serial.mojom.js
// META: script=/serial/resources/common.js // META: script=/serial/resources/common.js
// META: script=resources/automation.js // META: script=resources/automation.js
promise_test((t) => { serial_test((t, fake) => {
return promise_rejects_dom( return promise_rejects_dom(
t, 'SecurityError', navigator.serial.requestPort()); t, 'SecurityError', navigator.serial.requestPort());
}, 'requestPort() rejects without a user gesture'); }, 'requestPort() rejects without a user gesture');
promise_test(async (t) => {
let interceptor =
new MojoInterfaceInterceptor(blink.mojom.SerialService.name);
interceptor.oninterfacerequest = e => e.handle.close();
interceptor.start();
await trustedClick();
try {
await promise_rejects_dom(
t, 'NotFoundError', navigator.serial.requestPort());
} finally {
interceptor.stop();
}
}, 'requestPort() rejects if Mojo service connection fails');
serial_test(async (t, fake) => { serial_test(async (t, fake) => {
await trustedClick(); await trustedClick();
return promise_rejects_dom( return promise_rejects_dom(
......
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