summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/origin/cross-origin-objects/cross-origin-due-to-document-domain-only.html
blob: 425374faec02a6ec5f8b64f7e3d109e0bc2e0da3 (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
29
30
31
32
33
<!doctype html>
<title>Cross-origin due to document.domain</title>
<meta charset=utf-8>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<iframe src=resources/cross-origin-due-to-document-domain-only-helper.html></iframe>
<script>
async_test(t => {
  onload = t.step_func_done(() => {
    const frame = document.querySelector("iframe");
    const innerSelf = self[0];
    const innerLocation = innerSelf.location;
    const innerDocument = innerSelf.document;
    assert_equals(innerLocation.host, location.host);
    assert_true(innerSelf.expandosForever);
    assert_true(innerLocation.expandosForever);
    assert_equals(frame.contentWindow, innerSelf);
    assert_equals(frame.contentDocument, innerDocument);
    innerSelf.setDocumentDomain();
    assert_throws_dom("SecurityError", () => innerSelf.expandosForever);
    assert_throws_dom("SecurityError", () => innerLocation.expandosForever);
    assert_throws_dom("SecurityError", () => innerLocation.host);
    assert_equals(innerSelf.parent, self);
    assert_throws_dom("SecurityError", () => innerSelf.frameElement);
    assert_throws_dom("SecurityError", () => innerLocation.reload());
    assert_equals(frame.contentWindow, innerSelf);
    assert_equals(frame.contentDocument, null);
    // Cross-origin Document object obtained before it became cross-origin has no protections
    assert_equals(innerDocument.URL, frame.src);
  });
});
</script>