js/xpconnect/tests/chrome/test_bug932906.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=932906
     6 -->
     7 <window title="Mozilla Bug 932906"
     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=932906"
    14      target="_blank">Mozilla Bug 932906</a>
    15   </body>
    17   <!-- test code goes here -->
    18   <script type="application/javascript">
    19   <![CDATA[
    20   const Cu = Components.utils;
    21   Cu.import('resource://gre/modules/Services.jsm');
    23   /** Test for Bug 932906 **/
    24   SimpleTest.waitForExplicitFinish();
    26   function passToContent(shouldThrow) {
    27     try {
    28       $('ifr').contentWindow.obs = Services.obs;
    29       ok(!shouldThrow, "Didn't throw when passing non-DOM XPCWN to content");
    30     } catch (e) {
    31       ok(shouldThrow, "Threw when passing non-DOM XPCWN to content");
    32       ok(/denied/.test(e), "Threw correct exception: " + e);
    33     }
    34   }
    36   var gLoadCount = 0;
    37   function loaded() {
    38     ++gLoadCount;
    39     if (gLoadCount == 1)
    40       part1();
    41     else if (gLoadCount == 2)
    42       part2();
    43     else
    44       ok(false, "Didn't expect three loads");
    45   }
    47   function part1() {
    49     // Make sure that the pref is what we expect for mochitests.
    50     is(Services.prefs.getBoolPref('dom.use_xbl_scopes_for_remote_xul'), true,
    51        "Test harness set up like we expect");
    54     // First, test that we can't normally pass non-DOM XPCWNs to content.
    55     passToContent(/* shouldThrow = */ true);
    57     // Now, make sure we _can_ for the remote xul case. We use SpecialPowers
    58     // for the pref munging because it cleans up after us.
    59     SpecialPowers.pushPrefEnv({set: [['dom.use_xbl_scopes_for_remote_xul', false]]}, function() {
    60       $('ifr').contentWindow.location.reload();
    61     });
    62   }
    64   function part2() {
    65       passToContent(/* shouldThrow = */ false);
    66       SimpleTest.finish();
    67   }
    69   ]]>
    70   </script>
    71   <iframe id="ifr" onload="loaded();" type="content" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
    72 </window>

mercurial