Migrate remaining WPT to Mojo JS modules
All remaining WPT using Mojo bindings are migrated to newer module-based
bindings here. Support for loading older bindings variants in WPT is
removed.
Bug: 1004256
Change-Id: I630a6ddb0e5b89f5b7e6c538a273c3725a485aae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2664907
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: Stephen McGruer <smcgruer@chromium.org>
Reviewed-by: Michael Moss <mmoss@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#849713}
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations
index 95d3859d..6bfc8ce 100644
--- a/third_party/blink/web_tests/TestExpectations
+++ b/third_party/blink/web_tests/TestExpectations
@@ -5690,3 +5690,7 @@
# Sheriff 2021-01-29
crbug.com/1172437 [ Win10 ] svg/hixie/perf/004.xml [ Timeout Pass ]
+
+crbug.com/1173137 external/wpt/webxr/hit-test/ar_hittest_subscription_inputSources.https.html [ Failure ]
+crbug.com/1173137 external/wpt/webxr/hit-test/ar_hittest_subscription_refSpaces.https.html [ Failure ]
+crbug.com/1173137 external/wpt/webxr/hit-test/ar_hittest_subscription_transientInputSources.https.html [ Failure ]
diff --git a/third_party/blink/web_tests/external/wpt/contacts/resources/helpers.js b/third_party/blink/web_tests/external/wpt/contacts/resources/helpers.js
index c67d684..8bac86b 100644
--- a/third_party/blink/web_tests/external/wpt/contacts/resources/helpers.js
+++ b/third_party/blink/web_tests/external/wpt/contacts/resources/helpers.js
@@ -9,14 +9,7 @@
//
// --enable-blink-features=MojoJS,MojoJSTest
async function loadChromiumResources() {
-
- const chromiumResources = [
- '/gen/third_party/blink/public/mojom/contacts/contacts_manager.mojom.js',
- '/gen/components/payments/mojom/payment_request_data.mojom.js',
- ];
-
- await loadMojoResources(chromiumResources);
- await loadScript('/resources/chromium/contacts_manager_mock.js');
+ await import('/resources/chromium/contacts_manager_mock.js');
}
// User Agents must provide their own implementation of `WebContacts`,
diff --git a/third_party/blink/web_tests/external/wpt/generic-sensor/resources/generic-sensor-helpers.js b/third_party/blink/web_tests/external/wpt/generic-sensor/resources/generic-sensor-helpers.js
index 5985574..7070daa 100644
--- a/third_party/blink/web_tests/external/wpt/generic-sensor/resources/generic-sensor-helpers.js
+++ b/third_party/blink/web_tests/external/wpt/generic-sensor/resources/generic-sensor-helpers.js
@@ -9,15 +9,9 @@
//
// --enable-blink-features=MojoJS,MojoJSTest
async function loadChromiumResources() {
- const chromiumResources = [
- '/gen/mojo/public/mojom/base/string16.mojom.js',
- '/gen/services/device/public/mojom/sensor.mojom.js',
- '/gen/services/device/public/mojom/sensor_provider.mojom.js',
- ];
- await loadMojoResources(chromiumResources);
await loadScript('/resources/testdriver.js');
await loadScript('/resources/testdriver-vendor.js');
- await loadScript('/resources/chromium/generic_sensor_mocks.js');
+ await import('/resources/chromium/generic_sensor_mocks.js');
}
async function initialize_generic_sensor_tests() {
diff --git a/third_party/blink/web_tests/external/wpt/idle-detection/resources/idle-detection-helper.js b/third_party/blink/web_tests/external/wpt/idle-detection/resources/idle-detection-helper.js
index 5d08546..f053e63 100644
--- a/third_party/blink/web_tests/external/wpt/idle-detection/resources/idle-detection-helper.js
+++ b/third_party/blink/web_tests/external/wpt/idle-detection/resources/idle-detection-helper.js
@@ -10,12 +10,5 @@
// --enable-blink-features=MojoJS,MojoJSTest
async function loadChromiumResources() {
- const chromiumResources = [
- '/gen/mojo/public/mojom/base/string16.mojom.js',
- '/gen/mojo/public/mojom/base/time.mojom.js',
- '/gen/third_party/blink/public/mojom/idle/idle_manager.mojom.js'
- ];
-
- await loadMojoResources(chromiumResources);
- await loadScript('/resources/chromium/mock-idle-detection.js');
+ await import('/resources/chromium/mock-idle-detection.js');
}
diff --git a/third_party/blink/web_tests/external/wpt/lint.ignore b/third_party/blink/web_tests/external/wpt/lint.ignore
index e296376..72e26ff 100644
--- a/third_party/blink/web_tests/external/wpt/lint.ignore
+++ b/third_party/blink/web_tests/external/wpt/lint.ignore
@@ -727,20 +727,20 @@
# Tests that depend on resources in /gen/ in Chromium:
# https://github.com/web-platform-tests/wpt/issues/16455
# Please consult with ecosystem-infra@chromium.org before adding more.
-MISSING DEPENDENCY: contacts/resources/helpers.js
MISSING DEPENDENCY: credential-management/support/otpcredential-helper.js
-MISSING DEPENDENCY: generic-sensor/resources/generic-sensor-helpers.js
-MISSING DEPENDENCY: idle-detection/resources/idle-detection-helper.js
-MISSING DEPENDENCY: mediacapture-image/resources/imagecapture-helpers.js
-MISSING DEPENDENCY: orientation-event/resources/orientation-event-helpers.js
+MISSING DEPENDENCY: resources/chromium/contacts_manager_mock.js
MISSING DEPENDENCY: resources/chromium/web-bluetooth-test.js
MISSING DEPENDENCY: resources/chromium/webusb-test.js
-MISSING DEPENDENCY: resources/test-only-api.js
-MISSING DEPENDENCY: screen_enumeration/resources/screenenumeration-helpers.js
-MISSING DEPENDENCY: serial/resources/automation.js
-MISSING DEPENDENCY: shape-detection/resources/shapedetection-helpers.js
-MISSING DEPENDENCY: web-nfc/resources/nfc-helpers.js
-MISSING DEPENDENCY: webxr/resources/webxr_util.js
+MISSING DEPENDENCY: resources/chromium/fake-serial.js
+MISSING DEPENDENCY: resources/chromium/generic_sensor_mocks.js
+MISSING DEPENDENCY: resources/chromium/mock-barcodedetection.js
+MISSING DEPENDENCY: resources/chromium/mock-facedetection.js
+MISSING DEPENDENCY: resources/chromium/mock-idle-detection.js
+MISSING DEPENDENCY: resources/chromium/mock-imagecapture.js
+MISSING DEPENDENCY: resources/chromium/mock-screenenumeration.js
+MISSING DEPENDENCY: resources/chromium/mock-textdetection.js
+MISSING DEPENDENCY: resources/chromium/nfc-mock.js
+MISSING DEPENDENCY: resources/chromium/webxr-test.js
# Tests that are false positives for using Ahem as a system font
AHEM SYSTEM FONT: acid/acid3/test.html
diff --git a/third_party/blink/web_tests/external/wpt/mediacapture-image/resources/imagecapture-helpers.js b/third_party/blink/web_tests/external/wpt/mediacapture-image/resources/imagecapture-helpers.js
index 8301b1c..8f142cff4 100644
--- a/third_party/blink/web_tests/external/wpt/mediacapture-image/resources/imagecapture-helpers.js
+++ b/third_party/blink/web_tests/external/wpt/mediacapture-image/resources/imagecapture-helpers.js
@@ -10,11 +10,7 @@
// --enable-blink-features=MojoJS,MojoJSTest
async function loadChromiumResources() {
- const chromiumResources = [
- '/gen/media/capture/mojom/image_capture.mojom.js'
- ];
- await loadMojoResources(chromiumResources);
- await loadScript('/resources/chromium/mock-imagecapture.js');
+ await import('/resources/chromium/mock-imagecapture.js');
}
async function initialize_image_capture_tests() {
diff --git a/third_party/blink/web_tests/external/wpt/orientation-event/resources/orientation-event-helpers.js b/third_party/blink/web_tests/external/wpt/orientation-event/resources/orientation-event-helpers.js
index 51154ad..1f0deba 100644
--- a/third_party/blink/web_tests/external/wpt/orientation-event/resources/orientation-event-helpers.js
+++ b/third_party/blink/web_tests/external/wpt/orientation-event/resources/orientation-event-helpers.js
@@ -9,13 +9,7 @@
//
// --enable-blink-features=MojoJS,MojoJSTest
async function loadChromiumResources() {
- const chromiumResources = [
- '/gen/mojo/public/mojom/base/string16.mojom.js',
- '/gen/services/device/public/mojom/sensor.mojom.js',
- '/gen/services/device/public/mojom/sensor_provider.mojom.js',
- ];
- await loadMojoResources(chromiumResources);
- await loadScript('/resources/chromium/generic_sensor_mocks.js');
+ await import('/resources/chromium/generic_sensor_mocks.js');
}
async function initialize_generic_sensor_tests() {
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/README.md b/third_party/blink/web_tests/external/wpt/resources/chromium/README.md
index ec95303..3813f6d 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/README.md
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/README.md
@@ -2,6 +2,6 @@
test-only APIs implemented with
[MojoJS](https://chromium.googlesource.com/chromium/src/+/master/mojo/public/js/README.md).
-Please do **not** copy `*.mojom.js` into this directory. Follow this doc if you
+Please do **not** copy `*.mojom.m.js` into this directory. Follow this doc if you
want to add new MojoJS-backed mocks:
https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_platform_tests.md#mojojs
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/contacts_manager_mock.js b/third_party/blink/web_tests/external/wpt/resources/chromium/contacts_manager_mock.js
index 443d50b..2ace6d49 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/contacts_manager_mock.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/contacts_manager_mock.js
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-'use strict';
+import {ContactsManager, ContactsManagerReceiver} from '/gen/third_party/blink/public/mojom/contacts/contacts_manager.mojom.m.js';
-const WebContactsTest = (() => {
+self.WebContactsTest = (() => {
class MockContacts {
constructor() {
- this.bindingSet_ = new mojo.BindingSet(blink.mojom.ContactsManager);
+ this.receiver_ = new ContactsManagerReceiver(this);
this.interceptor_ =
- new MojoInterfaceInterceptor(blink.mojom.ContactsManager.name);
+ new MojoInterfaceInterceptor(ContactsManager.$interfaceName);
this.interceptor_.>
- e => this.bindingSet_.addBinding(this, e.handle);
+ e => this.receiver_.$.bindHandle(e.handle);
this.interceptor_.start();
this.selectedContacts_ = [];
@@ -39,7 +39,7 @@
return {contacts: null};
const contactInfos = await Promise.all(this.selectedContacts_.map(async contact => {
- const contactInfo = new blink.mojom.ContactInfo();
+ const contactInfo = {};
if (includeNames)
contactInfo.name = contact.name || [];
if (includeEmails)
@@ -69,7 +69,7 @@
}
reset() {
- this.bindingSet_.closeAllBindings();
+ this.receiver_.$.close();
this.interceptor_.stop();
}
}
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/fake-serial.js b/third_party/blink/web_tests/external/wpt/resources/chromium/fake-serial.js
index 46a79f0..1a0f4b521 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/fake-serial.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/fake-serial.js
@@ -1,3 +1,6 @@
+import {SerialPortFlushMode, SerialPortRemote, SerialReceiveError, SerialPortReceiver, SerialSendError} from '/gen/services/device/public/mojom/serial.mojom.m.js';
+import {SerialService, SerialServiceReceiver} from '/gen/third_party/blink/public/mojom/serial/serial.mojom.m.js';
+
// Implementation of an UnderlyingSource to create a ReadableStream from a Mojo
// data pipe consumer handle.
class DataPipeSource {
@@ -84,7 +87,7 @@
}
}
-// Implementation of blink.mojom.SerialPort.
+// Implementation of device.mojom.SerialPort.
class FakeSerialPort {
constructor() {
this.inputSignals_ = {
@@ -103,24 +106,21 @@
}
open(options, client) {
- if (this.binding_ !== undefined) {
+ if (this.receiver_ !== undefined) {
// Port already open.
return null;
}
- let portPtr = new device.mojom.SerialPortPtr();
- this.binding_ = new mojo.Binding(
- device.mojom.SerialPort, this, mojo.makeRequest(portPtr));
- this.binding_.setConnectionErrorHandler(() => {
- this.close();
- });
+ let port = new SerialPortRemote();
+ this.receiver_ = new SerialPortReceiver(this);
+ this.receiver_.$.bindHandle(port.$.bindNewPipeAndPassReceiver().handle);
this.options_ = options;
this.client_ = client;
// OS typically sets DTR on open.
this.outputSignals_.dataTerminalReady = true;
- return portPtr;
+ return port;
}
write(data) {
@@ -146,11 +146,11 @@
}
simulateParityError() {
- this.simulateReadError(device.mojom.SerialReceiveError.PARITY_ERROR);
+ this.simulateReadError(SerialReceiveError.PARITY_ERROR);
}
simulateDisconnectOnRead() {
- this.simulateReadError(device.mojom.SerialReceiveError.DISCONNECTED);
+ this.simulateReadError(SerialReceiveError.DISCONNECTED);
}
simulateWriteError(error) {
@@ -161,11 +161,11 @@
}
simulateSystemErrorOnWrite() {
- this.simulateWriteError(device.mojom.SerialSendError.SYSTEM_ERROR);
+ this.simulateWriteError(SerialSendError.SYSTEM_ERROR);
}
simulateDisconnectOnWrite() {
- this.simulateWriteError(device.mojom.SerialSendError.DISCONNECTED);
+ this.simulateWriteError(SerialSendError.DISCONNECTED);
}
simulateInputSignals(signals) {
@@ -232,13 +232,13 @@
async flush(mode) {
switch (mode) {
- case device.mojom.SerialPortFlushMode.kReceive:
+ case SerialPortFlushMode.kReceive:
this.writer_.abort();
this.writer_.releaseLock();
this.writer_ = undefined;
this.writable_ = undefined;
break;
- case device.mojom.SerialPortFlushMode.kTransmit:
+ case SerialPortFlushMode.kTransmit:
this.reader_.cancel();
this.reader_ = undefined;
this.readable_ = undefined;
@@ -289,11 +289,11 @@
async getPortInfo() {
return {
bitrate: this.options_.bitrate,
- data_bits: this.options_.data_bits,
- parity_bit: this.options_.parity_bit,
- stop_bits: this.options_.stop_bits,
- cts_flow_control: this.options_.has_cts_flow_control ?
- this.options_.cts_flow_control : false
+ dataBits: this.options_.datBits,
+ parityBit: this.options_.parityBit,
+ stopBits: this.options_.stopBits,
+ ctsFlowControl:
+ this.options_.hasCtsFlowControl && this.options_.ctsFlowControl,
};
}
@@ -307,9 +307,9 @@
}
this.writable_ = undefined;
- if (this.binding_) {
- this.binding_.close();
- this.binding_ = undefined;
+ if (this.receiver_) {
+ this.receiver_.$.close();
+ this.receiver_ = undefined;
}
return {};
}
@@ -319,9 +319,9 @@
class FakeSerialService {
constructor() {
this.interceptor_ =
- new MojoInterfaceInterceptor(blink.mojom.SerialService.name);
+ new MojoInterfaceInterceptor(SerialService.$interfaceName);
this.interceptor_. => this.bind(e.handle);
- this.bindingSet_ = new mojo.BindingSet(blink.mojom.SerialService);
+ this.receiver_ = new SerialServiceReceiver(this);
this.clients_ = [];
this.nextToken_ = 0;
this.reset();
@@ -341,7 +341,7 @@
}
addPort(info) {
- let portInfo = new blink.mojom.SerialPortInfo();
+ let portInfo = {};
if (info?.usbVendorId !== undefined) {
portInfo.hasUsbVendorId = true;
portInfo.usbVendorId = info.usbVendorId;
@@ -352,9 +352,7 @@
}
let token = ++this.nextToken_;
- portInfo.token = new mojoBase.mojom.UnguessableToken();
- portInfo.token.high = 0;
- portInfo.token.low = token;
+ portInfo.token = {high: 0n, low: BigInt(token)};
let record = {
portInfo: portInfo,
@@ -394,7 +392,7 @@
}
bind(handle) {
- this.bindingSet_.addBinding(this, handle);
+ this.receiver_.$.bindHandle(handle);
}
async setClient(client_remote) {
@@ -415,7 +413,7 @@
}
async openPort(token, options, client) {
- let record = this.ports_.get(token.low);
+ let record = this.ports_.get(Number(token.low));
if (record !== undefined) {
return {port: record.fakePort.open(options, client)};
} else {
@@ -424,4 +422,4 @@
}
}
-fakeSerialService = new FakeSerialService();
+export const fakeSerialService = new FakeSerialService();
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/generic_sensor_mocks.js b/third_party/blink/web_tests/external/wpt/resources/chromium/generic_sensor_mocks.js
index 5643882..b7b303b 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/generic_sensor_mocks.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/generic_sensor_mocks.js
@@ -1,9 +1,10 @@
-'use strict';
+import {ReportingMode, Sensor, SensorClientRemote, SensorReceiver, SensorRemote, SensorType} from '/gen/services/device/public/mojom/sensor.mojom.m.js';
+import {SensorCreationResult, SensorInitParams_READ_BUFFER_SIZE_FOR_TESTS, SensorProvider, SensorProviderReceiver} from '/gen/services/device/public/mojom/sensor_provider.mojom.m.js';
// A "sliding window" that iterates over |data| and returns one item at a
// time, advancing and wrapping around as needed. |data| must be an array of
// arrays.
-class RingBuffer {
+self.RingBuffer = class {
constructor(data) {
this.bufferPosition_ = 0;
// Validate |data|'s format and deep-copy every element.
@@ -28,9 +29,9 @@
[Symbol.iterator]() {
return this;
}
-}
+};
-var GenericSensorTest = (() => {
+self.GenericSensorTest = (() => {
// Default sensor frequency in default configurations.
const DEFAULT_FREQUENCY = 5;
@@ -56,11 +57,8 @@
}
this.buffer_ = new Float64Array(rv.buffer);
this.buffer_.fill(0);
- this.binding_ = new mojo.Binding(device.mojom.Sensor, this,
- sensorRequest);
- this.binding_.setConnectionErrorHandler(() => {
- this.reset();
- });
+ this.receiver_ = new SensorReceiver(this);
+ this.receiver_.$.bindHandle(sensorRequest.handle);
}
// Returns default configuration.
@@ -120,7 +118,7 @@
this.notifyOnReadingChange_ = true;
this.readingData_ = null;
this.buffer_.fill(0);
- this.binding_.close();
+ this.receiver_.$.close();
}
// Sets fake data that is used to deliver sensor reading updates.
@@ -166,7 +164,7 @@
// increasing timestamp.
this.buffer_[1] = this.timestamp_++;
- if (this.reportingMode_ === device.mojom.ReportingMode.ON_CHANGE &&
+ if (this.reportingMode_ === ReportingMode.ON_CHANGE &&
this.notifyOnReadingChange_) {
this.client_.sensorReadingChanged();
}
@@ -197,9 +195,9 @@
class MockSensorProvider {
constructor() {
this.readingSizeInBytes_ =
- device.mojom.SensorInitParams.READ_BUFFER_SIZE_FOR_TESTS;
- this.sharedBufferSizeInBytes_ = this.readingSizeInBytes_ *
- (device.mojom.SensorType.MAX_VALUE + 1);
+ Number(SensorInitParams_READ_BUFFER_SIZE_FOR_TESTS);
+ this.sharedBufferSizeInBytes_ =
+ this.readingSizeInBytes_ * (SensorType.MAX_VALUE + 1);
const rv = Mojo.createSharedBuffer(this.sharedBufferSizeInBytes_);
if (rv.result != Mojo.RESULT_OK) {
throw new Error("MockSensorProvider: Failed to map shared buffer");
@@ -212,28 +210,26 @@
this.maxFrequency_ = 60;
this.minFrequency_ = 1;
this.mojomSensorType_ = new Map([
- ['Accelerometer', device.mojom.SensorType.ACCELEROMETER],
- ['LinearAccelerationSensor',
- device.mojom.SensorType.LINEAR_ACCELERATION],
- ['GravitySensor',
- device.mojom.SensorType.GRAVITY],
- ['AmbientLightSensor', device.mojom.SensorType.AMBIENT_LIGHT],
- ['Gyroscope', device.mojom.SensorType.GYROSCOPE],
- ['Magnetometer', device.mojom.SensorType.MAGNETOMETER],
+ ['Accelerometer', SensorType.ACCELEROMETER],
+ ['LinearAccelerationSensor', SensorType.LINEAR_ACCELERATION],
+ ['GravitySensor', SensorType.GRAVITY],
+ ['AmbientLightSensor', SensorType.AMBIENT_LIGHT],
+ ['Gyroscope', SensorType.GYROSCOPE],
+ ['Magnetometer', SensorType.MAGNETOMETER],
['AbsoluteOrientationSensor',
- device.mojom.SensorType.ABSOLUTE_ORIENTATION_QUATERNION],
+ SensorType.ABSOLUTE_ORIENTATION_QUATERNION],
['AbsoluteOrientationEulerAngles',
- device.mojom.SensorType.ABSOLUTE_ORIENTATION_EULER_ANGLES],
+ SensorType.ABSOLUTE_ORIENTATION_EULER_ANGLES],
['RelativeOrientationSensor',
- device.mojom.SensorType.RELATIVE_ORIENTATION_QUATERNION],
+ SensorType.RELATIVE_ORIENTATION_QUATERNION],
['RelativeOrientationEulerAngles',
- device.mojom.SensorType.RELATIVE_ORIENTATION_EULER_ANGLES],
- ['ProximitySensor', device.mojom.SensorType.PROXIMITY]
+ SensorType.RELATIVE_ORIENTATION_EULER_ANGLES],
+ ['ProximitySensor', SensorType.PROXIMITY]
]);
- this.binding_ = new mojo.Binding(device.mojom.SensorProvider, this);
+ this.receiver_ = new SensorProviderReceiver(this);
this.interceptor_ =
- new MojoInterfaceInterceptor(device.mojom.SensorProvider.name);
+ new MojoInterfaceInterceptor(SensorProvider.$interfaceName);
this.interceptor_. => {
this.bindToPipe(e.handle);
};
@@ -243,25 +239,24 @@
// Returns initialized Sensor proxy to the client.
async getSensor(type) {
if (this.getSensorShouldFail_.get(type)) {
- return {result: device.mojom.SensorCreationResult.ERROR_NOT_AVAILABLE,
+ return {result: SensorCreationResult.ERROR_NOT_AVAILABLE,
initParams: null};
}
if (this.permissionsDenied_.get(type)) {
- return {result: device.mojom.SensorCreationResult.ERROR_NOT_ALLOWED,
+ return {result: SensorCreationResult.ERROR_NOT_ALLOWED,
initParams: null};
}
const offset = type * this.readingSizeInBytes_;
- const reportingMode = device.mojom.ReportingMode.ON_CHANGE;
+ const reportingMode = ReportingMode.ON_CHANGE;
- const sensorPtr = new device.mojom.SensorPtr();
+ const sensor = new SensorRemote();
if (!this.activeSensors_.has(type)) {
const mockSensor = new MockSensor(
- mojo.makeRequest(sensorPtr), this.sharedBufferHandle_, offset,
- this.readingSizeInBytes_, reportingMode);
+ sensor.$.bindNewPipeAndPassReceiver(), this.sharedBufferHandle_,
+ offset, this.readingSizeInBytes_, reportingMode);
this.activeSensors_.set(type, mockSensor);
- this.activeSensors_.get(type).client_ =
- new device.mojom.SensorClientPtr();
+ this.activeSensors_.get(type).client_ = new SensorClientRemote();
}
const rv = this.sharedBufferHandle_.duplicateBufferHandle();
@@ -272,8 +267,7 @@
const defaultConfig = { frequency: DEFAULT_FREQUENCY };
// Consider sensor traits to meet assertions in C++ code (see
// services/device/public/cpp/generic_sensor/sensor_traits.h)
- if (type == device.mojom.SensorType.AMBIENT_LIGHT ||
- type == device.mojom.SensorType.MAGNETOMETER) {
+ if (type == SensorType.AMBIENT_LIGHT || type == SensorType.MAGNETOMETER) {
this.maxFrequency_ = Math.min(10, this.maxFrequency_);
}
@@ -283,23 +277,24 @@
// each reading return a different value that is significantly different
// from the previous one when setSensorReading() is not called by client
// code (e.g. run_generic_sensor_iframe_tests()).
- if (type == device.mojom.SensorType.AMBIENT_LIGHT) {
+ if (type == SensorType.AMBIENT_LIGHT) {
this.activeSensors_.get(type).setSensorReading([
[window.performance.now() * 100],
[(window.performance.now() + 50) * 100]
]);
}
- const initParams = new device.mojom.SensorInitParams({
- sensor: sensorPtr,
- clientReceiver: mojo.makeRequest(this.activeSensors_.get(type).client_),
+ const client = this.activeSensors_.get(type).client_;
+ const initParams = {
+ sensor,
+ clientReceiver: client.$.bindNewPipeAndPassReceiver(),
memory: rv.handle,
- bufferOffset: offset,
+ bufferOffset: BigInt(offset),
mode: reportingMode,
defaultConfiguration: defaultConfig,
minimumFrequency: this.minFrequency_,
maximumFrequency: this.maxFrequency_
- });
+ };
if (this.resolveFuncs_.has(type)) {
for (let resolveFunc of this.resolveFuncs_.get(type)) {
@@ -308,16 +303,12 @@
this.resolveFuncs_.delete(type);
}
- return {result: device.mojom.SensorCreationResult.SUCCESS,
- initParams: initParams};
+ return {result: SensorCreationResult.SUCCESS, initParams};
}
// Binds object to mojo message pipe
bindToPipe(pipe) {
- this.binding_.bind(pipe);
- this.binding_.setConnectionErrorHandler(() => {
- this.reset();
- });
+ this.receiver_.$.bindHandle(pipe);
}
// Mock functions
@@ -333,7 +324,7 @@
this.permissionsDenied_.clear();
this.maxFrequency_ = 60;
this.minFrequency_ = 1;
- this.binding_.close();
+ this.receiver_.$.close();
this.interceptor_.stop();
}
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-barcodedetection.js b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-barcodedetection.js
index c11f879..b0d2e0af 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-barcodedetection.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-barcodedetection.js
@@ -1,20 +1,20 @@
-"use strict";
+import {BarcodeDetectionReceiver, BarcodeFormat} from '/gen/services/shape_detection/public/mojom/barcodedetection.mojom.m.js';
+import {BarcodeDetectionProvider, BarcodeDetectionProviderReceiver} from '/gen/services/shape_detection/public/mojom/barcodedetection_provider.mojom.m.js';
-var BarcodeDetectionTest = (() => {
+self.BarcodeDetectionTest = (() => {
// Class that mocks BarcodeDetectionProvider interface defined in
// https://cs.chromium.org/chromium/src/services/shape_detection/public/mojom/barcodedetection_provider.mojom
class MockBarcodeDetectionProvider {
constructor() {
- this.bindingSet_ = new mojo.BindingSet(
- shapeDetection.mojom.BarcodeDetectionProvider);
+ this.receiver_ = new BarcodeDetectionProviderReceiver(this);
this.interceptor_ = new MojoInterfaceInterceptor(
- shapeDetection.mojom.BarcodeDetectionProvider.name);
+ BarcodeDetectionProvider.$interfaceName);
this.interceptor_. => {
if (this.should_close_pipe_on_request_)
e.handle.close();
else
- this.bindingSet_.addBinding(this, e.handle);
+ this.receiver_.$.bindHandle(e.handle);
}
this.interceptor_.start();
this.should_close_pipe_on_request_ = false;
@@ -25,13 +25,13 @@
}
enumerateSupportedFormats() {
- return Promise.resolve({
+ return {
supportedFormats: [
- shapeDetection.mojom.BarcodeFormat.AZTEC,
- shapeDetection.mojom.BarcodeFormat.DATA_MATRIX,
- shapeDetection.mojom.BarcodeFormat.QR_CODE,
+ BarcodeFormat.AZTEC,
+ BarcodeFormat.DATA_MATRIX,
+ BarcodeFormat.QR_CODE,
]
- });
+ };
}
getFrameData() {
@@ -45,7 +45,7 @@
reset() {
this.mockService_ = null;
this.should_close_pipe_on_request_ = false;
- this.bindingSet_.closeAllBindings();
+ this.receiver_.$.close();
this.interceptor_.stop();
}
@@ -60,20 +60,19 @@
class MockBarcodeDetection {
constructor(request, options) {
this.options_ = options;
- this.binding_ =
- new mojo.Binding(shapeDetection.mojom.BarcodeDetection,
- this, request);
+ this.receiver_ = new BarcodeDetectionReceiver(this);
+ this.receiver_.$.bindHandle(request.handle);
}
detect(bitmapData) {
this.bufferData_ =
new Uint32Array(getArrayBufferFromBigBuffer(bitmapData.pixelData));
- return Promise.resolve({
+ return {
results: [
{
rawValue : "cats",
boundingBox: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 },
- format: shapeDetection.mojom.BarcodeFormat.QR_CODE,
+ format: BarcodeFormat.QR_CODE,
cornerPoints: [
{ x: 1.0, y: 1.0 },
{ x: 101.0, y: 1.0 },
@@ -84,7 +83,7 @@
{
rawValue : "dogs",
boundingBox: { x: 2.0, y: 2.0, width: 50.0, height: 50.0 },
- format: shapeDetection.mojom.BarcodeFormat.CODE_128,
+ format: BarcodeFormat.CODE_128,
cornerPoints: [
{ x: 2.0, y: 2.0 },
{ x: 52.0, y: 2.0 },
@@ -93,7 +92,7 @@
],
},
],
- });
+ };
}
}
@@ -133,3 +132,5 @@
return BarcodeDetectionTestChromium;
})();
+
+self.BarcodeFormat = BarcodeFormat;
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-facedetection.js b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-facedetection.js
index 1275e4dd..7ae6586 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-facedetection.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-facedetection.js
@@ -1,17 +1,17 @@
-"use strict";
+import {FaceDetectionReceiver, LandmarkType} from '/gen/services/shape_detection/public/mojom/facedetection.mojom.m.js';
+import {FaceDetectionProvider, FaceDetectionProviderReceiver} from '/gen/services/shape_detection/public/mojom/facedetection_provider.mojom.m.js';
-var FaceDetectionTest = (() => {
+self.FaceDetectionTest = (() => {
// Class that mocks FaceDetectionProvider interface defined in
// https://cs.chromium.org/chromium/src/services/shape_detection/public/mojom/facedetection_provider.mojom
class MockFaceDetectionProvider {
constructor() {
- this.bindingSet_ = new mojo.BindingSet(
- shapeDetection.mojom.FaceDetectionProvider);
+ this.receiver_ = new FaceDetectionProviderReceiver(this);
this.interceptor_ = new MojoInterfaceInterceptor(
- shapeDetection.mojom.FaceDetectionProvider.name);
+ FaceDetectionProvider.$interfaceName);
this.interceptor_.>
- e => this.bindingSet_.addBinding(this, e.handle);
+ e => this.receiver_.$.bindHandle(e.handle);
this.interceptor_.start();
}
@@ -33,7 +33,7 @@
reset() {
this.mockService_ = null;
- this.bindingSet_.closeAllBindings();
+ this.receiver_.$.close();
this.interceptor_.stop();
}
}
@@ -44,9 +44,8 @@
constructor(request, options) {
this.maxDetectedFaces_ = options.maxDetectedFaces;
this.fastMode_ = options.fastMode;
- this.binding_ =
- new mojo.Binding(shapeDetection.mojom.FaceDetection,
- this, request);
+ this.receiver_ = new FaceDetectionReceiver(this);
+ this.receiver_.$.bindHandle(request.handle);
}
detect(bitmapData) {
@@ -57,11 +56,11 @@
{
boundingBox: {x: 1.0, y: 1.0, width: 100.0, height: 100.0},
landmarks: [{
- type: shapeDetection.mojom.LandmarkType.EYE,
+ type: LandmarkType.EYE,
locations: [{x: 4.0, y: 5.0}]
},
{
- type: shapeDetection.mojom.LandmarkType.EYE,
+ type: LandmarkType.EYE,
locations: [
{x: 4.0, y: 5.0}, {x: 5.0, y: 4.0}, {x: 6.0, y: 3.0},
{x: 7.0, y: 4.0}, {x: 8.0, y: 5.0}, {x: 7.0, y: 6.0},
@@ -72,11 +71,11 @@
{
boundingBox: {x: 2.0, y: 2.0, width: 200.0, height: 200.0},
landmarks: [{
- type: shapeDetection.mojom.LandmarkType.NOSE,
+ type: LandmarkType.NOSE,
locations: [{x: 100.0, y: 50.0}]
},
{
- type: shapeDetection.mojom.LandmarkType.NOSE,
+ type: LandmarkType.NOSE,
locations: [
{x: 80.0, y: 50.0}, {x: 70.0, y: 60.0}, {x: 60.0, y: 70.0},
{x: 70.0, y: 60.0}, {x: 80.0, y: 70.0}, {x: 90.0, y: 80.0},
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-idle-detection.js b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-idle-detection.js
index d88d1ad..afc5b93f 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-idle-detection.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-idle-detection.js
@@ -1,3 +1,5 @@
+import {IdleManager, IdleManagerReceiver, ScreenIdleState as MojoScreenIdleState, UserIdleState as MojoUserIdleState} from '/gen/third_party/blink/public/mojom/idle/idle_manager.mojom.m.js';
+
/**
* This is a testing framework that enables us to test the user idle detection
* by intercepting the connection between the renderer and the browser and
@@ -35,14 +37,14 @@
return this;
}
close() {
- this.binding.close();
+ this.binding.$.close();
}
}
-const UserIdleState = {};
-const ScreenIdleState = {};
+self.UserIdleState = {};
+self.ScreenIdleState = {};
-function addMonitor(threshold, monitorPtr, callback) {
+self.addMonitor = function addMonitor(threshold, monitorPtr, callback) {
throw new Error("expected to be overriden by tests");
}
@@ -50,34 +52,31 @@
interceptor.close();
}
-function expect(call) {
+self.expect = function(call) {
return {
andReturn(callback) {
let handler = {};
handler[call.name] = callback;
interceptor.setHandler(handler);
}
- }
-}
+ };
+};
function intercept() {
let result = new FakeIdleMonitor();
- let binding = new mojo.Binding(blink.mojom.IdleManager, result);
- let interceptor = new MojoInterfaceInterceptor(blink.mojom.IdleManager.name);
- interceptor. => {
- binding.bind(e.handle);
- }
-
+ let binding = new IdleManagerReceiver(result);
+ let interceptor = new MojoInterfaceInterceptor(IdleManager.$interfaceName);
+ interceptor. => binding.$.bindHandle(e.handle);
interceptor.start();
- UserIdleState.ACTIVE = blink.mojom.UserIdleState.kActive;
- UserIdleState.IDLE = blink.mojom.UserIdleState.kIdle;
- ScreenIdleState.LOCKED = blink.mojom.ScreenIdleState.kLocked;
- ScreenIdleState.UNLOCKED = blink.mojom.ScreenIdleState.kUnlocked;
+ self.UserIdleState.ACTIVE = MojoUserIdleState.kActive;
+ self.UserIdleState.IDLE = MojoUserIdleState.kIdle;
+ self.ScreenIdleState.LOCKED = MojoScreenIdleState.kLocked;
+ self.ScreenIdleState.UNLOCKED = MojoScreenIdleState.kUnlocked;
result.setBinding(binding);
return result;
}
-const interceptor = intercept();
\ No newline at end of file
+const interceptor = intercept();
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-imagecapture.js b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-imagecapture.js
index a8f5c89..97d45d4 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-imagecapture.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-imagecapture.js
@@ -1,34 +1,34 @@
-"use strict";
+import {FillLightMode, ImageCapture, ImageCaptureReceiver, MeteringMode, RedEyeReduction} from '/gen/media/capture/mojom/image_capture.mojom.m.js';
-var ImageCaptureTest = (() => {
+self.ImageCaptureTest = (() => {
// Class that mocks ImageCapture interface defined in
// https://cs.chromium.org/chromium/src/media/capture/mojom/image_capture.mojom
class MockImageCapture {
constructor() {
this.interceptor_ =
- new MojoInterfaceInterceptor(media.mojom.ImageCapture.name);
+ new MojoInterfaceInterceptor(ImageCapture.$interfaceName);
this.interceptor_.>
- e => this.bindingSet_.addBinding(this, e.handle);
+ e => this.receiver_.$.bindHandle(e.handle);
this.interceptor_.start();
this.state_ = {
state: {
supportedWhiteBalanceModes: [
- media.mojom.MeteringMode.SINGLE_SHOT,
- media.mojom.MeteringMode.CONTINUOUS
+ MeteringMode.SINGLE_SHOT,
+ MeteringMode.CONTINUOUS
],
- currentWhiteBalanceMode: media.mojom.MeteringMode.CONTINUOUS,
+ currentWhiteBalanceMode: MeteringMode.CONTINUOUS,
supportedExposureModes: [
- media.mojom.MeteringMode.MANUAL,
- media.mojom.MeteringMode.SINGLE_SHOT,
- media.mojom.MeteringMode.CONTINUOUS
+ MeteringMode.MANUAL,
+ MeteringMode.SINGLE_SHOT,
+ MeteringMode.CONTINUOUS
],
- currentExposureMode: media.mojom.MeteringMode.MANUAL,
+ currentExposureMode: MeteringMode.MANUAL,
supportedFocusModes: [
- media.mojom.MeteringMode.MANUAL,
- media.mojom.MeteringMode.SINGLE_SHOT
+ MeteringMode.MANUAL,
+ MeteringMode.SINGLE_SHOT
],
- currentFocusMode: media.mojom.MeteringMode.MANUAL,
+ currentFocusMode: MeteringMode.MANUAL,
pointsOfInterest: [{
x: 0.4,
y: 0.6
@@ -115,7 +115,7 @@
supportsTorch: true,
torch: false,
- redEyeReduction: media.mojom.RedEyeReduction.CONTROLLABLE,
+ redEyeReduction: RedEyeReduction.CONTROLLABLE,
height: {
min: 240.0,
max: 2448.0,
@@ -128,18 +128,16 @@
current: 320.0,
step: 3.0
},
- fillLightMode: [
- media.mojom.FillLightMode.AUTO, media.mojom.FillLightMode.FLASH
- ],
+ fillLightMode: [FillLightMode.AUTO, FillLightMode.FLASH],
}
};
this.panTiltZoomPermissionStatus_ = null;
this.settings_ = null;
- this.bindingSet_ = new mojo.BindingSet(media.mojom.ImageCapture);
+ this.receiver_ = new ImageCaptureReceiver(this);
}
reset() {
- this.bindingSet_.closeAllBindings();
+ this.receiver_.$.close();
this.interceptor_.stop();
}
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-screenenumeration.js b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-screenenumeration.js
index 2e41f59..fc89b11 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-screenenumeration.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-screenenumeration.js
@@ -1,14 +1,27 @@
-'use strict'
+import {MultipleDisplays, ScreenEnumeration, ScreenEnumerationReceiver} from '/gen/third_party/blink/public/mojom/screen_enumeration/screen_enumeration.mojom.m.js';
+import {BufferFormat} from '/gen/ui/gfx/mojom/buffer_types.mojom.m.js';
+import {ColorSpaceMatrixID, ColorSpacePrimaryID, ColorSpaceRangeID, ColorSpaceTransferID} from '/gen/ui/gfx/mojom/color_space.mojom.m.js';
+import {AccelerometerSupport, Rotation, TouchSupport} from '/gen/ui/display/mojom/display.mojom.m.js';
-var ScreenEnumerationTest = (() => {
+export const HelperTypes = {
+ AccelerometerSupport,
+ BufferFormat,
+ ColorSpaceMatrixID,
+ ColorSpacePrimaryID,
+ ColorSpaceRangeID,
+ ColorSpaceTransferID,
+ Rotation,
+ TouchSupport,
+};
+self.ScreenEnumerationTest = (() => {
class MockScreenEnumeration {
constructor() {
- this.bindingSet_ = new mojo.BindingSet(blink.mojom.ScreenEnumeration);
- this.interceptor_ = new MojoInterfaceInterceptor(blink.mojom.ScreenEnumeration.name);
- this.interceptor_. => {
- this.bindingSet_.addBinding(this, e.handle);
- }
+ this.receiver_ = new ScreenEnumerationReceiver(this);
+ this.interceptor_ =
+ new MojoInterfaceInterceptor(ScreenEnumeration.$interfaceName);
+ this.interceptor_.>
+ e => this.receiver_.$.bindHandle(e.handle);
this.reset();
this.interceptor_.start();
}
@@ -45,22 +58,22 @@
async getDisplays() {
if (!this.success_)
- return Promise.resolve({ result: undefined, });
- let value = new blink.mojom.Displays();
- value.displays = this.displays_;
- value.internalId = this.internalId_;
- value.primaryId = this.primaryId_;
- return Promise.resolve({ result: value, });
+ return {result: undefined};
+ const result = {
+ displays: this.displays_,
+ internalId: this.internalId_,
+ primaryId: this.primaryId_,
+ };
+ return {result};
}
- async hasMultipleDisplays() {
+ hasMultipleDisplays() {
if (!this.success_)
- return Promise.resolve({ result: blink.mojom.MultipleDisplays.kError });
- return Promise.resolve({
+ return {result: MultipleDisplays.kError};
+ return {
result: this.displays_.length > 1
- ? blink.mojom.MultipleDisplays.kTrue
- : blink.mojom.MultipleDisplays.kFalse,
- });
+ ? MultipleDisplays.kTrue : MultipleDisplays.kFalse,
+ };
}
}
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-textdetection.js b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-textdetection.js
index 427ce38..52ca987e 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/mock-textdetection.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/mock-textdetection.js
@@ -1,16 +1,15 @@
-"use strict";
-var TextDetectionTest = (() => {
+import {TextDetection, TextDetectionReceiver} from '/gen/services/shape_detection/public/mojom/textdetection.mojom.m.js';
+
+self.TextDetectionTest = (() => {
// Class that mocks TextDetection interface defined in
// https://cs.chromium.org/chromium/src/services/shape_detection/public/mojom/textdetection.mojom
class MockTextDetection {
constructor() {
- this.bindingSet_ =
- new mojo.BindingSet(shapeDetection.mojom.TextDetection);
-
+ this.receiver_ = new TextDetectionReceiver(this);
this.interceptor_ =
- new MojoInterfaceInterceptor(shapeDetection.mojom.TextDetection.name);
+ new MojoInterfaceInterceptor(TextDetection.$interfaceName);
this.interceptor_.>
- e => this.bindingSet_.addBinding(this, e.handle);
+ e => this.receiver_.$.bindHandle(e.handle);
this.interceptor_.start();
}
@@ -48,7 +47,7 @@
}
reset() {
- this.bindingSet_.closeAllBindings();
+ this.receiver_.$.close();
this.interceptor_.stop();
}
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/nfc-mock.js b/third_party/blink/web_tests/external/wpt/resources/chromium/nfc-mock.js
index 2665f3d..6a0437a 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/nfc-mock.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/nfc-mock.js
@@ -1,10 +1,9 @@
-'use strict';
+import {NDEFErrorType, NDEFRecordTypeCategory, NFC, NFCReceiver} from '/gen/services/device/public/mojom/nfc.mojom.m.js';
// Converts between NDEFMessageInit https://w3c.github.io/web-nfc/#dom-ndefmessage
// and mojom.NDEFMessage structure, so that watch function can be tested.
function toMojoNDEFMessage(message) {
- let ndefMessage = new device.mojom.NDEFMessage();
- ndefMessage.data = [];
+ let ndefMessage = {data: []};
for (let record of message.records) {
ndefMessage.data.push(toMojoNDEFRecord(record));
}
@@ -12,16 +11,16 @@
}
function toMojoNDEFRecord(record) {
- let nfcRecord = new device.mojom.NDEFRecord();
+ let nfcRecord = {};
// Simply checks the existence of ':' to decide whether it's an external
// type or a local type. As a mock, no need to really implement the validation
// algorithms for them.
if (record.recordType.startsWith(':')) {
- nfcRecord.category = device.mojom.NDEFRecordTypeCategory.kLocal;
+ nfcRecord.category = NDEFRecordTypeCategory.kLocal;
} else if (record.recordType.search(':') != -1) {
- nfcRecord.category = device.mojom.NDEFRecordTypeCategory.kExternal;
+ nfcRecord.category = NDEFRecordTypeCategory.kExternal;
} else {
- nfcRecord.category = device.mojom.NDEFRecordTypeCategory.kStandardized;
+ nfcRecord.category = NDEFRecordTypeCategory.kStandardized;
}
nfcRecord.recordType = record.recordType;
nfcRecord.mediaType = record.mediaType;
@@ -59,7 +58,7 @@
// Compares NDEFRecords that were provided / received by the mock service.
// TODO: Use different getters to get received record data,
// see spec changes at https://github.com/w3c/web-nfc/pull/243.
-function compareNDEFRecords(providedRecord, receivedRecord) {
+self.compareNDEFRecords = function(providedRecord, receivedRecord) {
assert_equals(providedRecord.recordType, receivedRecord.recordType);
if (providedRecord.id === undefined) {
@@ -93,7 +92,7 @@
// Compares NDEFWriteOptions structures that were provided to API and
// received by the mock mojo service.
-function assertNDEFWriteOptionsEqual(provided, received) {
+self.assertNDEFWriteOptionsEqual = function(provided, received) {
if (provided.overwrite !== undefined)
assert_equals(provided.overwrite, !!received.overwrite);
else
@@ -102,7 +101,7 @@
// Compares NDEFReaderOptions structures that were provided to API and
// received by the mock mojo service.
-function assertNDEFReaderOptionsEqual(provided, received) {
+self.assertNDEFReaderOptionsEqual = function(provided, received) {
if (provided.url !== undefined)
assert_equals(provided.url, received.url);
else
@@ -119,24 +118,20 @@
}
function createNDEFError(type) {
- return {
- error: type != null ?
- new device.mojom.NDEFError({errorType: type, errorMessage: ''}) :
- null
- };
+ return {error: (type != null ? {errorType: type, errorMessage: ''} : null)};
}
-var WebNFCTest = (() => {
+self.WebNFCTest = (() => {
class MockNFC {
constructor() {
- this.bindingSet_ = new mojo.BindingSet(device.mojom.NFC);
+ this.receiver_ = new NFCReceiver(this);
- this.interceptor_ = new MojoInterfaceInterceptor(device.mojom.NFC.name);
+ this.interceptor_ = new MojoInterfaceInterceptor(NFC.$interfaceName);
this.interceptor_. => {
if (this.should_close_pipe_on_request_)
e.handle.close();
else
- this.bindingSet_.addBinding(this, e.handle);
+ this.receiver_.$.bindHandle(e.handle);
}
this.interceptor_.start();
@@ -174,10 +169,10 @@
} else if (this.is_formatted_tag_ && !options.overwrite) {
// Resolves with NotAllowedError if there are NDEF records on the device
// and overwrite is false.
- resolve(createNDEFError(device.mojom.NDEFErrorType.NOT_ALLOWED));
+ resolve(createNDEFError(NDEFErrorType.NOT_ALLOWED));
} else if (this.data_transfer_failed_) {
// Resolves with NetworkError if data transfer fails.
- resolve(createNDEFError(device.mojom.NDEFErrorType.IO_ERROR));
+ resolve(createNDEFError(NDEFErrorType.IO_ERROR));
} else {
resolve(createNDEFError(null));
}
@@ -223,9 +218,9 @@
getHWError() {
if (this.hw_status_ === NFCHWStatus.DISABLED)
- return createNDEFError(device.mojom.NDEFErrorType.NOT_READABLE);
+ return createNDEFError(NDEFErrorType.NOT_READABLE);
if (this.hw_status_ === NFCHWStatus.NOT_SUPPORTED)
- return createNDEFError(device.mojom.NDEFErrorType.NOT_SUPPORTED);
+ return createNDEFError(NDEFErrorType.NOT_SUPPORTED);
return null;
}
@@ -264,7 +259,7 @@
cancelPendingPushOperation() {
if (this.pending_promise_func_) {
this.pending_promise_func_(
- createNDEFError(device.mojom.NDEFErrorType.OPERATION_CANCELLED));
+ createNDEFError(NDEFErrorType.OPERATION_CANCELLED));
this.pending_promise_func_ = null;
}
@@ -318,15 +313,15 @@
simulateNonNDEFTagDiscovered() {
// Notify NotSupportedError to all active readers.
if (this.watchers_.length != 0) {
- this.client_.onError(new device.mojom.NDEFError({
- errorType: device.mojom.NDEFErrorType.NOT_SUPPORTED,
+ this.client_.onError({
+ errorType: NDEFErrorType.NOT_SUPPORTED,
errorMessage: ''
- }));
+ });
}
// Reject the pending push with NotSupportedError.
if (this.pending_promise_func_) {
this.pending_promise_func_(
- createNDEFError(device.mojom.NDEFErrorType.NOT_SUPPORTED));
+ createNDEFError(NDEFErrorType.NOT_SUPPORTED));
this.pending_promise_func_ = null;
}
}
diff --git a/third_party/blink/web_tests/external/wpt/resources/chromium/webxr-test.js b/third_party/blink/web_tests/external/wpt/resources/chromium/webxr-test.js
index 01d2ec2..2846add 100644
--- a/third_party/blink/web_tests/external/wpt/resources/chromium/webxr-test.js
+++ b/third_party/blink/web_tests/external/wpt/resources/chromium/webxr-test.js
@@ -1,13 +1,15 @@
-'use strict';
+import * as vrMojom from '/gen/device/vr/public/mojom/vr_service.mojom.m.js';
+import {GamepadHand, GamepadMapping} from '/gen/device/gamepad/public/mojom/gamepad.mojom.m.js';
// This polyfill library implements the WebXR Test API as specified here:
// https://github.com/immersive-web/webxr-test-api
-const defaultMojoFromFloor = new gfx.mojom.Transform();
-defaultMojoFromFloor.matrix = [1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, -1.65, 0, 1];
+const defaultMojoFromFloor = {
+ matrix: [1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, -1.65, 0, 1]
+};
const default_stage_parameters = {
mojoFromFloor: defaultMojoFromFloor,
bounds: null
@@ -44,15 +46,22 @@
m14, m24, m34, 1];
}
+function getPoseFromTransform(transform) {
+ const [px, py, pz] = transform.position;
+ const [ox, oy, oz, ow] = transform.orientation;
+ return {
+ position: {x: px, y: py, z: pz},
+ orientation: {x: ox, y: oy, z: oz, w: ow},
+ };
+}
+
function composeGFXTransform(fakeTransformInit) {
- const transform = new gfx.mojom.Transform();
- transform.matrix = getMatrixFromTransform(fakeTransformInit);
- return transform;
+ return {matrix: getMatrixFromTransform(fakeTransformInit)};
}
class ChromeXRTest {
constructor() {
- this.mockVRService_ = new MockVRService(mojo.frameInterfaces);
+ this.mockVRService_ = new MockVRService();
}
simulateDeviceConnection(init_params) {
@@ -60,7 +69,7 @@
}
disconnectAllDevices() {
- this.mockVRService_.removeAllRuntimes(device);
+ this.mockVRService_.removeAllRuntimes();
return Promise.resolve();
}
@@ -103,13 +112,13 @@
// Mock service implements the VRService mojo interface.
class MockVRService {
constructor() {
- this.bindingSet_ = new mojo.BindingSet(device.mojom.VRService);
+ this.receiver_ = new vrMojom.VRServiceReceiver(this);
this.runtimes_ = [];
this.interceptor_ =
- new MojoInterfaceInterceptor(device.mojom.VRService.name);
- this.interceptor_. =>
- this.bindingSet_.addBinding(this, e.handle);
+ new MojoInterfaceInterceptor(vrMojom.VRService.$interfaceName);
+ this.interceptor_.>
+ e => this.receiver_.$.bindHandle(e.handle);
this.interceptor_.start();
}
@@ -151,7 +160,7 @@
this.client_ = client;
}
- requestSession(sessionOptions, was_activation) {
+ requestSession(sessionOptions) {
const requests = [];
// Request a session from all the runtimes.
for (let i = 0; i < this.runtimes_.length; i++) {
@@ -163,31 +172,21 @@
for (let i = 0; i < results.length; i++) {
if (results[i].session) {
// Construct a dummy metrics recorder
- const metricsRecorderPtr = new device.mojom.XRSessionMetricsRecorderPtr();
- const metricsRecorderRequest = mojo.makeRequest(metricsRecorderPtr);
- const metricsRecorderBinding = new mojo.Binding(
- device.mojom.XRSessionMetricsRecorder, new MockXRSessionMetricsRecorder(), metricsRecorderRequest);
+ const metricsRecorderPtr = new vrMojom.XRSessionMetricsRecorderRemote();
+ metricsRecorderPtr.$.bindNewPipeAndPassReceiver().handle.close();
const success = {
session: results[i].session,
metricsRecorder: metricsRecorderPtr,
};
- return {
- result: {
- success : success,
- $tag : 0
- }
- };
+ return {result: {success}};
}
}
// If there were no successful results, returns a null session.
return {
- result: {
- failureReason : device.mojom.RequestSessionError.NO_RUNTIME_FOUND,
- $tag : 1
- }
+ result: {failureReason: vrMojom.RequestSessionError.NO_RUNTIME_FOUND}
};
});
}
@@ -216,17 +215,22 @@
});
}
+ setFramesThrottled(throttled) {
+ this.setFramesThrottledImpl(throttled);
+ }
+
+ // May be overridden by specific tests.
+ setFramesThrottledImpl(throttled) {}
+
// Only handles asynchronous calls to makeXrCompatible. Synchronous calls are
// not supported in Javascript.
makeXrCompatible() {
if (this.runtimes_.length == 0) {
- return Promise.resolve({
- xrCompatibleResult: device.mojom.XrCompatibleResult.kNoDeviceAvailable
- });
+ return {
+ xrCompatibleResult: vrMojom.XrCompatibleResult.kNoDeviceAvailable
+ };
}
- return Promise.resolve({
- xrCompatibleResult: device.mojom.XrCompatibleResult.kAlreadyCompatible
- });
+ return {xrCompatibleResult: vrMojom.XrCompatibleResult.kAlreadyCompatible};
}
}
@@ -324,36 +328,36 @@
// Mapping from string feature names to the corresponding mojo types.
// This is exposed as a member for extensibility.
static featureToMojoMap = {
- 'viewer': device.mojom.XRSessionFeature.REF_SPACE_VIEWER,
- 'local': device.mojom.XRSessionFeature.REF_SPACE_LOCAL,
- 'local-floor': device.mojom.XRSessionFeature.REF_SPACE_LOCAL_FLOOR,
- 'bounded-floor': device.mojom.XRSessionFeature.REF_SPACE_BOUNDED_FLOOR,
- 'unbounded': device.mojom.XRSessionFeature.REF_SPACE_UNBOUNDED,
- 'hit-test': device.mojom.XRSessionFeature.HIT_TEST,
- 'dom-overlay': device.mojom.XRSessionFeature.DOM_OVERLAY,
- 'light-estimation': device.mojom.XRSessionFeature.LIGHT_ESTIMATION,
- 'anchors': device.mojom.XRSessionFeature.ANCHORS,
+ 'viewer': vrMojom.XRSessionFeature.REF_SPACE_VIEWER,
+ 'local': vrMojom.XRSessionFeature.REF_SPACE_LOCAL,
+ 'local-floor': vrMojom.XRSessionFeature.REF_SPACE_LOCAL_FLOOR,
+ 'bounded-floor': vrMojom.XRSessionFeature.REF_SPACE_BOUNDED_FLOOR,
+ 'unbounded': vrMojom.XRSessionFeature.REF_SPACE_UNBOUNDED,
+ 'hit-test': vrMojom.XRSessionFeature.HIT_TEST,
+ 'dom-overlay': vrMojom.XRSessionFeature.DOM_OVERLAY,
+ 'light-estimation': vrMojom.XRSessionFeature.LIGHT_ESTIMATION,
+ 'anchors': vrMojom.XRSessionFeature.ANCHORS,
};
static sessionModeToMojoMap = {
- "inline": device.mojom.XRSessionMode.kInline,
- "immersive-vr": device.mojom.XRSessionMode.kImmersiveVr,
- "immersive-ar": device.mojom.XRSessionMode.kImmersiveAr,
+ "inline": vrMojom.XRSessionMode.kInline,
+ "immersive-vr": vrMojom.XRSessionMode.kImmersiveVr,
+ "immersive-ar": vrMojom.XRSessionMode.kImmersiveAr,
};
static environmentBlendModeToMojoMap = {
- "opaque": device.mojom.XREnvironmentBlendMode.kOpaque,
- "alpha-blend": device.mojom.XREnvironmentBlendMode.kAlphaBlend,
- "additive": device.mojom.XREnvironmentBlendMode.kAdditive,
+ "opaque": vrMojom.XREnvironmentBlendMode.kOpaque,
+ "alpha-blend": vrMojom.XREnvironmentBlendMode.kAlphaBlend,
+ "additive": vrMojom.XREnvironmentBlendMode.kAdditive,
};
static interactionModeToMojoMap = {
- "screen-space": device.mojom.XRInteractionMode.kScreenSpace,
- "world-space": device.mojom.XRInteractionMode.kWorldSpace,
+ "screen-space": vrMojom.XRInteractionMode.kScreenSpace,
+ "world-space": vrMojom.XRInteractionMode.kWorldSpace,
};
constructor(fakeDeviceInit, service) {
- this.sessionClient_ = new device.mojom.XRSessionClientPtr();
+ this.sessionClient_ = null;
this.presentation_provider_ = new MockXRPresentationProvider();
this.pose_ = null;
@@ -375,11 +379,11 @@
// Currently active transient hit test subscriptions.
this.transientHitTestSubscriptions_ = new Map();
// ID of the next subscription to be assigned.
- this.next_hit_test_id_ = 1;
+ this.next_hit_test_id_ = 1n;
this.anchor_controllers_ = new Map();
// ID of the next anchor to be assigned.
- this.next_anchor_id_ = 1;
+ this.next_anchor_id_ = 1n;
// Anchor creation callback (initially null, can be set by tests).
this.anchor_creation_callback_ = null;
@@ -406,10 +410,10 @@
// Initialize DisplayInfo first to set the defaults, then override with
// anything from the deviceInit
- if (this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveVr)
- || this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
+ if (this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveVr) ||
+ this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {
this.displayInfo_ = this.getImmersiveDisplayInfo();
- } else if (this.supportedModes_.includes(device.mojom.XRSessionMode.kInline)) {
+ } else if (this.supportedModes_.includes(vrMojom.XRSessionMode.kInline)) {
this.displayInfo_ = this.getNonImmersiveDisplayInfo();
} else {
// This should never happen!
@@ -458,10 +462,11 @@
if (blendMode in MockRuntime.environmentBlendModeToMojoMap) {
return MockRuntime.environmentBlendModeToMojoMap[blendMode];
} else {
- if (this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
- return device.mojom.XREnvironmentBlendMode.kAdditive;
- } else if (this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveVr)) {
- return device.mojom.XREnvironmentBlendMode.kOpaque;
+ if (this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {
+ return vrMojom.XREnvironmentBlendMode.kAdditive;
+ } else if (this.supportedModes_.includes(
+ vrMojom.XRSessionMode.kImmersiveVr)) {
+ return vrMojom.XREnvironmentBlendMode.kOpaque;
}
}
}
@@ -470,7 +475,7 @@
if (interactionMode in MockRuntime.interactionModeToMojoMap) {
return MockRuntime.interactionModeToMojoMap[interactionMode];
} else {
- return device.mojom.XRInteractionMode.kWorldSpace;
+ return vrMojom.XRInteractionMode.kWorldSpace;
}
}
@@ -478,8 +483,9 @@
disconnect() {
this.service_.removeRuntime(this);
this.presentation_provider_.Close();
- if (this.sessionClient_.ptr.isBound()) {
- this.sessionClient_.ptr.reset();
+ if (this.sessionClient_) {
+ this.sessionClient_.$.close();
+ this.sessionClient_ = null;
}
return Promise.resolve();
@@ -498,7 +504,7 @@
}
}
- if (changed && this.sessionClient_.ptr.isBound()) {
+ if (changed && this.sessionClient_) {
this.sessionClient_.onChanged(this.displayInfo_);
}
}
@@ -528,16 +534,16 @@
let mojoState = null;
switch (visibilityState) {
case "visible":
- mojoState = device.mojom.XRVisibilityState.VISIBLE;
+ mojoState = vrMojom.XRVisibilityState.VISIBLE;
break;
case "visible-blurred":
- mojoState = device.mojom.XRVisibilityState.VISIBLE_BLURRED;
+ mojoState = vrMojom.XRVisibilityState.VISIBLE_BLURRED;
break;
case "hidden":
- mojoState = device.mojom.XRVisibilityState.HIDDEN;
+ mojoState = vrMojom.XRVisibilityState.HIDDEN;
break;
}
- if (mojoState) {
+ if (mojoState && this.sessionClient_) {
this.sessionClient_.onVisibilityStateChanged(mojoState);
}
}
@@ -567,11 +573,9 @@
this.stageParameters_.bounds = this.bounds_;
}
- this.stageParameters_.mojoFromFloor = new gfx.mojom.Transform();
-
// floorOrigin is passed in as mojoFromFloor.
- this.stageParameters_.mojoFromFloor.matrix =
- getMatrixFromTransform(floorOrigin);
+ this.stageParameters_.mojoFromFloor =
+ {matrix: getMatrixFromTransform(floorOrigin)};
this.onStageParametersUpdated();
}
@@ -707,7 +711,7 @@
if (feature in MockRuntime.featureToMojoMap) {
return MockRuntime.featureToMojoMap[feature];
} else {
- return device.mojom.XRSessionFeature.INVALID;
+ return vrMojom.XRSessionFeature.INVALID;
}
}
@@ -715,7 +719,7 @@
for (let i = 0; i < supportedFeatures.length; i++) {
const feature = convertFeatureToMojom(supportedFeatures[i]);
- if (feature !== device.mojom.XRSessionFeature.INVALID) {
+ if (feature !== vrMojom.XRSessionFeature.INVALID) {
this.supportedFeatures_.push(feature);
}
}
@@ -774,11 +778,12 @@
inputState: input_state,
timeDelta: {
// window.performance.now() is in milliseconds, so convert to microseconds.
- microseconds: window.performance.now() * 1000,
+ microseconds: BigInt(Math.floor(window.performance.now() * 1000)),
},
frameId: this.next_frame_id_,
bufferHolder: null,
bufferSize: {},
+ renderingTimeRatio: 0,
stageParameters: this.stageParameters_,
stageParametersId: this.stageParametersId_,
};
@@ -794,7 +799,7 @@
resolve({frameData});
};
- if(this.sessionOptions_.mode == device.mojom.XRSessionMode.kInline) {
+ if(this.sessionOptions_.mode == vrMojom.XRSessionMode.kInline) {
// Inline sessions should not have a delay introduced since it causes them
// to miss a vsync blink-side and delays propagation of changes that happened
// within a rAFcb by one frame (e.g. setViewerOrigin() calls would take 2 frames
@@ -809,37 +814,46 @@
}
getEnvironmentIntegrationProvider(environmentProviderRequest) {
- this.environmentProviderBinding_ = new mojo.AssociatedBinding(
- device.mojom.XREnvironmentIntegrationProvider, this,
- environmentProviderRequest);
+ if (this.environmentProviderReceiver_) {
+ this.environmentProviderReceiver_.$.close();
+ }
+ this.environmentProviderReceiver_ =
+ new vrMojom.XREnvironmentIntegrationProviderReceiver(this);
+ this.environmentProviderReceiver_.$.bindHandle(
+ environmentProviderRequest.handle);
}
+ setInputSourceButtonListener(listener) { listener.$.close(); }
+
// Note that if getEnvironmentProvider hasn't finished running yet this will
// be undefined. It's recommended that you allow a successful task to post
// first before attempting to close.
closeEnvironmentIntegrationProvider() {
- this.environmentProviderBinding_.close();
+ if (this.environmentProviderReceiver_) {
+ this.environmentProviderReceiver_.$.close();
+ }
}
closeDataProvider() {
- this.dataProviderBinding_.close();
+ this.closeEnvironmentIntegrationProvider();
+ this.dataProviderReceiver_.$.close();
this.sessionOptions_ = null;
}
// XREnvironmentIntegrationProvider implementation:
subscribeToHitTest(nativeOriginInformation, entityTypes, ray) {
- if (!this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
+ if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {
// Reject outside of AR.
return Promise.resolve({
- result : device.mojom.SubscribeToHitTestResult.FAILURE_GENERIC,
- subscriptionId : 0
+ result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,
+ subscriptionId : 0n
});
}
if (!this._nativeOriginKnown(nativeOriginInformation)) {
return Promise.resolve({
- result : device.mojom.SubscribeToHitTestResult.FAILURE_GENERIC,
- subscriptionId : 0
+ result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,
+ subscriptionId : 0n
});
}
@@ -856,24 +870,24 @@
this.hitTestSubscriptions_.set(id, { nativeOriginInformation, entityTypes, ray, controller });
return Promise.resolve({
- result : device.mojom.SubscribeToHitTestResult.SUCCESS,
+ result : vrMojom.SubscribeToHitTestResult.SUCCESS,
subscriptionId : id
});
} else {
return Promise.resolve({
- result : device.mojom.SubscribeToHitTestResult.FAILURE_GENERIC,
- subscriptionId : 0
+ result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,
+ subscriptionId : 0n
});
}
});
}
subscribeToHitTestForTransientInput(profileName, entityTypes, ray){
- if (!this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
+ if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {
// Reject outside of AR.
return Promise.resolve({
- result : device.mojom.SubscribeToHitTestResult.FAILURE_GENERIC,
- subscriptionId : 0
+ result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,
+ subscriptionId : 0n
});
}
@@ -891,13 +905,13 @@
this.transientHitTestSubscriptions_.set(id, { profileName, entityTypes, ray, controller });
return Promise.resolve({
- result : device.mojom.SubscribeToHitTestResult.SUCCESS,
+ result : vrMojom.SubscribeToHitTestResult.SUCCESS,
subscriptionId : id
});
} else {
return Promise.resolve({
- result : device.mojom.SubscribeToHitTestResult.FAILURE_GENERIC,
- subscriptionId : 0
+ result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,
+ subscriptionId : 0n
});
}
});
@@ -922,8 +936,8 @@
return new Promise((resolve) => {
if(this.anchor_creation_callback_ == null) {
resolve({
- result : device.mojom.CreateAnchorResult.FAILURE,
- anchorId : 0
+ result : vrMojom.CreateAnchorResult.FAILURE,
+ anchorId : 0n
});
return;
@@ -932,8 +946,8 @@
const mojoFromNativeOrigin = this._getMojoFromNativeOrigin(nativeOriginInformation);
if(mojoFromNativeOrigin == null) {
resolve({
- result : device.mojom.CreateAnchorResult.FAILURE,
- anchorId : 0
+ result : vrMojom.CreateAnchorResult.FAILURE,
+ anchorId : 0n
});
return;
@@ -962,22 +976,22 @@
anchorController.id = anchor_id;
resolve({
- result : device.mojom.CreateAnchorResult.SUCCESS,
+ result : vrMojom.CreateAnchorResult.SUCCESS,
anchorId : anchor_id
});
} else {
// The test has rejected anchor creation.
resolve({
- result : device.mojom.CreateAnchorResult.FAILURE,
- anchorId : 0
+ result : vrMojom.CreateAnchorResult.FAILURE,
+ anchorId : 0n
});
}
})
.catch(() => {
// The test threw an error, treat anchor creation as failed.
resolve({
- result : device.mojom.CreateAnchorResult.FAILURE,
- anchorId : 0
+ result : vrMojom.CreateAnchorResult.FAILURE,
+ anchorId : 0n
});
});
});
@@ -989,21 +1003,25 @@
// Not supported yet.
resolve({
- result : device.mojom.CreateAnchorResult.FAILURE,
- anchorId : 0
+ result : vrMojom.CreateAnchorResult.FAILURE,
+ anchorId : 0n,
});
});
}
+ detachAnchor(anchorId) {}
+
// Utility function
requestRuntimeSession(sessionOptions) {
return this.runtimeSupportsSession(sessionOptions).then((result) => {
// The JavaScript bindings convert c_style_names to camelCase names.
- const options = new device.mojom.XRPresentationTransportOptions();
- options.transportMethod =
- device.mojom.XRPresentationTransportMethod.SUBMIT_AS_MAILBOX_HOLDER;
- options.waitForTransferNotification = true;
- options.waitForRenderNotification = true;
+ const options = {
+ transportMethod:
+ vrMojom.XRPresentationTransportMethod.SUBMIT_AS_MAILBOX_HOLDER,
+ waitForTransferNotification: true,
+ waitForRenderNotification: true,
+ waitForGpuFence: false,
+ };
let submit_frame_sink;
if (result.supportsSession) {
@@ -1013,13 +1031,15 @@
transportOptions: options
};
- const dataProviderPtr = new device.mojom.XRFrameDataProviderPtr();
- const dataProviderRequest = mojo.makeRequest(dataProviderPtr);
- this.dataProviderBinding_ = new mojo.Binding(
- device.mojom.XRFrameDataProvider, this, dataProviderRequest);
+ const dataProviderPtr = new vrMojom.XRFrameDataProviderRemote();
+ this.dataProviderReceiver_ =
+ new vrMojom.XRFrameDataProviderReceiver(this);
+ this.dataProviderReceiver_.$.bindHandle(
+ dataProviderPtr.$.bindNewPipeAndPassReceiver().handle);
this.sessionOptions_ = sessionOptions;
- const clientReceiver = mojo.makeRequest(this.sessionClient_);
+ this.sessionClient_ = new vrMojom.XRSessionClientRemote();
+ const clientReceiver = this.sessionClient_.$.bindNewPipeAndPassReceiver();
const enabled_features = [];
for (let i = 0; i < sessionOptions.requiredFeatures.length; i++) {
@@ -1044,6 +1064,7 @@
displayInfo: this.displayInfo_,
enabledFeatures: enabled_features,
deviceConfig: {
+ usesInputEventing: false,
defaultFramebufferScale: this.defaultFramebufferScale_,
supportsViewportScaling: true
},
@@ -1066,17 +1087,17 @@
// Private functions - utilities:
_nativeOriginKnown(nativeOriginInformation){
- if (nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.inputSourceId) {
+ if (nativeOriginInformation.inputSourceId !== undefined) {
if (!this.input_sources_.has(nativeOriginInformation.inputSourceId)) {
// Unknown input source.
return false;
}
return true;
- } else if (nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.referenceSpaceType) {
+ } else if (nativeOriginInformation.referenceSpaceType !== undefined) {
// Bounded_floor & unbounded ref spaces are not yet supported for AR:
- if (nativeOriginInformation.referenceSpaceType == device.mojom.XRReferenceSpaceType.kUnbounded
- || nativeOriginInformation.referenceSpaceType == device.mojom.XRReferenceSpaceType.kBoundedFlor) {
+ if (nativeOriginInformation.referenceSpaceType == vrMojom.XRReferenceSpaceType.kUnbounded
+ || nativeOriginInformation.referenceSpaceType == vrMojom.XRReferenceSpaceType.kBoundedFloor) {
return false;
}
@@ -1091,24 +1112,21 @@
// Modifies passed in frameData to add anchor information.
_calculateAnchorInformation(frameData) {
- if (!this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
+ if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {
return;
}
- frameData.anchorsData = new device.mojom.XRAnchorsData();
- frameData.anchorsData.allAnchorsIds = [];
- frameData.anchorsData.updatedAnchorsData = [];
-
+ frameData.anchorsData = {allAnchorsIds: [], updatedAnchorsData: []};
for(const [id, controller] of this.anchor_controllers_) {
frameData.anchorsData.allAnchorsIds.push(id);
// Send the entire anchor data over if there was a change since last GetFrameData().
if(controller.dirty) {
- const anchorData = new device.mojom.XRAnchorData();
- anchorData.id = id;
+ const anchorData = {id};
if(!controller.paused) {
- anchorData.mojoFromAnchor = XRMathHelper.decomposeRigidTransform(
- controller.getAnchorOrigin());
+ anchorData.mojoFromAnchor = getPoseFromTransform(
+ XRMathHelper.decomposeRigidTransform(
+ controller.getAnchorOrigin()));
}
controller.markProcessed();
@@ -1133,14 +1151,12 @@
// Modifies passed in frameData to add hit test results.
_calculateHitTestResults(frameData) {
- if (!this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
+ if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {
return;
}
- frameData.hitTestSubscriptionResults = new device.mojom.XRHitTestSubscriptionResultsData();
- frameData.hitTestSubscriptionResults.results = [];
- frameData.hitTestSubscriptionResults.transientInputResults = [];
-
+ frameData.hitTestSubscriptionResults = {results: [],
+ transientInputResults: []};
if (!this.world_) {
return;
}
@@ -1156,21 +1172,16 @@
);
const results = this._hitTestWorld(mojo_ray_origin, mojo_ray_direction, subscription.entityTypes);
-
- const result = new device.mojom.XRHitTestSubscriptionResultData();
- result.subscriptionId = id;
- result.hitTestResults = results;
-
- frameData.hitTestSubscriptionResults.results.push(result);
+ frameData.hitTestSubscriptionResults.results.push(
+ {subscriptionId: id, hitTestResults: results});
}
// Transient hit test:
const mojo_from_viewer = this._getMojoFromViewer();
for (const [id, subscription] of this.transientHitTestSubscriptions_) {
- const result = new device.mojom.XRHitTestTransientInputSubscriptionResultData();
- result.subscriptionId = id;
- result.inputSourceIdToHitTestResults = new Map();
+ const result = {subscriptionId: id,
+ inputSourceIdToHitTestResults: new Map()};
// Find all input sources that match the profile name:
const matching_input_sources = Array.from(this.input_sources_.values())
@@ -1241,8 +1252,8 @@
// Returns array of XRHitResults, each entry will be decorated with the distance from the ray origin (along the ray).
_hitTestRegion(region, origin, direction, entityTypes) {
const regionNameToMojoEnum = {
- "point":device.mojom.EntityTypeForHitTest.POINT,
- "plane":device.mojom.EntityTypeForHitTest.PLANE,
+ "point": vrMojom.EntityTypeForHitTest.POINT,
+ "plane": vrMojom.EntityTypeForHitTest.PLANE,
"mesh":null
};
@@ -1333,7 +1344,7 @@
return null;
}
- const hitResult = new device.mojom.XRHitResult();
+ const hitResult = {planeId: 0n};
hitResult.distance = distance; // Extend the object with additional information used by higher layers.
// It will not be serialized over mojom.
@@ -1359,8 +1370,8 @@
matrix[14] = intersection_point.z;
matrix[15] = 1;
- hitResult.mojoFromResult = XRMathHelper.decomposeRigidTransform(matrix);
-
+ hitResult.mojoFromResult = getPoseFromTransform(
+ XRMathHelper.decomposeRigidTransform(matrix));
return hitResult;
}
}
@@ -1385,28 +1396,28 @@
_getMojoFromNativeOrigin(nativeOriginInformation) {
const mojo_from_viewer = this._getMojoFromViewer();
- if (nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.inputSourceId) {
+ if (nativeOriginInformation.inputSourceId !== undefined) {
if (!this.input_sources_.has(nativeOriginInformation.inputSourceId)) {
return null;
} else {
const inputSource = this.input_sources_.get(nativeOriginInformation.inputSourceId);
return inputSource._getMojoFromInputSource(mojo_from_viewer);
}
- } else if (nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.referenceSpaceType) {
+ } else if (nativeOriginInformation.referenceSpaceType !== undefined) {
switch (nativeOriginInformation.referenceSpaceType) {
- case device.mojom.XRReferenceSpaceType.kLocal:
+ case vrMojom.XRReferenceSpaceType.kLocal:
return XRMathHelper.identity();
- case device.mojom.XRReferenceSpaceType.kLocalFloor:
+ case vrMojom.XRReferenceSpaceType.kLocalFloor:
if (this.stageParameters_ == null || this.stageParameters_.mojoFromFloor == null) {
console.warn("Standing transform not available.");
return null;
}
return this.stageParameters_.mojoFromFloor.matrix;
- case device.mojom.XRReferenceSpaceType.kViewer:
+ case vrMojom.XRReferenceSpaceType.kViewer:
return mojo_from_viewer;
- case device.mojom.XRReferenceSpaceType.kBoundedFlor:
+ case vrMojom.XRReferenceSpaceType.kBoundedFloor:
return null;
- case device.mojom.XRReferenceSpaceType.kUnbounded:
+ case vrMojom.XRReferenceSpaceType.kUnbounded:
return null;
default:
throw new TypeError("Unrecognized XRReferenceSpaceType!");
@@ -1418,12 +1429,6 @@
}
}
-class MockXRSessionMetricsRecorder {
- reportFeatureUsed(feature) {
- // Do nothing
- }
-}
-
class MockXRInputSource {
constructor(fakeInputSourceInit, id, pairedDevice) {
this.source_id_ = id;
@@ -1633,9 +1638,10 @@
// Helpers for Mojom
getInputSourceState() {
- const input_state = new device.mojom.XRInputSourceState();
+ const input_state = {};
input_state.sourceId = this.source_id_;
+ input_state.isAuxiliary = false;
input_state.primaryInputPressed = this.primary_input_pressed_;
input_state.primaryInputClicked = this.primary_input_clicked_;
@@ -1658,17 +1664,17 @@
input_state.emulatedPosition = this.emulated_position_;
if (this.desc_dirty_) {
- const input_desc = new device.mojom.XRInputSourceDescription();
+ const input_desc = {};
switch (this.target_ray_mode_) {
case 'gaze':
- input_desc.targetRayMode = device.mojom.XRTargetRayMode.GAZING;
+ input_desc.targetRayMode = vrMojom.XRTargetRayMode.GAZING;
break;
case 'tracked-pointer':
- input_desc.targetRayMode = device.mojom.XRTargetRayMode.POINTING;
+ input_desc.targetRayMode = vrMojom.XRTargetRayMode.POINTING;
break;
case 'screen':
- input_desc.targetRayMode = device.mojom.XRTargetRayMode.TAPPING;
+ input_desc.targetRayMode = vrMojom.XRTargetRayMode.TAPPING;
break;
default:
throw new Error('Unhandled target ray mode ' + this.target_ray_mode_);
@@ -1676,13 +1682,13 @@
switch (this.handedness_) {
case 'left':
- input_desc.handedness = device.mojom.XRHandedness.LEFT;
+ input_desc.handedness = vrMojom.XRHandedness.LEFT;
break;
case 'right':
- input_desc.handedness = device.mojom.XRHandedness.RIGHT;
+ input_desc.handedness = vrMojom.XRHandedness.RIGHT;
break;
default:
- input_desc.handedness = device.mojom.XRHandedness.NONE;
+ input_desc.handedness = vrMojom.XRHandedness.NONE;
break;
}
@@ -1716,7 +1722,7 @@
// Since we store mojo_from_input, we need to invert it here before
// multiplying.
let input_from_mojo = XRMathHelper.inverse(mojo_from_input);
- input_desc.inputFromPointer = new gfx.mojom.Transform();
+ input_desc.inputFromPointer = {};
input_desc.inputFromPointer.matrix =
XRMathHelper.mul4x4(input_from_mojo, this.mojo_from_pointer_.matrix);
@@ -1745,23 +1751,23 @@
// everything to reasonable defaults that tests can override.
const gamepad = {
connected: true,
- id: "",
- timestamp: 0,
+ id: [],
+ timestamp: 0n,
axes: [],
buttons: [],
- mapping: "xr-standard",
- display_id: 0,
+ mapping: GamepadMapping.GamepadMappingStandard,
+ displayId: 0,
};
switch (this.handedness_) {
case 'left':
- gamepad.hand = device.mojom.GamepadHand.GamepadHandLeft;
+ gamepad.hand = GamepadHand.GamepadHandLeft;
break;
case 'right':
- gamepad.hand = device.mojom.GamepadHand.GamepadHandRight;
+ gamepad.hand = GamepadHand.GamepadHandRight;
break;
default:
- gamepad.hand = device.mojom.GamepadHand.GamepadHandNone;
+ gamepad.hand = GamepadHand.GamepadHandNone;
break;
}
@@ -1832,29 +1838,29 @@
// Mojo helper classes
class MockXRPresentationProvider {
constructor() {
- this.binding_ = new mojo.Binding(device.mojom.XRPresentationProvider, this);
-
+ this.receiver_ = null;
this.submit_frame_count_ = 0;
this.missing_frame_count_ = 0;
}
- bindProvider(request) {
- const providerPtr = new device.mojom.XRPresentationProviderPtr();
- const providerRequest = mojo.makeRequest(providerPtr);
+ bindProvider() {
+ const provider = new vrMojom.XRPresentationProviderRemote();
- this.binding_.close();
-
- this.binding_ = new mojo.Binding(
- device.mojom.XRPresentationProvider, this, providerRequest);
-
- return providerPtr;
+ if (this.receiver_) {
+ this.receiver_.$.close();
+ }
+ this.receiver_ = new vrMojom.XRPresentationProviderReceiver(this);
+ this.receiver_.$.bindHandle(provider.$.bindNewPipeAndPassReceiver().handle);
+ return provider;
}
getClientReceiver() {
- this.submitFrameClient_ = new device.mojom.XRPresentationClientPtr();
- return mojo.makeRequest(this.submitFrameClient_);
+ this.submitFrameClient_ = new vrMojom.XRPresentationClientRemote();
+ return this.submitFrameClient_.$.bindNewPipeAndPassReceiver();
}
+ updateLayerBounds(frameId, leftBounds, rightBounds, sourceSize) {}
+
// XRPresentationProvider mojo implementation
submitFrameMissing(frameId, mailboxHolder, timeWaited) {
this.missing_frame_count_++;
@@ -1872,10 +1878,23 @@
this.submitFrameClient_.onSubmitFrameRendered();
}
+ submitFrameWithTextureHandle(frameId, texture) {}
+
+ submitFrameDrawnIntoTexture(frameId, syncToken, timeWaited) {}
+
// Utility methods
Close() {
- this.binding_.close();
+ if (this.receiver_) {
+ this.receiver_.$.close();
+ }
}
}
+// Export these into the global object as a side effect of importing this
+// module.
+self.ChromeXRTest = ChromeXRTest;
+self.MockRuntime = MockRuntime;
+self.MockVRService = MockVRService;
+self.SubscribeToHitTestResult = vrMojom.SubscribeToHitTestResult;
+
navigator.xr.test = new ChromeXRTest();
diff --git a/third_party/blink/web_tests/external/wpt/resources/test-only-api.js b/third_party/blink/web_tests/external/wpt/resources/test-only-api.js
index ef66e0e..a66eb44 100644
--- a/third_party/blink/web_tests/external/wpt/resources/test-only-api.js
+++ b/third_party/blink/web_tests/external/wpt/resources/test-only-api.js
@@ -29,72 +29,3 @@
return p;
}
}
-
-/**
- * A helper for Chromium-based browsers to load Mojo JS bindings
- *
- * This is an async function that works in both workers and windows. It first
- * loads mojo_bindings.js, disables automatic dependency loading, and loads all
- * resources sequentially. The promise resolves if everything loads
- * successfully, or rejects if any exception is raised. If testharness.js is
- * used, an uncaught exception will terminate the test with a harness error
- * (unless `allow_uncaught_exception` is true), which is usually the desired
- * behaviour.
- *
- * This function also works with Blink web tests loaded from file://, in which
- * case file:// will be prepended to all '/gen/...' URLs.
- *
- * Only call this function if isChromiumBased === true.
- *
- * @param {Array.<string>} resources - A list of scripts to load: Mojo JS
- * bindings should be of the form '/gen/../*.mojom.js' or
- * '/gen/../*.mojom-lite.js' (requires `lite` to be true); the order does not
- * matter. Do not include 'mojo_bindings.js' or 'mojo_bindings_lite.js'.
- * @param {boolean=} lite - Whether the lite bindings (*.mojom-lite.js) are used
- * (default is false).
- * @returns {Promise}
- */
-async function loadMojoResources(resources, lite = false) {
- if (!isChromiumBased) {
- throw new Error('MojoJS not enabled; start Chrome with --enable-blink-features=MojoJS,MojoJSTest');
- }
- if (resources.length == 0) {
- return;
- }
-
- let genPrefix = '';
- if (self.location.pathname.includes('/web_tests/')) {
- // Blink internal web tests
- genPrefix = 'file://';
- }
-
- for (const path of resources) {
- // We want to load mojo_bindings.js separately to set mojo.config.
- if (path.endsWith('/mojo_bindings.js')) {
- throw new Error('Do not load mojo_bindings.js explicitly.');
- }
- if (path.endsWith('/mojo_bindings_lite.js')) {
- throw new Error('Do not load mojo_bindings_lite.js explicitly.');
- }
- if (lite) {
- if (! /^\/gen\/.*\.mojom-lite\.js$/.test(path)) {
- throw new Error(`Unrecognized resource path: ${path}`);
- }
- } else {
- if (! /^\/gen\/.*\.mojom\.js$/.test(path)) {
- throw new Error(`Unrecognized resource path: ${path}`);
- }
- }
- }
-
- if (lite) {
- await loadScript(genPrefix + '/gen/layout_test_data/mojo/public/js/mojo_bindings_lite.js');
- } else {
- await loadScript(genPrefix + '/gen/layout_test_data/mojo/public/js/mojo_bindings.js');
- mojo.config.autoLoadMojomDeps = false;
- }
-
- for (const path of resources) {
- await loadScript(genPrefix + path);
- }
-}
diff --git a/third_party/blink/web_tests/external/wpt/screen_enumeration/resources/screenenumeration-helpers.js b/third_party/blink/web_tests/external/wpt/screen_enumeration/resources/screenenumeration-helpers.js
index 7d5d522..d0e0d9c 100644
--- a/third_party/blink/web_tests/external/wpt/screen_enumeration/resources/screenenumeration-helpers.js
+++ b/third_party/blink/web_tests/external/wpt/screen_enumeration/resources/screenenumeration-helpers.js
@@ -7,19 +7,10 @@
// --enable-blink-features=MojoJS,MojoJSTest
async function loadChromiumResources() {
- const chromiumResources = [
- '/gen/ui/gfx/mojom/color_space.mojom.js',
- '/gen/ui/gfx/mojom/buffer_types.mojom.js',
- '/gen/ui/gfx/mojom/display_color_spaces.mojom.js',
- '/gen/ui/gfx/geometry/mojom/geometry.mojom.js',
- '/gen/ui/display/mojom/display.mojom.js',
- '/gen/third_party/blink/public/mojom/screen_enumeration/screen_enumeration.mojom.js'
- ];
-
- await loadMojoResources(chromiumResources);
await loadScript('/resources/testdriver.js');
await loadScript('/resources/testdriver-vendor.js');
- await loadScript('/resources/chromium/mock-screenenumeration.js');
+ const {HelperTypes} = await import('/resources/chromium/mock-screenenumeration.js');
+ self.HelperTypes = HelperTypes;
}
async function initialize_screen_enumeration_tests() {
@@ -57,28 +48,24 @@
function makeDisplay(id, bounds, work_area, scale_factor) {
let myColorSpace = fillColorSpaceVector();
let myBufferFormat = fillBufferFormatVector();
- let newDisplay = new display.mojom.Display({id: id,
- bounds: new gfx.mojom.Rect({x: bounds.x, y: bounds.y,
- width: bounds.width,
- height: bounds.height}),
- sizeInPixels: new gfx.mojom.Size({width: bounds.width,
- height: bounds.height}),
- maximumCursorSize: new gfx.mojom.Size({width: 20, height: 20}),
- workArea: new gfx.mojom.Rect({x: work_area.x, y: work_area.y,
- width: work_area.width,
- height: work_area.height}),
- deviceScaleFactor: scale_factor,
- rotation: display.mojom.Rotation.VALUE_0,
- touchSupport: display.mojom.TouchSupport.UNAVAILABLE,
- accelerometerSupport: display.mojom.AccelerometerSupport.UNAVAILABLE,
- colorSpaces: new gfx.mojom.DisplayColorSpaces({colorSpaces: myColorSpace,
- bufferFormats: myBufferFormat,
- sdrWhiteLevel: 1.0}),
- colorDepth: 10,
- depthPerComponent: 10,
- isMonochrome: true,
- displayFrequency: 120});
- return newDisplay;
+ return {
+ id,
+ bounds,
+ sizeInPixels: {width: bounds.width, height: bounds.height},
+ maximumCursorSize: {width: 20, height: 20},
+ workArea: work_area,
+ deviceScaleFactor: scale_factor,
+ rotation: HelperTypes.Rotation.VALUE_0,
+ touchSupport: HelperTypes.TouchSupport.UNAVAILABLE,
+ accelerometerSupport: HelperTypes.AccelerometerSupport.UNAVAILABLE,
+ colorSpaces: {colorSpaces: myColorSpace,
+ bufferFormats: myBufferFormat,
+ sdrWhiteLevel: 1.0},
+ colorDepth: 10,
+ depthPerComponent: 10,
+ isMonochrome: true,
+ displayFrequency: 120
+ };
}
// Function to construct color space vector.
@@ -86,13 +73,14 @@
function fillColorSpaceVector() {
let colorSpaceVector = [];
for (let i = 0; i < 6; i++) {
- let colorSpace = new gfx.mojom.ColorSpace({
- primaries: gfx.mojom.ColorSpacePrimaryID.BT709,
- transfer: gfx.mojom.ColorSpaceTransferID.BT709,
- matrix: gfx.mojom.ColorSpaceMatrixID.BT709,
- range: gfx.mojom.ColorSpaceRangeID.LIMITED,
- customPrimaryMatrix: fillCustomPrimaryMatrix(),
- transferParams: fillTransferParams()});
+ let colorSpace = {
+ primaries: HelperTypes.ColorSpacePrimaryID.BT709,
+ transfer: HelperTypes.ColorSpaceTransferID.BT709,
+ matrix: HelperTypes.ColorSpaceMatrixID.BT709,
+ range: HelperTypes.ColorSpaceRangeID.LIMITED,
+ customPrimaryMatrix: fillCustomPrimaryMatrix(),
+ transferParams: fillTransferParams()
+ };
colorSpaceVector.push(colorSpace);
}
return colorSpaceVector;
@@ -115,12 +103,12 @@
// Function to construct buffer format vector.
// Values are purely random but mandatory.
function fillBufferFormatVector() {
-
- let bufferFormat = [gfx.mojom.BufferFormat.RGBA_8888,
- gfx.mojom.BufferFormat.RGBA_8888,
- gfx.mojom.BufferFormat.RGBA_8888,
- gfx.mojom.BufferFormat.RGBA_8888,
- gfx.mojom.BufferFormat.RGBA_8888,
- gfx.mojom.BufferFormat.RGBA_8888];
+ const BufferFormat = HelperTypes.BufferFormat;
+ let bufferFormat = [BufferFormat.RGBA_8888,
+ BufferFormat.RGBA_8888,
+ BufferFormat.RGBA_8888,
+ BufferFormat.RGBA_8888,
+ BufferFormat.RGBA_8888,
+ BufferFormat.RGBA_8888];
return bufferFormat;
}
diff --git a/third_party/blink/web_tests/external/wpt/serial/resources/automation.js b/third_party/blink/web_tests/external/wpt/serial/resources/automation.js
index 98f67fb6..e88fdb1a 100644
--- a/third_party/blink/web_tests/external/wpt/serial/resources/automation.js
+++ b/third_party/blink/web_tests/external/wpt/serial/resources/automation.js
@@ -11,14 +11,7 @@
//
// --enable-blink-features=MojoJS,MojoJSTest
-async function loadChromiumResources() {
- const chromiumResources = [
- '/gen/mojo/public/mojom/base/unguessable_token.mojom.js',
- '/gen/services/device/public/mojom/serial.mojom.js',
- '/gen/third_party/blink/public/mojom/serial/serial.mojom.js',
- ];
- await loadMojoResources(chromiumResources);
-}
+let fakeSerialService = undefined;
// Returns a SerialPort instance and associated FakeSerialPort instance.
async function getFakeSerialPort(fake) {
@@ -34,16 +27,14 @@
return { port, fakePort };
}
-let fakeSerialService = undefined;
-
function serial_test(func, name, properties) {
promise_test(async (test) => {
assert_implements(navigator.serial, 'missing navigator.serial');
if (fakeSerialService === undefined) {
// Try loading a polyfill for the fake serial service.
if (isChromiumBased) {
- await loadChromiumResources();
- await loadScript('/resources/chromium/fake-serial.js');
+ const fakes = await import('/resources/chromium/fake-serial.js');
+ fakeSerialService = fakes.fakeSerialService;
}
}
assert_implements(fakeSerialService, 'missing fakeSerialService after initialization');
diff --git a/third_party/blink/web_tests/external/wpt/shape-detection/detection-options.https.html b/third_party/blink/web_tests/external/wpt/shape-detection/detection-options.https.html
index db870e8..4b79da2 100644
--- a/third_party/blink/web_tests/external/wpt/shape-detection/detection-options.https.html
+++ b/third_party/blink/web_tests/external/wpt/shape-detection/detection-options.https.html
@@ -36,8 +36,7 @@
barcodeDetectionResult = await detectorWithOptions.detect(img);
assert_array_equals(
mock.getFormats(),
- [shapeDetection.mojom.BarcodeFormat.CODE_128,
- shapeDetection.mojom.BarcodeFormat.QR_CODE],
+ [BarcodeFormat.CODE_128, BarcodeFormat.QR_CODE],
"formats");
const invalidFormats = [
diff --git a/third_party/blink/web_tests/external/wpt/shape-detection/resources/shapedetection-helpers.js b/third_party/blink/web_tests/external/wpt/shape-detection/resources/shapedetection-helpers.js
index 05424de8..1b4949b8 100644
--- a/third_party/blink/web_tests/external/wpt/shape-detection/resources/shapedetection-helpers.js
+++ b/third_party/blink/web_tests/external/wpt/shape-detection/resources/shapedetection-helpers.js
@@ -10,23 +10,9 @@
// --enable-blink-features=MojoJS,MojoJSTest
async function loadChromiumResources() {
- const prefix = '/gen/services/shape_detection/public/mojom';
- const chromiumResources = [
- '/gen/mojo/public/mojom/base/big_buffer.mojom.js',
- '/gen/skia/public/mojom/image_info.mojom.js',
- '/gen/skia/public/mojom/bitmap.mojom.js',
- '/gen/ui/gfx/geometry/mojom/geometry.mojom.js',
- `${prefix}/barcodedetection.mojom.js`,
- `${prefix}/barcodedetection_provider.mojom.js`,
- `${prefix}/facedetection.mojom.js`,
- `${prefix}/facedetection_provider.mojom.js`,
- `${prefix}/textdetection.mojom.js`,
- ];
-
- await loadMojoResources(chromiumResources);
- await loadScript('/resources/chromium/mock-barcodedetection.js');
- await loadScript('/resources/chromium/mock-facedetection.js');
- await loadScript('/resources/chromium/mock-textdetection.js');
+ await import('/resources/chromium/mock-barcodedetection.js');
+ await import('/resources/chromium/mock-facedetection.js');
+ await import('/resources/chromium/mock-textdetection.js');
}
/**
@@ -81,7 +67,7 @@
}
function getArrayBufferFromBigBuffer(bigBuffer) {
- if (bigBuffer.$tag == mojoBase.mojom.BigBuffer.Tags.bytes) {
+ if (bigBuffer.bytes !== undefined) {
return new Uint8Array(bigBuffer.bytes).buffer;
}
return bigBuffer.sharedMemory.bufferHandle.mapBuffer(0,
diff --git a/third_party/blink/web_tests/external/wpt/web-nfc/resources/nfc-helpers.js b/third_party/blink/web_tests/external/wpt/web-nfc/resources/nfc-helpers.js
index 659f74e..35154e28 100644
--- a/third_party/blink/web_tests/external/wpt/web-nfc/resources/nfc-helpers.js
+++ b/third_party/blink/web_tests/external/wpt/web-nfc/resources/nfc-helpers.js
@@ -9,14 +9,9 @@
// --enable-blink-features=MojoJS,MojoJSTest
async function loadChromiumResources() {
- const chromiumResources = [
- '/gen/services/device/public/mojom/nfc.mojom.js',
- ];
-
- await loadMojoResources(chromiumResources);
await loadScript('/resources/testdriver.js');
await loadScript('/resources/testdriver-vendor.js');
- await loadScript('/resources/chromium/nfc-mock.js');
+ await import('/resources/chromium/nfc-mock.js');
}
async function initialize_nfc_tests() {
diff --git a/third_party/blink/web_tests/external/wpt/webxr/resources/webxr_util.js b/third_party/blink/web_tests/external/wpt/webxr/resources/webxr_util.js
index fc4ca7d0d..8ca79182 100644
--- a/third_party/blink/web_tests/external/wpt/webxr/resources/webxr_util.js
+++ b/third_party/blink/web_tests/external/wpt/webxr/resources/webxr_util.js
@@ -204,42 +204,19 @@
// Code for loading test API in Chromium.
async function loadChromiumResources() {
- const chromiumResources = [
- '/gen/mojo/public/mojom/base/time.mojom.js',
- '/gen/mojo/public/mojom/base/shared_memory.mojom.js',
- '/gen/mojo/public/mojom/base/unguessable_token.mojom.js',
- '/gen/gpu/ipc/common/sync_token.mojom.js',
- '/gen/gpu/ipc/common/mailbox.mojom.js',
- '/gen/gpu/ipc/common/mailbox_holder.mojom.js',
- '/gen/ui/gfx/geometry/mojom/geometry.mojom.js',
- '/gen/ui/gfx/mojom/native_handle_types.mojom.js',
- '/gen/ui/gfx/mojom/buffer_types.mojom.js',
- '/gen/ui/gfx/mojom/color_space.mojom.js',
- '/gen/ui/gfx/mojom/display_color_spaces.mojom.js',
- '/gen/ui/gfx/mojom/gpu_fence_handle.mojom.js',
- '/gen/ui/gfx/mojom/transform.mojom.js',
- '/gen/ui/display/mojom/display.mojom.js',
- '/gen/device/gamepad/public/mojom/gamepad.mojom.js',
- '/gen/device/vr/public/mojom/vr_service.mojom.js',
- ];
+ await loadScript('/resources/chromium/webxr-test-math-helper.js');
+ await import('/resources/chromium/webxr-test.js');
+ await loadScript('/resources/testdriver.js');
+ await loadScript('/resources/testdriver-vendor.js');
- let extraResources = [
- '/resources/chromium/webxr-test-math-helper.js',
- '/resources/chromium/webxr-test.js',
- '/resources/testdriver.js',
- '/resources/testdriver-vendor.js',
- ];
// This infrastructure is also used by Chromium-specific internal tests that
// may need additional resources (e.g. internal API extensions), this allows
// those tests to rely on this infrastructure while ensuring that no tests
// make it into public WPTs that rely on APIs outside of the webxr test API.
if (typeof(additionalChromiumResources) !== 'undefined') {
- extraResources = extraResources.concat(additionalChromiumResources);
- }
-
- await loadMojoResources(chromiumResources);
- for (const path of extraResources) {
- await loadScript(path);
+ for (const path of additionalChromiumResources) {
+ await loadScript(path);
+ }
}
xr_debug = navigator.xr.test.Debug;
diff --git a/third_party/blink/web_tests/wpt_internal/webxr/resources/xr-internal-device-mocking.js b/third_party/blink/web_tests/wpt_internal/webxr/resources/xr-internal-device-mocking.js
index f79f9b65..342c43d 100644
--- a/third_party/blink/web_tests/wpt_internal/webxr/resources/xr-internal-device-mocking.js
+++ b/third_party/blink/web_tests/wpt_internal/webxr/resources/xr-internal-device-mocking.js
@@ -47,7 +47,7 @@
return this.mockVRService_;
};
-MockVRService.prototype.setFramesThrottled = function(throttled) {
+MockVRService.prototype.setFramesThrottledImpl = function(throttled) {
return this.frames_throttled_ = throttled;
};
diff --git a/third_party/blink/web_tests/wpt_internal/webxr/xrSession_environmentProviderDisconnect.https.html b/third_party/blink/web_tests/wpt_internal/webxr/xrSession_environmentProviderDisconnect.https.html
index 495149a0..e898d47 100644
--- a/third_party/blink/web_tests/wpt_internal/webxr/xrSession_environmentProviderDisconnect.https.html
+++ b/third_party/blink/web_tests/wpt_internal/webxr/xrSession_environmentProviderDisconnect.https.html
@@ -29,7 +29,7 @@
}
return Promise.resolve({
- result : device.mojom.SubscribeToHitTestResult.SUCCESS,
+ result : SubscribeToHitTestResult.SUCCESS,
subscriptionId : 1001
});
}