Bug 1735858 [wpt PR 31247] - App history: make it mostly nonfunctional for opaque...
[gecko.git] / testing / web-platform / tests / mediacapture-streams / MediaDevices-produceCropId.https.html
blob682caad7e7de5e79bae3a5b8d2b0da1bdfbb498f
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test navigator.mediaDevices.produceCropId()</title>
5 <meta name='assert' content='Test the produceCropId() method.'/>
6 </head>
8 <body>
9 <h1 class="instructions">Description</h1>
10 <p class="instructions">This test checks for the behavior of the
11 <code>navigator.mediaDevices.produceCropId()</code> method.</p>
13 <div id='test-div'></div>
14 <iframe id='test-iframe' src="about:blank" />
15 <a id='test-a'></a>
16 <div id='log'></div>
18 <script src=/resources/testharness.js></script>
19 <script src=/resources/testharnessreport.js></script>
21 <script>
22 "use strict";
24 // Regex that matches a string only if it is exactly 32 valid hex characters.
25 const HEX_REGEX = /^[0-9A-Fa-f]{32}$/g;
26 test(() => {
27 const div_id = document.getElementById('test-div').produceCropId();
28 assert_true(HEX_REGEX.test(div_id));
29 }, "produces valid id for div");
31 test(() => {
32 const iframe_id = document.getElementById('test-iframe').produceCropId();
33 assert_true(HEX_REGEX.test(iframe_id));
34 }, "produces valid id for iframe");
36 test(() => {
37 const iframe_id = document.getElementById('test-iframe').produceCropId();
38 const second_iframe_id = document.getElementById('test-iframe').produceCropId();
39 assert_equals(iframe_id, second_iframe_id);
40 }, "repeated calls return the same value");
42 test(() => {
43 assert_throws_js(TypeError, function() {
44 await document.getElementById('test-a').produceCropId();
45 });
46 }, "invalid element types cause an error");
48 test(() => {
49 const div_id = document.getElementById('test-div').produceCropId();
50 const iframe_id = document.getElementById('test-iframe').produceCropId();
51 assert_not_equals(div_id, iframe_id);
52 }, "two elements have different IDs");
54 test(() => {
55 const div = document.getElementById('test-div');
56 const div_id = div.produceCropId();
57 const clone = div.cloneNode(true);
58 document.querySelector('body').appendChild(clone);
59 const clone_id = clone.produceCropId();
60 assert_not_equals(div_id, clone_id);
61 }, "cloned elements have different IDs");
63 </script>
64 </body>
65 </html>