forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Region Capture #1] Add new produceCropId() API
This patch adds a new produceCropId() API to mediaDevices. This API is called with a DIV or IFRAME element, and adds a new base::UnguessableToken value to that element's rare data structure. This token value will be used in followup patches in order to keep track of an element's location in the page and viewport. Based on the following design document: https://docs.google.com/document/d/1dULARMnMZggfWqa_Ti_GrINRNYXGIli3XK9brzAKEV8/ Bug: 1247761 Change-Id: I01cd67e2d4e3dfa7a86289f876e48c8b55095d0a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3173396 Commit-Queue: Jordan Bayles <jophba@chromium.org> Reviewed-by: Elad Alon <eladalon@chromium.org> Reviewed-by: mark a. foltz <mfoltz@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#925544}
- Loading branch information
Showing
15 changed files
with
231 additions
and
1 deletion.
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
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
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
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
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
65 changes: 65 additions & 0 deletions
65
...y/blink/web_tests/external/wpt/mediacapture-streams/MediaDevices-produceCropId.https.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,65 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Test navigator.mediaDevices.produceCropId()</title> | ||
<meta name='assert' content='Test the produceCropId() method.'/> | ||
</head> | ||
|
||
<body> | ||
<h1 class="instructions">Description</h1> | ||
<p class="instructions">This test checks for the behavior of the | ||
<code>navigator.mediaDevices.produceCropId()</code> method.</p> | ||
|
||
<div id='test-div'></div> | ||
<iframe id='test-iframe' src="about:blank" /> | ||
<a id='test-a'></a> | ||
<div id='log'></div> | ||
|
||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
// Regex that matches a string only if it is exactly 32 valid hex characters. | ||
const HEX_REGEX = /^[0-9A-Fa-f]{32}$/g; | ||
test(() => { | ||
const div_id = document.getElementById('test-div').produceCropId(); | ||
assert_true(HEX_REGEX.test(div_id)); | ||
}, "produces valid id for div"); | ||
|
||
test(() => { | ||
const iframe_id = document.getElementById('test-iframe').produceCropId(); | ||
assert_true(HEX_REGEX.test(iframe_id)); | ||
}, "produces valid id for iframe"); | ||
|
||
test(() => { | ||
const iframe_id = document.getElementById('test-iframe').produceCropId(); | ||
const second_iframe_id = document.getElementById('test-iframe').produceCropId(); | ||
assert_equals(iframe_id, second_iframe_id); | ||
}, "repeated calls return the same value"); | ||
|
||
test(() => { | ||
assert_throws_js(TypeError, function() { | ||
await document.getElementById('test-a').produceCropId(); | ||
}); | ||
}, "invalid element types cause an error"); | ||
|
||
test(() => { | ||
const div_id = document.getElementById('test-div').produceCropId(); | ||
const iframe_id = document.getElementById('test-iframe').produceCropId(); | ||
assert_not_equals(div_id, iframe_id); | ||
}, "two elements have different IDs"); | ||
|
||
test(() => { | ||
const div = document.getElementById('test-div'); | ||
const div_id = div.produceCropId(); | ||
const clone = div.cloneNode(true); | ||
document.querySelector('body').appendChild(clone); | ||
const clone_id = clone.produceCropId(); | ||
assert_not_equals(div_id, clone_id); | ||
}, "cloned elements have different IDs"); | ||
|
||
</script> | ||
</body> | ||
</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
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