js/xpconnect/tests/chrome/test_bug860494.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial