summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/origin/inheritance/about-blank-iframe.html
blob: fabde327a1c49b00b9a3e0733471ff6da960c514 (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
27
28
<!doctype html>
<html>
  <head>
    <title>about:blank in child browsing context aliases security origin</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
  </head>
  <body>
    <script>
      test(() => {
        let iframe = document.createElement('iframe');
        document.body.appendChild(iframe);
        // Should not throw: srcdoc should always be same-origin.
        iframe.contentWindow.document.body.innerHTML = '<p>Hello world!</p>';

        // Explicitly set `domain` component of origin: any other same-origin
        // browsing contexts are now cross-origin unless they also explicitly
        // set document.domain to the same value.
        document.domain = document.domain;
        // Should not throw: the origin should be aliased, so setting
        // document.domain in one Document should affect both Documents.
        assert_equals(
            iframe.contentWindow.document.body.textContent,
            'Hello world!');
      });
    </script>
  </body>
</html>