-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
1 parent
f4f3076
commit 8efc577
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:[email protected]"> | ||
<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> |