js/xpconnect/tests/chrome/test_bug773962.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=773962
michael@0 6 -->
michael@0 7 <window title="Mozilla Bug 773962"
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=773962"
michael@0 14 target="_blank">Mozilla Bug 773962</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
michael@0 21 /** Test for remapping Xray waivers during brain transplant. **/
michael@0 22 SimpleTest.waitForExplicitFinish();
michael@0 23 const Cu = Components.utils;
michael@0 24
michael@0 25 var gFramesLoaded = 0;
michael@0 26 function frameLoaded() {
michael@0 27 ++gFramesLoaded;
michael@0 28 if (gFramesLoaded == 2)
michael@0 29 startTest();
michael@0 30 if (gFramesLoaded == 3)
michael@0 31 finishTest();
michael@0 32 }
michael@0 33
michael@0 34 function startTest() {
michael@0 35 // grab the windows and the node.
michael@0 36 win1 = document.getElementById('frame1').contentWindow;
michael@0 37 win2 = document.getElementById('frame2').contentWindow;
michael@0 38 node1 = win1.document.getElementById('text');
michael@0 39 loc1 = win1.location;
michael@0 40
michael@0 41 // Grab some Xray waivers.
michael@0 42 win1Waiver = win1.wrappedJSObject;
michael@0 43 node1Waiver = node1.wrappedJSObject;
michael@0 44 loc1Waiver = win1Waiver.location;
michael@0 45
michael@0 46 // Adopt node1 into win2. This causes node1 to be transplanted.
michael@0 47 win2.document.adoptNode(node1);
michael@0 48
michael@0 49 // Navigate win1. This causes win1 to be transplanted.
michael@0 50 win1.location = 'http://test2.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html';
michael@0 51
michael@0 52 // The above happens async. Our onload handler will call finishTest() when we're ready.
michael@0 53 }
michael@0 54
michael@0 55 function finishTest() {
michael@0 56 // Now, recompute some wrappers.
michael@0 57 Cu.recomputeWrappers();
michael@0 58
michael@0 59 // First, pat ourselves on the back for not asserting/crashing. That's most of
michael@0 60 // what we're really testing here.
michael@0 61 ok(true, "Didnt crash!");
michael@0 62
michael@0 63 // Now, make sure everything is set up how we expect.
michael@0 64 ok(win1Waiver === win1.wrappedJSObject, "waivers still work");
michael@0 65 ok(XPCNativeWrapper(win1Waiver) === win1, "waivers still work");
michael@0 66 ok(node1Waiver === node1.wrappedJSObject, "waivers still work");
michael@0 67 ok(XPCNativeWrapper(node1Waiver) === node1, "waivers still work");
michael@0 68
michael@0 69 // The semantics of location are tricky, because win1 now has a new location object.
michael@0 70 // In fact, loc1 should be a dead object proxy. Let's make sure we get this right.
michael@0 71 ok(loc1 !== win1.location, "navigation means different window.location");
michael@0 72 ok(loc1Waiver !== win1.location.wrappedJSObject, "navigation means different window.location");
michael@0 73
michael@0 74 // Whew.
michael@0 75 SimpleTest.finish();
michael@0 76 }
michael@0 77
michael@0 78 ]]>
michael@0 79 </script>
michael@0 80 <iframe id="frame1" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
michael@0 81 <iframe id="frame2" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
michael@0 82 </window>

mercurial