1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 if (!Services.prefs.getBoolPref("javascript.options.experimental.symbols_as_weakmap_keys")) {
10 var strKey = new String("strKey");
11 var symKey = Symbol("symKey");
13 var weakset = new WeakSet([strKey, symKey]);
14 var weakmap = new WeakMap();
15 weakmap.set(strKey, 23);
16 weakmap.set(symKey, "oh no");
18 var keys = ChromeUtils.nondeterministicGetWeakMapKeys(weakmap);
19 equal(keys.length, 2, "length of nondeterministicGetWeakMapKeys");
20 equal(weakmap.get(strKey), 23, "check strKey in weakmap");
21 equal(weakmap.get(symKey), "oh no", "check symKey in weakmap");
23 keys = ChromeUtils.nondeterministicGetWeakSetKeys(weakset);
24 equal(keys.length, 2, "length of nondeterministicGetWeakSetKeys");
25 ok(weakset.has(strKey), "check strKey in weakset");
26 ok(weakset.has(symKey), "check symKey in weakset");
33 keys = ChromeUtils.nondeterministicGetWeakMapKeys(weakmap);
34 equal(keys.length, 1, "length of nondeterministicGetWeakMapKeys after GC");
35 equal(weakmap.get(symKey), "oh no", "check symKey still in weakmap");
37 keys = ChromeUtils.nondeterministicGetWeakSetKeys(weakset);
38 equal(keys.length, 1, "length of nondeterministicGetWeakSetKeys after GC");
39 ok(weakset.has(symKey), "check symKey still in weakset");