dom/base/test/test_window_cross_origin_props.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11   <script type="application/javascript">
    13   /** Test for Bug 946067 **/
    14   SimpleTest.waitForExplicitFinish();
    16   function doGet(prop, thisObj) {
    17     return Object.getOwnPropertyDescriptor(window, prop).get.call(thisObj);
    18   }
    20   function doSet(prop, thisObj, value) {
    21     return Object.getOwnPropertyDescriptor(window, prop).set.call(thisObj, value);
    22   }
    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]);
    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");
    37     is(frames[0].frames, frames[0], "window.frames === window");
    38     is(doGet("frames", frames[0]), frames[0],
    39        "Really, window.frames === window");
    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     }
    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");
    58     is(frames[0].length, 0, "404 page has no subframes");
    59     is(doGet("length", frames[0]), 0, "404 page has no subframes");
    61     is(frames[0].opener, null, "subframe has no opener");
    62     is(doGet("opener", frames[0]), null, "subframe still has no opener");
    64     is(frames[0].parent, window, "subframe has us as parent");
    65     is(doGet("parent", frames[0]), window, "subframe still has us as parent");
    67     // Check that postMessage doesn't throw
    68     frames[0].postMessage(null, "*");
    70     is(frames[0].self, frames[0], "self should work");
    71     is(doGet("self", frames[0]), frames[0], "self should still work");
    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");
    77     is(frames[0].window, frames[0], "window getter should work");
    78     // "window" is not a getter property yet
    79     //is(doGet("window", frames[0]), frames[0], "window getter should still work");
    80     todo_isnot(Object.getOwnPropertyDescriptor(window, "window").get, undefined,
    81               "Should have a getter here");
    83     // Finally, check that we can set the location
    84     frames[0].location = "about:blank";
    85     doSet("location", frames[1], "about:blank");
    87     SimpleTest.finish();
    88   }
    89   </script>
    90 </head>
    91 <body>
    92 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=946067">Mozilla Bug 946067</a>
    93 <p id="display"></p>
    94 <div id="content" style="display: none">
    96 </div>
    97 <pre id="test">
    98   <iframe id="x" src="http://www.example.com/nosuchpageIhope"></iframe>
    99   <iframe id="y" src="http://www.example.com/nosuchpageIhope"></iframe>
   100 </pre>
   101 </body>
   102 </html>

mercurial