File: frame.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 (51 lines) | stat: -rw-r--r-- 1,714 bytes parent folder | download | duplicates (26)
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
<!doctype html>
<html>
<head>
<script>
  if (location.search == "?setdomain") {
    document.domain = document.domain;
  }

  // Override the |frames| and |focus| property to test that such overrides are
  // properly ignored cross-origin.
  window.frames = "override";
  window.focus = "override";

  // Also add a |then| property to test that it doesn't get exposed.
  window.then = "something";
  window.location.then = "something-else";

  // If we get a postMessage, we grab references to everything and set
  // document.domain to trim off our topmost subdomain.
  window.onmessage = function(evt) {
    window.windowReferences = [];
    window.locationReferences = [];
    for (var i = 0; i < parent.length; ++i) {
      windowReferences.push(parent[i]);
      locationReferences.push(parent[i].location);
    }
    try {
      document.domain = document.domain.substring(document.domain.indexOf('.') + 1);
      evt.source.postMessage('PASS', '*');
    } catch (e) {
      evt.source.postMessage('FAIL: cannot trim off document.domain: ' + e, '*');
    }
  }

  function checkWindowReferences() {
    for (var i = 0; i < parent.length; ++i) {
      if (windowReferences[i] != parent[i])
        throw new Error("Window references don't match for " + i + " after document.domain");
      if (locationReferences[i] != parent[i].location)
        throw new Error("Location references don't match for " + i + " after document.domain");
    }
    return true;
  }
</script>
</head>
<body>
  <!-- Two subframes to give us some indexed properties -->
  <iframe></iframe>
  <iframe name=donotleakme></iframe><!-- "donotleakme" is excluded as cross-origin named property due to [[HideFromKeys]] -->
</body>
</html>