js/xpconnect/tests/mochitest/test_bug504877.html

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 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=504877
     5 -->
     6 <head>
     7   <title>Test for Bug 504877</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=504877">Mozilla Bug 504877</a>
    13 <p id="display"></p>
    14 <div id="content" style="display: none">
    16 </div>
    17 <pre id="test">
    18 <script type="application/javascript">
    20 /** Test for Bug 504877 **/
    21 SimpleTest.waitForExplicitFinish();
    22 var p = 0;
    23 function go() {
    24     var ifr = $('ifr').contentWindow;
    25     function test1() {
    26         try {
    27             ifr.foopy;
    28             ok(false, "should have thrown a cross-origin access exception");
    29         } catch (e) {
    30             ok(/Permission denied/.test(e), "Threw a permission denied exception");
    31         }
    33         var loc = ifr.location;
    34         (function() {
    35             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    36             ifr.blat = 42;
    38             is(ifr.blat, 42, "able to set random properties")
    39             is(ifr.getblat(), 42, "setting properties propagates");
    40             is(ifr.foopy, 42, "able to use UniversalXPConnect to get random properties");
    42             loc.replace; // resolves the property onto the wrapper.
    43          })();
    45         loc.replace("http://mochi.test:8888/");
    46         ok(true, "able to set location on the cross origin(!) frame");
    47     }
    49     function test2() {
    50         SimpleTest.finish();
    51     }
    53     switch (++p) {
    54         case 1: return test1();
    55         case 2: return test2();
    56     }
    57 }
    60 </script>
    61 </pre>
    62 <iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/bug504877_helper.html" id="ifr" onload="go()"></iframe>
    63 </body>
    64 </html>

mercurial