Skip to content

Commit

Permalink
Bug 1730572 [wpt PR 30696] - [EyeDropper API] Add optional AbortSigna…
Browse files Browse the repository at this point in the history
…l parameter to EyeDropper.open, a=testonly

Automatic update from web-platform-tests
[EyeDropper API] Add optional AbortSignal parameter to EyeDropper.open

Per TAG review[1], this CL adds an optional AbortSignal parameter to
EyeDropper.open to allow authors to dismiss the eyedropper with no
selection in case another high-priority event occurs.

[1]: w3ctag/design-reviews#587 (comment)

Bug: 1248286
Change-Id: I15580609ece85f947f019a724b23b5e4898e42f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761
Commit-Queue: Ionel Popescu <iopopesc@microsoft.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#920997}

--

wpt-commits: a1d99ba695a939e001be1d57c9d758bd5e5ce431
wpt-pr: 30696
  • Loading branch information
ipopescu93 authored and moz-wptsync-bot committed Sep 27, 2021
1 parent ea3e800 commit 93e0704
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<title>EyeDropper Test: abort signal</title>
<link rel="author" title="Ionel Popescu" href="mailto:iopopesc@microsoft.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<button id="eyedropperbutton">Open eyedropper!</button>

<script>
function clickOn(element) {
const actions = new test_driver.Actions();
return actions.pointerMove(0, 0, {origin: element})
.pointerDown({button: actions.ButtonType.LEFT})
.pointerUp({button: actions.ButtonType.LEFT})
.send();
}

promise_test(async t => {
const eyeDropperButton = document.getElementById("eyedropperbutton");
eyeDropperButton.addEventListener("click", async () => {
let eyeDropper = new EyeDropper();
let controller = new AbortController();
controller.abort();
await promise_rejects_dom(t, "AbortError", eyeDropper.open({signal: controller.signal}));
});
await clickOn(eyeDropperButton);
}, "Calling EyeDropper.open with signal's aborted flag set should directly throw AbortError");

promise_test(async t => {
const eyeDropperButton = document.getElementById("eyedropperbutton");
eyeDropperButton.addEventListener("click", () => {
let eyeDropper = new EyeDropper();
let controller = new AbortController();
this.step_timeout(() => {
controller.abort();
}, 500);
promise_rejects_dom(t, "AbortError", eyeDropper.open({signal: controller.signal}));
});
await clickOn(eyeDropperButton);
}, "Calling abort should dismiss the eyedropper");

</script>

0 comments on commit 93e0704

Please sign in to comment.