Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / mochitest / test_paris_weakmap_keys.html
blob1b786138d44562f31022e30e9e937f3d23750947
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=777385
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Tests for WebIDL objects as weak map keys</title>
9 <script src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 <script type="application/javascript">
13 /** Test for Bug 777385 **/
15 SimpleTest.waitForExplicitFinish();
17 // We wait to run this until the load event because it needs to access an element.
18 function go() {
20 let live_map = new WeakMap;
22 let get_div_style = function () {
23 return document.getElementById("mydivname").style;
26 let make_live_map = function () {
27 let my_div_style = get_div_style();
28 let div_fail = false;
29 try {
30 live_map.set(my_div_style, 12345);
31 } catch (e) {
32 div_fail = true;
34 ok(!div_fail, "Using elem.style as a weak map key should not produce an exception.");
36 is(live_map.get(get_div_style()), 12345, "Live map should have live style with right value before GC.");
40 make_live_map();
42 let tf = new TestFunctions;
44 let add_non_isupports2 = function () {
45 let testKey = tf.wrapperCachedNonISupportsObject;
47 let testFail = false;
48 try {
49 live_map.set(testKey, 23456);
50 } catch (e) {
51 testFail = true;
54 ok(!testFail, "Using a wrapper cached non-nsISupports class as a weak map key should not produce an exception.");
56 is(live_map.get(testKey), 23456, "Live map should have wrapper cached non-nsISupports class right value before GC.");
59 add_non_isupports2();
62 /* Set up for running precise GC/CC then check the results. */
64 SpecialPowers.exactGC(function () {
65 SpecialPowers.forceCC();
66 SpecialPowers.forceGC();
67 SpecialPowers.forceGC();
69 is(SpecialPowers.nondeterministicGetWeakMapKeys(live_map).length, 2,
70 "Live WebIDL bindings keys should not be removed from a weak map.");
72 is(live_map.get(get_div_style()), 12345, "Live weak map should have live style with right value after GC.");
73 is(live_map.get(tf.wrapperCachedNonISupportsObject), 23456,
74 "Live weak map should have live wrapper cached non-nsISupports class with right value after GC.");
76 SimpleTest.finish();
77 });
81 SimpleTest.waitForExplicitFinish();
83 addLoadEvent(function() {
84 SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]},
85 go);
86 });
87 </script>
88 </head>
89 <div></div>
90 <div id="mydivname"></div>
91 <body>
92 <p id="display"></p>
93 </body>
94 </html>