tor-browser

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

test_window_cross_origin_props.html (3422B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=946067
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 946067</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 946067 */
     14  SimpleTest.waitForExplicitFinish();
     15 
     16  function doGet(prop, thisObj) {
     17    return Object.getOwnPropertyDescriptor(window, prop).get.call(thisObj);
     18  }
     19 
     20  function doSet(prop, thisObj, value) {
     21    return Object.getOwnPropertyDescriptor(window, prop).set.call(thisObj, value);
     22  }
     23 
     24  window.onload = function() {
     25    frames[0].focus();
     26    is(document.activeElement.id, "x", "Should have focused first subframe");
     27    frames[0].blur();
     28    window.focus.call(frames[1]);
     29    is(document.activeElement.id, "y", "Should have focused second subframe");
     30    window.blur.call(frames[1]);
     31 
     32    frames[0].close();
     33    is(frames[0].closed, false, "Subframe is not closed");
     34    window.close.call(frames[0]);
     35    is(doGet("closed", frames[0]), false, "Subframe is still not closed");
     36 
     37    is(frames[0].frames, frames[0], "window.frames === window");
     38    is(doGet("frames", frames[0]), frames[0],
     39       "Really, window.frames === window");
     40 
     41    try {
     42      frames[0].frames = 1;
     43      ok(false, "Should throw when setting .frames");
     44    } catch (e) {
     45      ok(true, "Should throw when setting .frames");
     46    }
     47    try {
     48      doSet("frames", frames[0], 1);
     49      ok(false, "Should still throw when setting .frames");
     50    } catch (e) {
     51      ok(true, "Should still throw when setting .frames");
     52    }
     53 
     54    // Just check whether we can get the location without throwing:
     55    is(frames[0].location, doGet("location", frames[0]),
     56       "Should be same Location object");
     57 
     58    is(frames[0].length, 0, "404 page has no subframes");
     59    is(doGet("length", frames[0]), 0, "404 page has no subframes");
     60 
     61    is(frames[0].opener, null, "subframe has no opener");
     62    is(doGet("opener", frames[0]), null, "subframe still has no opener");
     63 
     64    is(frames[0].parent, window, "subframe has us as parent");
     65    is(doGet("parent", frames[0]), window, "subframe still has us as parent");
     66 
     67    // Check that postMessage doesn't throw
     68    frames[0].postMessage(null, "*");
     69 
     70    is(frames[0].self, frames[0], "self should work");
     71    is(doGet("self", frames[0]), frames[0], "self should still work");
     72 
     73    is(frames[0].top, window.top, "Our subframe's top should be our top");
     74    is(doGet("top", frames[0]), window.top,
     75       "Our subframe's top should still be our top");
     76 
     77    is(frames[0].window, frames[0], "window getter should work");
     78    is(doGet("window", frames[0]), frames[0], "window getter should still work");
     79    isnot(Object.getOwnPropertyDescriptor(window, "window").get, undefined,
     80          "Should have a getter here");
     81 
     82    // Finally, check that we can set the location
     83    frames[0].location = "about:blank";
     84    doSet("location", frames[1], "about:blank");
     85 
     86    SimpleTest.finish();
     87  }
     88  </script>
     89 </head>
     90 <body>
     91 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=946067">Mozilla Bug 946067</a>
     92 <p id="display"></p>
     93 <div id="content" style="display: none">
     94 
     95 </div>
     96 <pre id="test">
     97  <iframe id="x" src="http://www.example.com/nosuchpageIhope"></iframe>
     98  <iframe id="y" src="http://www.example.com/nosuchpageIhope"></iframe>
     99 </pre>
    100 </body>
    101 </html>