tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_getweakmapkeys.html (906B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for SpecialPowers.nondeterministicGetWeakMapKeys</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      7 </head>
      8 <body>
      9 
     10 <div id="content" class="testbody">
     11  <script type="text/javascript">
     12    var emptyMap = new WeakMap;
     13    is(SpecialPowers.nondeterministicGetWeakMapKeys(emptyMap).length, 0, "Empty map has no keys");
     14    var twoMap = new WeakMap;
     15    var x = {};
     16    var y = {};
     17    twoMap.set(x, 1);
     18    twoMap.set(y, 2);
     19    var twoMapKeys = SpecialPowers.nondeterministicGetWeakMapKeys(twoMap);
     20    is(twoMapKeys.length, 2, "Map with two things should have two keys");
     21    ok(twoMapKeys[0] == x || twoMapKeys[1] == x, "One of the keys should be x");
     22    ok(twoMapKeys[0] == y || twoMapKeys[1] == y, "One of the keys should be y");
     23  </script>
     24 </div>
     25 </body>
     26 </html>