Commit 03ef65db authored by Ovidio Henriquez's avatar Ovidio Henriquez Committed by Commit Bot

Update existing WebUSB WPT to be multi-global

This change updates the remaining WebUSB web platform tests to be
multi-global so that the API is also tested in the worker contexts.

Bug: 841510
Change-Id: I9df24f1ae4289ab742db275c34552200bb477b22
Reviewed-on: https://chromium-review.googlesource.com/1089033
Commit-Queue: Ovidio Henriquez <odejesush@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565778}
parent 955535cb
<!DOCTYPE html> // META: script=/webusb/resources/fake-devices.js
<script src="/resources/testharness.js"></script> // META: script=/webusb/resources/usb-helpers.js
<script src="/resources/testharnessreport.js"></script> // META: global=sharedworker
<script src="resources/fake-devices.js"></script>
<script src="resources/usb-helpers.js"></script>
<script>
'use strict'; 'use strict';
function assertRejectsWithNotFoundError(promise) { function assertRejectsWithNotFoundError(promise) {
...@@ -12,7 +9,7 @@ function assertRejectsWithNotFoundError(promise) { ...@@ -12,7 +9,7 @@ function assertRejectsWithNotFoundError(promise) {
function assertRejectsWithNotOpenError(promise) { function assertRejectsWithNotOpenError(promise) {
return assertRejectsWithError( return assertRejectsWithError(
promise, 'InvalidStateError', 'The device must be opened first.') promise, 'InvalidStateError', 'The device must be opened first.');
} }
function assertRejectsWithNotConfiguredError(promise) { function assertRejectsWithNotConfiguredError(promise) {
...@@ -340,7 +337,7 @@ usb_test(() => { ...@@ -340,7 +337,7 @@ usb_test(() => {
assert_equals(result.status, 'ok'); assert_equals(result.status, 'ok');
assert_equals(result.bytesWritten, 8); assert_equals(result.bytesWritten, 8);
return device.close(); return device.close();
}) });
}); });
}, 'can issue OUT control transfer'); }, 'can issue OUT control transfer');
...@@ -651,4 +648,3 @@ usb_test(() => { ...@@ -651,4 +648,3 @@ usb_test(() => {
.then(() => assertRejectsWithNotFoundError(device.reset())); .then(() => assertRejectsWithNotFoundError(device.reset()));
}); });
}, 'resetDevice rejects when called on a disconnected device'); }, 'resetDevice rejects when called on a disconnected device');
</script>
<!DOCTYPE html> // META: script=/webusb/resources/fake-devices.js
<script src="/resources/testharness.js"></script> // META: script=/webusb/resources/usb-helpers.js
<script src="/resources/testharnessreport.js"></script> // META: global=sharedworker
<script>
'use strict'; 'use strict';
test(t => { test(t => {
...@@ -28,4 +27,3 @@ test(t => { ...@@ -28,4 +27,3 @@ test(t => {
test(t => { test(t => {
assert_throws(TypeError(), () => new USBInTransferResult()); assert_throws(TypeError(), () => new USBInTransferResult());
}, 'Cannot construct USBInTransferResult without a status'); }, 'Cannot construct USBInTransferResult without a status');
</script>
<!DOCTYPE html> // META: global=sharedworker
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict'; 'use strict';
test(t => { test(t => {
...@@ -30,4 +27,3 @@ test(t => { ...@@ -30,4 +27,3 @@ test(t => {
test(t => { test(t => {
assert_throws(TypeError(), () => new USBIsochronousInTransferPacket()); assert_throws(TypeError(), () => new USBIsochronousInTransferPacket());
}, 'Cannot construct USBIsochronousInTransferPacket without a status'); }, 'Cannot construct USBIsochronousInTransferPacket without a status');
</script>
<!DOCTYPE html> // META: global=sharedworker
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict'; 'use strict';
test(t => { test(t => {
...@@ -38,4 +35,3 @@ test(t => { ...@@ -38,4 +35,3 @@ test(t => {
test(t => { test(t => {
assert_throws(TypeError(), () => new USBIsochronousInTransferResult()); assert_throws(TypeError(), () => new USBIsochronousInTransferResult());
}, 'Cannot construct a USBIsochronousInTransferResult without packets'); }, 'Cannot construct a USBIsochronousInTransferResult without packets');
</script>
<!DOCTYPE html> // META: global=sharedworker
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict'; 'use strict';
test(t => { test(t => {
...@@ -23,4 +20,3 @@ test(t => { ...@@ -23,4 +20,3 @@ test(t => {
test(t => { test(t => {
assert_throws(TypeError(), () => new USBIsochronousOutTransferPacket()); assert_throws(TypeError(), () => new USBIsochronousOutTransferPacket());
}, 'Cannot construct USBIsochronousOutTransferPacket without a status'); }, 'Cannot construct USBIsochronousOutTransferPacket without a status');
</script>
<!DOCTYPE html> // META: global=sharedworker
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict'; 'use strict';
test(t => { test(t => {
...@@ -21,4 +18,3 @@ test(t => { ...@@ -21,4 +18,3 @@ test(t => {
test(t => { test(t => {
assert_throws(TypeError(), () => new USBIsochronousOutTransferResult()); assert_throws(TypeError(), () => new USBIsochronousOutTransferResult());
}, 'Cannot construct a USBIsochronousOutTransferResult without packets'); }, 'Cannot construct a USBIsochronousOutTransferResult without packets');
</script>
<!DOCTYPE html> // META: global=sharedworker
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict'; 'use strict';
test(t => { test(t => {
...@@ -21,4 +18,3 @@ test(t => { ...@@ -21,4 +18,3 @@ test(t => {
test(t => { test(t => {
assert_throws(TypeError(), () => new USBOutTransferResult()); assert_throws(TypeError(), () => new USBOutTransferResult());
}, 'Cannot construct USBOutTransferResult without a status'); }, 'Cannot construct USBOutTransferResult without a status');
</script>
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