2 <?xml-stylesheet type=
"text/css" href=
"chrome://global/skin"?>
3 <?xml-stylesheet type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"?>
5 https://bugzilla.mozilla.org/show_bug.cgi?id=673468
7 <window title=
"Mozilla Bug "
8 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
11 <!-- test results are displayed in the html:body -->
12 <body xmlns=
"http://www.w3.org/1999/xhtml">
13 <a id=
"testelem" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id="
14 target=
"_blank">Mozilla Bug
673468</a>
17 <!-- test code goes here -->
18 <script type=
"application/javascript">
20 /** Test for Bug
673468 **/
21 SimpleTest.waitForExplicitFinish();
22 SpecialPowers.DOMWindowUtils.garbageCollect();
24 let get_live_dom = function () {
25 return document.getElementById(
"testelem");
28 let wrappers_as_keys_test = function () {
29 let e = new MessageEvent(
"foo", { bubbles: false, cancellable: false,
30 data: { dummy: document.createXULElement(
"foo") }});
33 let live_dom = e.data.dummy;
34 let dead_dom = document.createElementNS(
"http://www.w3.org/1999/xhtml",
"div");
35 let dead_child = document.createElementNS(
"http://www.w3.org/1999/xhtml",
"div");
36 dead_dom.appendChild(dead_child);
37 is(dead_dom.children.length,
1,
"children have wrong length");
40 dead_dom.abcxyz = wrappee;
42 let system = Cc[
"@mozilla.org/systemprincipal;1"].createInstance();
43 let sandbox = Cu.Sandbox(system);
45 sandbox.wrapper = wrappee;
46 sandbox.value = dead_dom;
47 let map = Cu.evalInSandbox(
"wm = new WeakMap(); wm.set(wrapper, value); wm", sandbox);
48 sandbox.wrapper = null;
51 live_dom.xyzabc = {wrappee, m: map, sb: sandbox};
53 let key = ChromeUtils.nondeterministicGetWeakMapKeys(map)[
0];
54 let value = map.get(key);
55 is(value.children.length,
1,
"children have wrong length");
58 wrappers_as_keys_test();
60 let check_wrappers_as_keys = function () {
61 let live_dom = window.eeeevent.data.dummy;
62 let live_map = live_dom.xyzabc.m;
63 is(ChromeUtils.nondeterministicGetWeakMapKeys(live_map).length,
1,
64 "Map should not be empty.");
65 let key = ChromeUtils.nondeterministicGetWeakMapKeys(live_map)[
0];
66 let value = live_map.get(key);
67 is(value.children.length,
1,
"children have wrong length");
70 Cu.schedulePreciseGC(function () {
71 SpecialPowers.DOMWindowUtils.cycleCollect();
72 SpecialPowers.DOMWindowUtils.garbageCollect();
74 check_wrappers_as_keys();