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.

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

mercurial