tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_shared_compartment2.html (1373B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1530608
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 1530608</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11  <script type="application/javascript">
     12 
     13  /** Test for Bug 1530608 */
     14  SimpleTest.waitForExplicitFinish();
     15 
     16  // We have the following origins:
     17  //
     18  // 1: this page:    mochi.test:8888
     19  // 2: iframe:       test1.mochi.test:8888
     20  // 3: inner iframe: mochi.test:8888
     21  //
     22  // Test that 1 and 2 are cross-compartment (because cross-origin), but 1 and 3
     23  // are same-compartment.
     24 
     25  function go(innerWin) {
     26    var Cu = SpecialPowers.Cu;
     27    var isSameCompartment = Cu.getJSTestingFunctions().isSameCompartment;
     28 
     29    var frame = document.getElementById("frame");
     30    ok(!isSameCompartment(window, frame.contentWindow),
     31       "Cross-origin iframe must be cross-compartment");
     32 
     33    ok(isSameCompartment(window, innerWin),
     34       "Same-origin inner iframe must be same-compartment");
     35 
     36    SimpleTest.finish();
     37  }
     38 
     39  </script>
     40 </head>
     41 <body>
     42 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1530608">Mozilla Bug 1530608</a>
     43 
     44 <iframe id="frame" src="http://test1.mochi.test:8888/tests/dom/base/test/iframe_shared_compartment2a.html"></iframe>
     45 
     46 </body>
     47 </html>