summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/forms/the-input-element/resources/show-picker-child-iframe.html
blob: 07b72f02cb69f2cb3af049a4f9cb65128428e4a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html>
<title>Test showPicker() in an iframe</title>
<script type=module>
import inputTypes from "./../input-types.js";

const urlParams = new URLSearchParams(location.search);
const documentDomain = urlParams.get('documentDomain');
if (documentDomain) {
  document.domain = documentDomain;
}

let securityErrors = [];
for (const inputType of inputTypes) {
  const input = document.createElement("input");
  input.setAttribute("type", inputType);

  try {
    input.showPicker();
  } catch (error) {
    if (error instanceof DOMException && error.name == 'SecurityError') {
      securityErrors.push(inputType);
    }
  }
}
parent.postMessage(securityErrors.join(','), "*");
</script>