File: self-origin.sub.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (93 lines) | stat: -rw-r--r-- 3,976 bytes parent folder | download | duplicates (33)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE HTML>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<iframe></iframe>
<iframe id="blob-test"></iframe> <!-- will get blob: URI -->
<iframe src="javascript:'javascript'"></iframe>
<iframe srcdoc="srcdoc"></iframe>
<!-- Use the non-default HTTP port so we can make sure it gets included in
     self.origin -->
<iframe src="http://{{domains[www1]}}:{{ports[http][1]}}{{location[path]}}/../resources/self-origin-subframe.html"></iframe>
<!-- Using the Unicode version on purpose, we expect to get back the Punycode
     version in self.origin -->
<iframe src="http://élève.{{domains[]}}:{{ports[http][1]}}{{location[path]}}/../resources/self-origin-subframe.html"></iframe>
<iframe src="resources/self-origin-subframe.html" sandbox="allow-scripts"></iframe>
<script type="application/javascript">
test(function() {
  var blob = new Blob(['blob']);
  var url = URL.createObjectURL(blob);
  document.getElementById("blob-test").src = url;
}, "Assigning blob url");

/* Each message test is a four things: window to send message to, message to
   send, expected response, async test to use. */
var messageTests = [
  [ frames[4], "getOrigin", "http://{{domains[www1]}}:{{ports[http][1]}}",
    async_test("Should have the right origin for cross-origin subframe") ],
  [ frames[4], "setDomainAndGetOrigin", "http://{{domains[www1]}}:{{ports[http][1]}}",
    async_test("Should have the right origin for cross-origin subframe after setting document.domain") ],
  [ frames[5], "getOrigin", "http://xn--lve-6lad.{{domains[]}}:{{ports[http][1]}}",
    async_test("Should have the right origin for IDN subframe") ],
  [ frames[5], "setDomainAndGetOrigin", "http://xn--lve-6lad.{{domains[]}}:{{ports[http][1]}}",
    async_test("Should have the right origin for IDN subframe after setting document.domain") ],
  [ frames[6], "getOrigin", "null",
    async_test("Should have the right origin for sandboxed iframe") ],
];

var curTest = 0;
function nextMessageTest() {
  if (curTest == messageTests.length) {
    return;
  }

  var testData = messageTests[curTest];
  testData[0].postMessage(testData[1], "*");
}

window.onmessage = function(e) {
  var testData = messageTests[curTest++];
  testData[3].step(function() {
    assert_equals(e.data, testData[2])
  });
  testData[3].done();
  nextMessageTest();
}

addEventListener("load", nextMessageTest);

test(function() {
  assert_equals(self.origin, "http://{{location[host]}}");
}, "We should have the right origin for our page");

var t1 = async_test("about:blank subframe origins");
addEventListener("load", t1.step_func_done(function() {
  assert_equals(frames[0].location.origin, "null",
                "Should have the right location origin for about:blank iframe");
  assert_equals(frames[0].origin, "http://{{location[host]}}",
                "Should have the right origin for about:blank iframe");
}));

var t2 = async_test("blob: subframe origins");
addEventListener("load", t2.step_func_done(function() {
  assert_equals(frames[1].location.origin, "http://{{location[host]}}",
                "Should have the right location origin for blob: iframe");
  assert_equals(frames[1].origin, "http://{{location[host]}}",
                "Should have the right origin for blob: iframe");
}));

var t3 = async_test("javascript: subframe origins");
addEventListener("load", t3.step_func_done(function() {
  assert_equals(frames[2].origin, "http://{{location[host]}}",
                "Should have the right origin for javascript: iframe");
}));

var t4 = async_test("srcdoc subframe origins");
addEventListener("load", t4.step_func_done(function() {
  assert_equals(frames[3].location.origin, "null",
                "Should have the right location origin for srcdoc iframe");
  assert_equals(frames[3].origin, "http://{{location[host]}}",
                "Should have the right origin for srcdoc iframe");
}));
</script>