-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix MediaDevices-produceCropId WPT test
This patch fixes the currently broken produceCropId test. Due to an issue with the test harness parsing an iframe, this test set is not picked up and ran. The produceCropId API has also been finalized and removed from the Element API, so some additional changes to fix the actual tests as well. Bug: 1314679 Change-Id: Ic967c6b2c2651ac9391078897219ed337a033513 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3596403 Reviewed-by: Elad Alon <eladalon@chromium.org> Commit-Queue: Jordan Bayles <jophba@chromium.org> Cr-Commit-Position: refs/heads/main@{#1001701}
- Loading branch information
Showing
1 changed file
with
66 additions
and
48 deletions.
There are no files selected for viewing
114 changes: 66 additions & 48 deletions
114
...ty/blink/web_tests/external/wpt/mediacapture-region/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 |
---|---|---|
@@ -1,65 +1,83 @@ | ||
<!doctype html> | ||
<html> | ||
|
||
<head> | ||
<title>Test navigator.mediaDevices.produceCropId()</title> | ||
<meta name='assert' content='Test the produceCropId() method.'/> | ||
<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> | ||
<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"></iframe> | ||
<a id='test-a'></a> | ||
<div id='log'></div> | ||
|
||
<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 src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<script> | ||
"use strict"; | ||
|
||
<script> | ||
"use strict"; | ||
// Regex that matches a Universally Unique IDentifer composed of hex | ||
// characters separated by dashes in the form 8-4-4-4-12 for a total | ||
// of 36 characters. | ||
const GUID_REGEX = /^[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$/; | ||
|
||
// 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"); | ||
promise_test(async () => { | ||
assert_true(!!navigator.mediaDevices.produceCropId); | ||
const iframe_id = await navigator.mediaDevices.produceCropId( | ||
document.getElementById('test-iframe')); | ||
assert_true(GUID_REGEX.test(iframe_id)); | ||
}, "produces valid IDs for iframe"); | ||
|
||
test(() => { | ||
const iframe_id = document.getElementById('test-iframe').produceCropId(); | ||
assert_true(HEX_REGEX.test(iframe_id)); | ||
}, "produces valid id for iframe"); | ||
promise_test(async () => { | ||
assert_true(!!navigator.mediaDevices.produceCropId); | ||
const div_id = await navigator.mediaDevices.produceCropId( | ||
document.getElementById('test-div')); | ||
assert_true(GUID_REGEX.test(div_id)); | ||
}, "produces valid id for div"); | ||
|
||
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"); | ||
promise_test(async () => { | ||
const iframe_id = await navigator.mediaDevices.produceCropId( | ||
document.getElementById('test-iframe')); | ||
const second_iframe_id = await navigator.mediaDevices.produceCropId( | ||
document.getElementById('test-iframe')); | ||
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"); | ||
promise_test(t => { | ||
return promise_rejects_js(t, TypeError, | ||
navigator.mediaDevices.produceCropId(123)); | ||
}, "rejects an invalid element with a TypeError"); | ||
|
||
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"); | ||
promise_test(function (t) { | ||
return promise_rejects_js(t, TypeError, | ||
navigator.mediaDevices.produceCropId(document.getElementById("test-a"))); | ||
}, "rejects an incorrectly typed element with a TypeError"); | ||
|
||
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"); | ||
promise_test(async () => { | ||
const div_id = await navigator.mediaDevices.produceCropId( | ||
document.getElementById('test-div')); | ||
const iframe_id = await navigator.mediaDevices.produceCropId( | ||
document.getElementById('test-iframe')); | ||
assert_not_equals(div_id, iframe_id); | ||
}, "two elements have different IDs"); | ||
|
||
</script> | ||
promise_test(async () => { | ||
const div = document.getElementById('test-div'); | ||
const div_id = await navigator.mediaDevices.produceCropId(div); | ||
const clone = div.cloneNode(true); | ||
document.querySelector('body').appendChild(clone); | ||
const clone_id = await navigator.mediaDevices.produceCropId(clone); | ||
assert_not_equals(div_id, clone_id); | ||
}, "cloned elements have different IDs"); | ||
|
||
</script> | ||
</body> | ||
</html> | ||
|
||
</html> |