4 <title>Test navigator.mediaDevices.produceCropId()
</title>
5 <meta name='assert' content='Test the produceCropId() method.'
/>
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" />
18 <script src=/resources/testharness.js
></script>
19 <script src=/resources/testharnessreport.js
></script>
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;
27 const div_id
= document
.getElementById('test-div').produceCropId();
28 assert_true(HEX_REGEX
.test(div_id
));
29 }, "produces valid id for div");
32 const iframe_id
= document
.getElementById('test-iframe').produceCropId();
33 assert_true(HEX_REGEX
.test(iframe_id
));
34 }, "produces valid id for iframe");
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");
43 assert_throws_js(TypeError
, function() {
44 await document
.getElementById('test-a').produceCropId();
46 }, "invalid element types cause an error");
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");
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");