Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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> |