forked from chromium/chromium
-
-
Notifications
You must be signed in to change notification settings - Fork 17
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 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3152761 Commit-Queue: Ionel Popescu <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#920997}
- Loading branch information
1 parent
f80ddc8
commit 024aec1
Showing
7 changed files
with
97 additions
and
7 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
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
9 changes: 9 additions & 0 deletions
9
third_party/blink/renderer/modules/eyedropper/color_selection_options.idl
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,9 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// https://wicg.github.io/eyedropper-api/#colorselectionoptions-dictionary | ||
|
||
dictionary ColorSelectionOptions { | ||
AbortSignal signal; | ||
}; |
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
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
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
45 changes: 45 additions & 0 deletions
45
third_party/blink/web_tests/external/wpt/eyedropper/eye-dropper-abort-signal.tentative.html
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> |