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.

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

mercurial