js/xpconnect/tests/chrome/test_bug860494.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <?xml version="1.0"?>
     2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
     4 <!--
     5 https://bugzilla.mozilla.org/show_bug.cgi?id=860494
     6 -->
     7 <window title="Mozilla Bug 860494"
     8         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     9   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    11   <!-- test results are displayed in the html:body -->
    12   <body xmlns="http://www.w3.org/1999/xhtml">
    13   <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=860494"
    14      target="_blank">Mozilla Bug 860494</a>
    15   </body>
    17   <!-- test code goes here -->
    18   <script type="application/javascript">
    19   <![CDATA[
    20   /** Test for Bug 860494 **/
    21   SimpleTest.waitForExplicitFinish();
    22   const Cu = Components.utils;
    24   function go() {
    25     var iwin = $('ifr').contentWindow;
    26     // NB: mochitest-chrome actually runs the test as a content docshell.
    27     is(iwin.top, window.top, "iframe names shouldn't shadow |top| via Xray");
    28     is(iwin.parent, window, "iframe names shouldn't shadow |parent| via Xray");
    29     ok(!!/http/.exec(iwin.location), "iframe names shouldn't shadow |location| via Xray");
    30     is(iwin.length, 7, "iframe names shouldn't shadow |length| via Xray");
    31     is(iwin.window, iwin, "iframe names shouldn't shadow |window| via Xray");
    32     is(iwin.navigator, XPCNativeWrapper(iwin.wrappedJSObject.navigator),
    33        "iframe names shouldn't shadow |navigator| via Xray");
    34     ok(iwin.alert instanceof Function,
    35        "iframe names shouldn't shadow |alert| via Xray");
    37     // Now test XOWs.
    38     var sb = new Cu.Sandbox('http://www.example.com');
    39     sb.win = iwin;
    40     sb.topWin = top;
    41     sb.parentWin = window;
    42     sb.is = is;
    43     sb.ok = ok;
    44     Cu.evalInSandbox('is(win.top, topWin, "iframe names shouldnt shadow |top| via cross-origin Xray");', sb);
    45     Cu.evalInSandbox('is(win.parent, parentWin, "iframe names shouldnt shadow |parent| via cross-origin Xray");', sb);
    46     Cu.evalInSandbox('is(win.length, 7, "iframe names shouldnt shadow |length| via cross-origin Xray");', sb);
    47     Cu.evalInSandbox('is(win.window, win, "iframe names shouldnt shadow |window| via cross-origin Xray");', sb);
    48     Cu.evalInSandbox('var exn = "nothrow"; try { win.navigator; } catch (e) { exn = e; } ok(!!/denied/.exec(exn), "cross-origin Xray blocks subframes that shadow: navigator: " + exn);', sb);
    49     Cu.evalInSandbox('var exn = "nothrow"; try { win.alert; } catch (e) { exn = e; } ok(!!/denied/.exec(exn), "cross-origin Xray blocks subframes that shadow: alert: " + exn);', sb);
    51     SimpleTest.finish();
    52   }
    54   ]]>
    55   </script>
    56   <iframe id="ifr" type="content" onload="go();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_bug860494.html" />
    57 </window>

mercurial