js/xpconnect/tests/mochitest/test_crosscompartment_weakmap.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 <head>
     4   <title>Test Cross-Compartment DOM WeakMaps</title>
     5   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     7 </head>
     8 <body>
     9 <p id="display"></p>
    10 <script type="application/javascript">
    12 var my_map = WeakMap();
    14 function setup() {
    15   var item = window.frames[0].document.querySelector("body");
    17   my_map.set(item, "success_string");
    19   var rule_fail = false;
    20   try {
    21     my_map.set(window.frames[0].document.styleSheets[0].cssRules[0], 1);
    22   } catch (e) {
    23     rule_fail = true;
    24   }
    25   ok(rule_fail, "Using rule as a weak map key across compartments should produce an exception because it can't be wrapper preserved.");
    26 }
    28 function runTest() {
    29   setup();
    30   SpecialPowers.forceGC();
    31   SpecialPowers.forceCC();
    32   SpecialPowers.forceGC();
    33   SpecialPowers.forceCC();
    34   var item = window.frames[0].document.querySelector("body");
    35   is(my_map.get(item), "success_string", "Preserve reflectors used cross-compartment as weak map keys.");
    36 }
    38 </script>
    39 <iframe src="file_crosscompartment_weakmap.html" onload="runTest()"></iframe>
    42 </pre>
    43 </body>
    44 </html>

mercurial