dom/base/test/test_window_cross_origin_props.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/base/test/test_window_cross_origin_props.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,102 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=946067
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 946067</title>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +  <script type="application/javascript">
    1.15 +
    1.16 +  /** Test for Bug 946067 **/
    1.17 +  SimpleTest.waitForExplicitFinish();
    1.18 +
    1.19 +  function doGet(prop, thisObj) {
    1.20 +    return Object.getOwnPropertyDescriptor(window, prop).get.call(thisObj);
    1.21 +  }
    1.22 +
    1.23 +  function doSet(prop, thisObj, value) {
    1.24 +    return Object.getOwnPropertyDescriptor(window, prop).set.call(thisObj, value);
    1.25 +  }
    1.26 +
    1.27 +  window.onload = function() {
    1.28 +    frames[0].focus();
    1.29 +    is(document.activeElement.id, "x", "Should have focused first subframe");
    1.30 +    frames[0].blur();
    1.31 +    window.focus.call(frames[1]);
    1.32 +    is(document.activeElement.id, "y", "Should have focused second subframe");
    1.33 +    window.blur.call(frames[1]);
    1.34 +
    1.35 +    frames[0].close();
    1.36 +    is(frames[0].closed, false, "Subframe is not closed");
    1.37 +    window.close.call(frames[0]);
    1.38 +    is(doGet("closed", frames[0]), false, "Subframe is still not closed");
    1.39 +
    1.40 +    is(frames[0].frames, frames[0], "window.frames === window");
    1.41 +    is(doGet("frames", frames[0]), frames[0],
    1.42 +       "Really, window.frames === window");
    1.43 +
    1.44 +    try {
    1.45 +      frames[0].frames = 1;
    1.46 +      ok(false, "Should throw when setting .frames");
    1.47 +    } catch (e) {
    1.48 +      ok(true, "Should throw when setting .frames");
    1.49 +    }
    1.50 +    try {
    1.51 +      doSet("frames", frames[0], 1);
    1.52 +      ok(false, "Should still throw when setting .frames");
    1.53 +    } catch (e) {
    1.54 +      ok(true, "Should still throw when setting .frames");
    1.55 +    }
    1.56 +
    1.57 +    // Just check whether we can get the location without throwing:
    1.58 +    is(frames[0].location, doGet("location", frames[0]),
    1.59 +       "Should be same Location object");
    1.60 +
    1.61 +    is(frames[0].length, 0, "404 page has no subframes");
    1.62 +    is(doGet("length", frames[0]), 0, "404 page has no subframes");
    1.63 +
    1.64 +    is(frames[0].opener, null, "subframe has no opener");
    1.65 +    is(doGet("opener", frames[0]), null, "subframe still has no opener");
    1.66 +
    1.67 +    is(frames[0].parent, window, "subframe has us as parent");
    1.68 +    is(doGet("parent", frames[0]), window, "subframe still has us as parent");
    1.69 +
    1.70 +    // Check that postMessage doesn't throw
    1.71 +    frames[0].postMessage(null, "*");
    1.72 +
    1.73 +    is(frames[0].self, frames[0], "self should work");
    1.74 +    is(doGet("self", frames[0]), frames[0], "self should still work");
    1.75 +
    1.76 +    is(frames[0].top, window.top, "Our subframe's top should be our top");
    1.77 +    is(doGet("top", frames[0]), window.top,
    1.78 +       "Our subframe's top should still be our top");
    1.79 +
    1.80 +    is(frames[0].window, frames[0], "window getter should work");
    1.81 +    // "window" is not a getter property yet
    1.82 +    //is(doGet("window", frames[0]), frames[0], "window getter should still work");
    1.83 +    todo_isnot(Object.getOwnPropertyDescriptor(window, "window").get, undefined,
    1.84 +              "Should have a getter here");
    1.85 +
    1.86 +    // Finally, check that we can set the location
    1.87 +    frames[0].location = "about:blank";
    1.88 +    doSet("location", frames[1], "about:blank");
    1.89 +
    1.90 +    SimpleTest.finish();
    1.91 +  }
    1.92 +  </script>
    1.93 +</head>
    1.94 +<body>
    1.95 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=946067">Mozilla Bug 946067</a>
    1.96 +<p id="display"></p>
    1.97 +<div id="content" style="display: none">
    1.98 +
    1.99 +</div>
   1.100 +<pre id="test">
   1.101 +  <iframe id="x" src="http://www.example.com/nosuchpageIhope"></iframe>
   1.102 +  <iframe id="y" src="http://www.example.com/nosuchpageIhope"></iframe>
   1.103 +</pre>
   1.104 +</body>
   1.105 +</html>

mercurial