test_bug655297-2.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=655297
  5. -->
  6. <head>
  7. <title>Test for Bug 655297</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=655297">Mozilla Bug 655297</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. </div>
  16. <p>0</p> <p>1</p> <p>2</p> <p>3</p> <p>4</p>
  17. <p>5</p> <p>6</p> <p>7</p> <p>8</p> <p>9</p>
  18. <pre id="test">
  19. <script type="application/javascript">
  20. /** Test for Bug 655297 **/
  21. var map = new WeakMap();
  22. function f() {
  23. var paras = document.getElementsByTagName("p");
  24. for (var i = 0; i < paras.length; i++)
  25. map.set(paras[i], "ok");
  26. }
  27. function g() {
  28. var paras = document.getElementsByTagName("p");
  29. for (var i = 0; i < paras.length; i++) {
  30. if (map.get(paras[i]) != "ok") {
  31. return false;
  32. }
  33. }
  34. return true;
  35. }
  36. f();
  37. SpecialPowers.forceGC();
  38. ok(g(), "Failed to keep XPCWrappedNative used as WeakMap key alive.");
  39. </script>
  40. </pre>
  41. </body>
  42. </html>