Commit 63cd1601 authored by Yuki Shiino's avatar Yuki Shiino Committed by Chromium LUCI CQ

v8bindings: Clean up workarounds of crbug.com/839117

The issue 839117 was fixed by the new bindings generator, so
removes workarounds and related tests.

Bug: 839117
Change-Id: I5d017b6453997171258f716814901d5d24cc42ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2558084Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832638}
parent fc723c22
......@@ -44,14 +44,6 @@ String TokenToString(const base::UnguessableToken& token) {
const char Serial::kSupplementName[] = "Serial";
Serial* Serial::serial(NavigatorBase& navigator) {
ExecutionContext* context = navigator.GetExecutionContext();
if (!context ||
(!context->IsWindow() && !context->IsDedicatedWorkerGlobalScope())) {
// TODO(https://crbug.com/839117): Remove this check once the Exposed
// attribute is fixed to only expose this property in dedicated workers.
return nullptr;
}
Serial* serial = Supplement<NavigatorBase>::From<Serial>(navigator);
if (!serial) {
serial = MakeGarbageCollected<Serial>(navigator);
......
......@@ -5,10 +5,7 @@
// https://wicg.github.io/serial
[
// TODO(crbug.com/839117): Enable the following [Exposed] on the partial
// interface declaration once it's supported.
//
// Exposed=DedicatedWorker,
Exposed=DedicatedWorker,
ImplementedAs=Serial,
RuntimeEnabled=Serial,
SecureContext
......
......@@ -32,14 +32,6 @@ const char WakeLock::kSupplementName[] = "WakeLock";
// static
WakeLock* WakeLock::wakeLock(NavigatorBase& navigator) {
ExecutionContext* context = navigator.GetExecutionContext();
if (!context ||
(!context->IsWindow() && !context->IsDedicatedWorkerGlobalScope())) {
// TODO(https://crbug.com/839117): Remove this check once the Exposed
// attribute is fixed to only expose this property in dedicated workers.
return nullptr;
}
WakeLock* supplement = Supplement<NavigatorBase>::From<WakeLock>(navigator);
if (!supplement && navigator.GetExecutionContext()) {
supplement = MakeGarbageCollected<WakeLock>(navigator);
......
......@@ -7,6 +7,7 @@
// until System Wake Lock API was split from the Screen Wake Lock API.
[
Exposed=DedicatedWorker,
ImplementedAs=WakeLock,
RuntimeEnabled=SystemWakeLock,
SecureContext
......
......@@ -95,22 +95,6 @@ UsbDeviceFilterPtr ConvertDeviceFilter(const USBDeviceFilter* filter,
const char USB::kSupplementName[] = "USB";
USB* USB::usb(NavigatorBase& navigator) {
ExecutionContext* context = navigator.GetExecutionContext();
if (!context)
return nullptr;
if (!context->IsWindow() &&
(!context->IsDedicatedWorkerGlobalScope() ||
!RuntimeEnabledFeatures::WebUSBOnDedicatedWorkersEnabled())) {
// A bug in the WebIDL compiler causes this attribute to be incorrectly
// exposed in the other worker contexts if one of the RuntimeEnabled flags
// is enabled. Therefore, we will just return the empty usb_ member if the
// appropriate flag is not enabled for the current context, or if the
// current context is a ServiceWorkerGlobalScope.
// TODO(https://crbug.com/839117): Once this attribute stops being
// incorrectly exposed to the worker contexts, remove these checks.
return nullptr;
}
USB* usb = Supplement<NavigatorBase>::From<USB>(navigator);
if (!usb) {
usb = MakeGarbageCollected<USB>(navigator);
......
......@@ -5,10 +5,7 @@
// https://wicg.github.io/webusb/#enumeration
[
// TODO(crbug.com/839117): Enable the following [Exposed] on the partial
// interface declaration once it's supported.
//
// Exposed(DedicatedWorker WebUSBOnDedicatedWorkers),
Exposed(DedicatedWorker WebUSBOnDedicatedWorkers),
ImplementedAs=USB,
SecureContext
] partial interface WorkerNavigator {
......
This is a testharness.js-based test.
PASS Ensure that WebUSB is inaccessible from a service worker.
FAIL Service workers should not have access to the WebUSB API. assert_equals: navigator.usb should not be a USB object expected "undefined" but got "object"
Harness: the test ran to completion.
......@@ -2955,13 +2955,10 @@ interface WorkerNavigator
getter permissions
getter platform
getter product
getter serial
getter storage
getter storageBuckets
getter usb
getter userAgent
getter userAgentData
getter wakeLock
method clearAppBadge
method constructor
method setAppBadge
......
......@@ -2722,7 +2722,6 @@ interface WorkerNavigator
getter platform
getter product
getter storage
getter usb
getter userAgent
method clearAppBadge
method constructor
......
......@@ -2605,7 +2605,6 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] getter platform
[Worker] getter product
[Worker] getter storage
[Worker] getter usb
[Worker] getter userAgent
[Worker] method constructor
[Worker] interface WritableStream
......
This test interface attributes which should be null in SharedWorkerGlobalScope.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Starting worker: resources/null-attributes-shared-worker.js
FAIL [Worker] navigator.serial should be null (of type object). Was undefined (of type undefined).
PASS [Worker] navigator.usb is null
FAIL [Worker] navigator.wakeLock should be null (of type object). Was undefined (of type undefined).
PASS successfullyParsed is true
TEST COMPLETE
......@@ -2825,13 +2825,10 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] getter permissions
[Worker] getter platform
[Worker] getter product
[Worker] getter serial
[Worker] getter storage
[Worker] getter storageBuckets
[Worker] getter usb
[Worker] getter userAgent
[Worker] getter userAgentData
[Worker] getter wakeLock
[Worker] method constructor
[Worker] interface WritableStream
[Worker] attribute @@toStringTag
......
This test interface attributes which should be null in SharedWorkerGlobalScope.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Starting worker: resources/null-attributes-shared-worker.js
PASS [Worker] navigator.serial is null
PASS [Worker] navigator.usb is null
PASS [Worker] navigator.wakeLock is null
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../resources/js-test.js"></script>
<script>
description("This test interface attributes which should be null in SharedWorkerGlobalScope.");
worker = startWorker("resources/null-attributes-shared-worker.js", "shared");
worker.port.postMessage({});
</script>
importScripts('../../resources/js-test.js');
// TODO(https://crbug.com/839117): Special logic is required to work around
// a bug where these interfaces are exposed in shared workers even though
// the Exposed attribute only specifies dedicated workers.
function runTest(platformSpecific) {
shouldBe('navigator.serial', 'null');
shouldBe('navigator.usb', 'null');
shouldBe('navigator.wakeLock', 'null');
finishJSTest();
}
self.onconnect = function(event) {
self.postMessage = function(message) {
event.ports[0].postMessage(message);
};
event.ports[0].onmessage = () => {
runTest();
};
};
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