Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <!-- |
michael@0 | 3 | Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 5 | --> |
michael@0 | 6 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 7 | <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> |
michael@0 | 8 | |
michael@0 | 9 | <window title="DOMRequestHelper Test" |
michael@0 | 10 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 11 | onload="start();"> |
michael@0 | 12 | |
michael@0 | 13 | <script type="application/javascript" |
michael@0 | 14 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 15 | |
michael@0 | 16 | <script type="application/javascript"> |
michael@0 | 17 | <![CDATA[ |
michael@0 | 18 | const Cc = Components.classes; |
michael@0 | 19 | const Cu = Components.utils; |
michael@0 | 20 | const Ci = Components.interfaces; |
michael@0 | 21 | Cu.import("resource://gre/modules/DOMRequestHelper.jsm"); |
michael@0 | 22 | let obs = Cc["@mozilla.org/observer-service;1"]. |
michael@0 | 23 | getService(Ci.nsIObserverService); |
michael@0 | 24 | |
michael@0 | 25 | function DummyHelperSubclass() { |
michael@0 | 26 | this.onuninit = null; |
michael@0 | 27 | } |
michael@0 | 28 | DummyHelperSubclass.prototype = { |
michael@0 | 29 | __proto__: DOMRequestIpcHelper.prototype, |
michael@0 | 30 | uninit: function() { |
michael@0 | 31 | if (typeof this.onuninit === "function") { |
michael@0 | 32 | this.onuninit(); |
michael@0 | 33 | } |
michael@0 | 34 | this.onuninit = null; |
michael@0 | 35 | } |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | var dummy = new DummyHelperSubclass(); |
michael@0 | 39 | |
michael@0 | 40 | /** |
michael@0 | 41 | * Init & destroy. |
michael@0 | 42 | */ |
michael@0 | 43 | function initDOMRequestHelperTest(aMessages) { |
michael@0 | 44 | is(dummy._requests, undefined, "Request is undefined"); |
michael@0 | 45 | is(dummy._messages, undefined, "Messages is undefined"); |
michael@0 | 46 | is(dummy._window, undefined, "Window is undefined"); |
michael@0 | 47 | |
michael@0 | 48 | dummy.initDOMRequestHelper(window, aMessages); |
michael@0 | 49 | |
michael@0 | 50 | ok(dummy._window, "Window exists"); |
michael@0 | 51 | is(dummy._window, window, "Correct window"); |
michael@0 | 52 | if (aMessages) { |
michael@0 | 53 | is(typeof dummy._listeners, "object", "Listeners is an object"); |
michael@0 | 54 | } |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function destroyDOMRequestHelperTest() { |
michael@0 | 58 | dummy.destroyDOMRequestHelper(); |
michael@0 | 59 | |
michael@0 | 60 | is(dummy._requests, undefined, "Request is undefined"); |
michael@0 | 61 | is(dummy._messages, undefined, "Messages is undefined"); |
michael@0 | 62 | is(dummy._window, undefined, "Window is undefined"); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * Message listeners. |
michael@0 | 67 | */ |
michael@0 | 68 | function checkMessageListeners(aExpectedListeners, aCount) { |
michael@0 | 69 | ok(true, "Checking message listeners\n" + "Expected listeners " + |
michael@0 | 70 | JSON.stringify(aExpectedListeners) + " \nExpected count " + aCount); |
michael@0 | 71 | let count = 0; |
michael@0 | 72 | Object.keys(dummy._listeners).forEach(function(name) { |
michael@0 | 73 | count++; |
michael@0 | 74 | is(aExpectedListeners[name], dummy._listeners[name], |
michael@0 | 75 | "Message found " + name + " - Same listeners"); |
michael@0 | 76 | }); |
michael@0 | 77 | is(aCount, count, "Correct number of listeners"); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | function addMessageListenersTest(aMessages, aExpectedListeners, aCount) { |
michael@0 | 81 | dummy.addMessageListeners(aMessages); |
michael@0 | 82 | ok(true, JSON.stringify(dummy._listeners)); |
michael@0 | 83 | checkMessageListeners(aExpectedListeners, aCount); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | function removeMessageListenersTest(aMessages, aExpectedListeners, aCount) { |
michael@0 | 87 | dummy.removeMessageListeners(aMessages); |
michael@0 | 88 | checkMessageListeners(aExpectedListeners, aCount); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | /** |
michael@0 | 92 | * Utility function to test window destruction behavior. In general this |
michael@0 | 93 | * function does the following: |
michael@0 | 94 | * |
michael@0 | 95 | * 1) Create a new iframe |
michael@0 | 96 | * 2) Create a new DOMRequestHelper |
michael@0 | 97 | * 3) initDOMRequestHelper(), optionally with weak or strong listeners |
michael@0 | 98 | * 4) Optionally force a garbage collection to reap weak references |
michael@0 | 99 | * 5) Destroy the iframe triggering an inner-window-destroyed event |
michael@0 | 100 | * 6) Callback with a boolean indicating if DOMRequestHelper.uninit() was |
michael@0 | 101 | * called. |
michael@0 | 102 | * |
michael@0 | 103 | * Example usage: |
michael@0 | 104 | * |
michael@0 | 105 | * checkWindowDestruction({ messages: ["foo"], gc: true }, |
michael@0 | 106 | * function(uninitCalled) { |
michael@0 | 107 | * // expect uninitCalled === false since GC with only weak refs |
michael@0 | 108 | * }); |
michael@0 | 109 | */ |
michael@0 | 110 | const TOPIC = "inner-window-destroyed"; |
michael@0 | 111 | function checkWindowDestruction(aOptions, aCallback) { |
michael@0 | 112 | aOptions = aOptions || {}; |
michael@0 | 113 | aOptions.messages = aOptions.messages || []; |
michael@0 | 114 | aOptions.gc = !!aOptions.gc; |
michael@0 | 115 | |
michael@0 | 116 | if (typeof aCallback !== "function") { |
michael@0 | 117 | aCallback = function() { }; |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | let uninitCalled = false; |
michael@0 | 121 | |
michael@0 | 122 | // Use a secondary observer so we know when to expect the uninit(). We |
michael@0 | 123 | // can then reasonably expect uninitCalled to be set properly on the |
michael@0 | 124 | // next tick. |
michael@0 | 125 | let observer = { |
michael@0 | 126 | observe: function(aSubject, aTopic, aData) { |
michael@0 | 127 | if (aTopic !== TOPIC) { |
michael@0 | 128 | return; |
michael@0 | 129 | } |
michael@0 | 130 | obs.removeObserver(observer, TOPIC); |
michael@0 | 131 | setTimeout(function() { |
michael@0 | 132 | aCallback(uninitCalled); |
michael@0 | 133 | }); |
michael@0 | 134 | } |
michael@0 | 135 | }; |
michael@0 | 136 | |
michael@0 | 137 | let frame = document.createElement("iframe"); |
michael@0 | 138 | frame.onload = function() { |
michael@0 | 139 | obs.addObserver(observer, TOPIC, false); |
michael@0 | 140 | // Create dummy DOMRequestHelper specific to checkWindowDestruction() |
michael@0 | 141 | let cwdDummy = new DummyHelperSubclass(); |
michael@0 | 142 | cwdDummy.onuninit = function() { |
michael@0 | 143 | uninitCalled = true; |
michael@0 | 144 | }; |
michael@0 | 145 | cwdDummy.initDOMRequestHelper(frame.contentWindow, aOptions.messages); |
michael@0 | 146 | // Make sure to clear our strong ref here so that we can test our |
michael@0 | 147 | // weak reference listeners and observer. |
michael@0 | 148 | cwdDummy = null; |
michael@0 | 149 | if (aOptions.gc) { |
michael@0 | 150 | Cu.schedulePreciseGC(function() { |
michael@0 | 151 | SpecialPowers.DOMWindowUtils.cycleCollect(); |
michael@0 | 152 | SpecialPowers.DOMWindowUtils.garbageCollect(); |
michael@0 | 153 | SpecialPowers.DOMWindowUtils.garbageCollect(); |
michael@0 | 154 | document.documentElement.removeChild(frame); |
michael@0 | 155 | }); |
michael@0 | 156 | return; |
michael@0 | 157 | } |
michael@0 | 158 | document.documentElement.removeChild(frame); |
michael@0 | 159 | }; |
michael@0 | 160 | document.documentElement.appendChild(frame); |
michael@0 | 161 | } |
michael@0 | 162 | |
michael@0 | 163 | /** |
michael@0 | 164 | * Test steps. |
michael@0 | 165 | */ |
michael@0 | 166 | var tests = [ |
michael@0 | 167 | function() { |
michael@0 | 168 | ok(true, "== InitDOMRequestHelper no messages"); |
michael@0 | 169 | initDOMRequestHelperTest(null); |
michael@0 | 170 | next(); |
michael@0 | 171 | }, |
michael@0 | 172 | function() { |
michael@0 | 173 | ok(true, "== DestroyDOMRequestHelper"); |
michael@0 | 174 | destroyDOMRequestHelperTest(); |
michael@0 | 175 | next(); |
michael@0 | 176 | }, |
michael@0 | 177 | function() { |
michael@0 | 178 | ok(true, "== InitDOMRequestHelper empty array"); |
michael@0 | 179 | initDOMRequestHelperTest([]); |
michael@0 | 180 | checkMessageListeners({}, 0); |
michael@0 | 181 | next(); |
michael@0 | 182 | }, |
michael@0 | 183 | function() { |
michael@0 | 184 | ok(true, "== DestroyDOMRequestHelper"); |
michael@0 | 185 | destroyDOMRequestHelperTest(); |
michael@0 | 186 | next(); |
michael@0 | 187 | }, |
michael@0 | 188 | function() { |
michael@0 | 189 | ok(true, "== InitDOMRequestHelper with strings array"); |
michael@0 | 190 | initDOMRequestHelperTest(["name1", "nameN"]); |
michael@0 | 191 | checkMessageListeners({"name1": false, "nameN": false}, 2); |
michael@0 | 192 | next(); |
michael@0 | 193 | }, |
michael@0 | 194 | function() { |
michael@0 | 195 | ok(true, "== DestroyDOMRequestHelper"); |
michael@0 | 196 | destroyDOMRequestHelperTest(); |
michael@0 | 197 | next(); |
michael@0 | 198 | }, |
michael@0 | 199 | function() { |
michael@0 | 200 | ok(true, "== InitDOMRequestHelper with objects array"); |
michael@0 | 201 | initDOMRequestHelperTest([{ |
michael@0 | 202 | name: "name1", |
michael@0 | 203 | weakRef: false |
michael@0 | 204 | }, { |
michael@0 | 205 | name: "nameN", |
michael@0 | 206 | weakRef: true |
michael@0 | 207 | }]); |
michael@0 | 208 | checkMessageListeners({"name1": false, "nameN": true}, 2); |
michael@0 | 209 | next(); |
michael@0 | 210 | }, |
michael@0 | 211 | function() { |
michael@0 | 212 | ok(true, "== AddMessageListeners empty array"); |
michael@0 | 213 | addMessageListenersTest([], {"name1": false, "nameN": true}, 2); |
michael@0 | 214 | next(); |
michael@0 | 215 | }, |
michael@0 | 216 | function() { |
michael@0 | 217 | ok(true, "== AddMessageListeners null"); |
michael@0 | 218 | addMessageListenersTest(null, {"name1": false, "nameN": true}, 2); |
michael@0 | 219 | next(); |
michael@0 | 220 | }, |
michael@0 | 221 | function() { |
michael@0 | 222 | ok(true, "== AddMessageListeners new listener, string only"); |
michael@0 | 223 | addMessageListenersTest("name2", { |
michael@0 | 224 | "name1": false, |
michael@0 | 225 | "name2": false, |
michael@0 | 226 | "nameN": true |
michael@0 | 227 | }, 3); |
michael@0 | 228 | next(); |
michael@0 | 229 | }, |
michael@0 | 230 | function() { |
michael@0 | 231 | ok(true, "== AddMessageListeners new listeners, strings array"); |
michael@0 | 232 | addMessageListenersTest(["name3", "name4"], { |
michael@0 | 233 | "name1": false, |
michael@0 | 234 | "name2": false, |
michael@0 | 235 | "name3": false, |
michael@0 | 236 | "name4": false, |
michael@0 | 237 | "nameN": true |
michael@0 | 238 | }, 5); |
michael@0 | 239 | next(); |
michael@0 | 240 | }, |
michael@0 | 241 | function() { |
michael@0 | 242 | ok(true, "== AddMessageListeners new listeners, objects array"); |
michael@0 | 243 | addMessageListenersTest([{ |
michael@0 | 244 | name: "name5", |
michael@0 | 245 | weakRef: true |
michael@0 | 246 | }, { |
michael@0 | 247 | name: "name6", |
michael@0 | 248 | weakRef: false |
michael@0 | 249 | }], { |
michael@0 | 250 | "name1": false, |
michael@0 | 251 | "name2": false, |
michael@0 | 252 | "name3": false, |
michael@0 | 253 | "name4": false, |
michael@0 | 254 | "name5": true, |
michael@0 | 255 | "name6": false, |
michael@0 | 256 | "nameN": true |
michael@0 | 257 | }, 7); |
michael@0 | 258 | next(); |
michael@0 | 259 | }, |
michael@0 | 260 | function() { |
michael@0 | 261 | ok(true, "== RemoveMessageListeners, null"); |
michael@0 | 262 | removeMessageListenersTest(null, { |
michael@0 | 263 | "name1": false, |
michael@0 | 264 | "name2": false, |
michael@0 | 265 | "name3": false, |
michael@0 | 266 | "name4": false, |
michael@0 | 267 | "name5": true, |
michael@0 | 268 | "name6": false, |
michael@0 | 269 | "nameN": true |
michael@0 | 270 | }, 7); |
michael@0 | 271 | next(); |
michael@0 | 272 | }, |
michael@0 | 273 | function() { |
michael@0 | 274 | ok(true, "== RemoveMessageListeners, one message"); |
michael@0 | 275 | removeMessageListenersTest("name1", { |
michael@0 | 276 | "name2": false, |
michael@0 | 277 | "name3": false, |
michael@0 | 278 | "name4": false, |
michael@0 | 279 | "name5": true, |
michael@0 | 280 | "name6": false, |
michael@0 | 281 | "nameN": true |
michael@0 | 282 | }, 6); |
michael@0 | 283 | next(); |
michael@0 | 284 | }, |
michael@0 | 285 | function() { |
michael@0 | 286 | ok(true, "== RemoveMessageListeners, array of messages"); |
michael@0 | 287 | removeMessageListenersTest(["name2", "name3"], { |
michael@0 | 288 | "name4": false, |
michael@0 | 289 | "name5": true, |
michael@0 | 290 | "name6": false, |
michael@0 | 291 | "nameN": true |
michael@0 | 292 | }, 4); |
michael@0 | 293 | next(); |
michael@0 | 294 | }, |
michael@0 | 295 | function() { |
michael@0 | 296 | ok(true, "== RemoveMessageListeners, unknown message"); |
michael@0 | 297 | removeMessageListenersTest("unknown", { |
michael@0 | 298 | "name4": false, |
michael@0 | 299 | "name5": true, |
michael@0 | 300 | "name6": false, |
michael@0 | 301 | "nameN": true |
michael@0 | 302 | }, 4); |
michael@0 | 303 | next(); |
michael@0 | 304 | }, |
michael@0 | 305 | function() { |
michael@0 | 306 | try { |
michael@0 | 307 | ok(true, "== AddMessageListeners, same message, same kind"); |
michael@0 | 308 | addMessageListenersTest("name4", { |
michael@0 | 309 | "name4": false, |
michael@0 | 310 | "name5": true, |
michael@0 | 311 | "name6": false, |
michael@0 | 312 | "nameN": true |
michael@0 | 313 | }, 4); |
michael@0 | 314 | next(); |
michael@0 | 315 | } catch (ex) { |
michael@0 | 316 | ok(false, "Unexpected exception " + ex); |
michael@0 | 317 | } |
michael@0 | 318 | }, |
michael@0 | 319 | function() { |
michael@0 | 320 | ok(true, "== AddMessageListeners, same message, different kind"); |
michael@0 | 321 | try { |
michael@0 | 322 | addMessageListenersTest({name: "name4", weakRef: true}, { |
michael@0 | 323 | "name4": true, |
michael@0 | 324 | "name5": true, |
michael@0 | 325 | "name6": false, |
michael@0 | 326 | "nameN": true |
michael@0 | 327 | }, 4); |
michael@0 | 328 | ok(false, "Should have thrown an exception"); |
michael@0 | 329 | } catch (ex) { |
michael@0 | 330 | ok(true, "Expected exception"); |
michael@0 | 331 | next(); |
michael@0 | 332 | } |
michael@0 | 333 | }, |
michael@0 | 334 | function() { |
michael@0 | 335 | ok(true, "== Test createRequest()"); |
michael@0 | 336 | ok(DOMRequest, "DOMRequest object exists"); |
michael@0 | 337 | var req = dummy.createRequest(); |
michael@0 | 338 | ok(req instanceof DOMRequest, "Returned a DOMRequest"); |
michael@0 | 339 | next(); |
michael@0 | 340 | }, |
michael@0 | 341 | function() { |
michael@0 | 342 | ok(true, "== Test getRequestId(), removeRequest() and getRequest()"); |
michael@0 | 343 | var req = dummy.createRequest(); |
michael@0 | 344 | var id = dummy.getRequestId(req); |
michael@0 | 345 | is(typeof id, "string", "id is a string"); |
michael@0 | 346 | var req_ = dummy.getRequest(id); |
michael@0 | 347 | is(req, req_, "Got correct request"); |
michael@0 | 348 | dummy.removeRequest(id); |
michael@0 | 349 | req = dummy.getRequest(id); |
michael@0 | 350 | is(req, null, "No request"); |
michael@0 | 351 | next(); |
michael@0 | 352 | }, |
michael@0 | 353 | function() { |
michael@0 | 354 | ok(true, "== Test createPromise()"); |
michael@0 | 355 | ok(Promise, "Promise object exists"); |
michael@0 | 356 | var promise = dummy.createPromise(function(resolve, reject) { |
michael@0 | 357 | resolve(true); |
michael@0 | 358 | }); |
michael@0 | 359 | ok(promise instanceof Promise, "Returned a Promise"); |
michael@0 | 360 | promise.then(next); |
michael@0 | 361 | }, |
michael@0 | 362 | function() { |
michael@0 | 363 | ok(true, "== Test getResolver()"); |
michael@0 | 364 | var id; |
michael@0 | 365 | var resolver; |
michael@0 | 366 | var promise = dummy.createPromise(function(resolve, reject) { |
michael@0 | 367 | var r = { resolve: resolve, reject: reject }; |
michael@0 | 368 | id = dummy.getPromiseResolverId(r); |
michael@0 | 369 | resolver = r; |
michael@0 | 370 | ok(typeof id === "string", "id is a string"); |
michael@0 | 371 | r.resolve(true); |
michael@0 | 372 | }).then(function(unused) { |
michael@0 | 373 | var r = dummy.getPromiseResolver(id); |
michael@0 | 374 | ok(resolver === r, "Get succeeded"); |
michael@0 | 375 | next(); |
michael@0 | 376 | }); |
michael@0 | 377 | }, |
michael@0 | 378 | function() { |
michael@0 | 379 | ok(true, "== Test removeResolver"); |
michael@0 | 380 | var id; |
michael@0 | 381 | var promise = dummy.createPromise(function(resolve, reject) { |
michael@0 | 382 | var r = { resolve: resolve, reject: reject }; |
michael@0 | 383 | id = dummy.getPromiseResolverId(r); |
michael@0 | 384 | ok(typeof id === "string", "id is a string"); |
michael@0 | 385 | |
michael@0 | 386 | var resolver = dummy.getPromiseResolver(id); |
michael@0 | 387 | ok(true, "Got resolver " + JSON.stringify(resolver)); |
michael@0 | 388 | ok(resolver === r, "Resolver get succeeded"); |
michael@0 | 389 | |
michael@0 | 390 | r.resolve(true); |
michael@0 | 391 | }).then(function(unused) { |
michael@0 | 392 | dummy.removePromiseResolver(id); |
michael@0 | 393 | var resolver = dummy.getPromiseResolver(id); |
michael@0 | 394 | ok(resolver === undefined, "removeResolver: get failed"); |
michael@0 | 395 | next(); |
michael@0 | 396 | }); |
michael@0 | 397 | }, |
michael@0 | 398 | function() { |
michael@0 | 399 | ok(true, "== Test takeResolver"); |
michael@0 | 400 | var id; |
michael@0 | 401 | var resolver; |
michael@0 | 402 | var promise = dummy.createPromise(function(resolve, reject) { |
michael@0 | 403 | var r = { resolve: resolve, reject: reject }; |
michael@0 | 404 | id = dummy.getPromiseResolverId(r); |
michael@0 | 405 | resolver = r; |
michael@0 | 406 | ok(typeof id === "string", "id is a string"); |
michael@0 | 407 | |
michael@0 | 408 | var gotR = dummy.getPromiseResolver(id); |
michael@0 | 409 | ok(gotR === r, "resolver get succeeded"); |
michael@0 | 410 | |
michael@0 | 411 | r.resolve(true); |
michael@0 | 412 | }).then(function(unused) { |
michael@0 | 413 | var r = dummy.takePromiseResolver(id); |
michael@0 | 414 | ok(resolver === r, "take should succeed"); |
michael@0 | 415 | |
michael@0 | 416 | r = dummy.getPromiseResolver(id); |
michael@0 | 417 | ok(r === undefined, "takeResolver: get failed"); |
michael@0 | 418 | next(); |
michael@0 | 419 | }); |
michael@0 | 420 | }, |
michael@0 | 421 | function() { |
michael@0 | 422 | ok(true, "== Test window destroyed without messages and without GC"); |
michael@0 | 423 | checkWindowDestruction({ gc: false }, function(uninitCalled) { |
michael@0 | 424 | ok(uninitCalled, "uninit() should have been called"); |
michael@0 | 425 | next(); |
michael@0 | 426 | }); |
michael@0 | 427 | }, |
michael@0 | 428 | function() { |
michael@0 | 429 | ok(true, "== Test window destroyed without messages and with GC"); |
michael@0 | 430 | checkWindowDestruction({ gc: true }, function(uninitCalled) { |
michael@0 | 431 | ok(!uninitCalled, "uninit() should NOT have been called"); |
michael@0 | 432 | next(); |
michael@0 | 433 | }); |
michael@0 | 434 | }, |
michael@0 | 435 | function() { |
michael@0 | 436 | ok(true, "== Test window destroyed with weak messages and without GC"); |
michael@0 | 437 | checkWindowDestruction({ messages: [{ name: "foo", weakRef: true }], |
michael@0 | 438 | gc: false }, function(uninitCalled) { |
michael@0 | 439 | ok(uninitCalled, "uninit() should have been called"); |
michael@0 | 440 | next(); |
michael@0 | 441 | }); |
michael@0 | 442 | }, |
michael@0 | 443 | function() { |
michael@0 | 444 | ok(true, "== Test window destroyed with weak messages and with GC"); |
michael@0 | 445 | checkWindowDestruction({ messages: [{ name: "foo", weakRef: true }], |
michael@0 | 446 | gc: true }, function(uninitCalled) { |
michael@0 | 447 | ok(!uninitCalled, "uninit() should NOT have been called"); |
michael@0 | 448 | next(); |
michael@0 | 449 | }); |
michael@0 | 450 | }, |
michael@0 | 451 | function() { |
michael@0 | 452 | ok(true, "== Test window destroyed with strong messages and without GC"); |
michael@0 | 453 | checkWindowDestruction({ messages: [{ name: "foo", weakRef: false }], |
michael@0 | 454 | gc: false }, function(uninitCalled) { |
michael@0 | 455 | ok(uninitCalled, "uninit() should have been called"); |
michael@0 | 456 | next(); |
michael@0 | 457 | }); |
michael@0 | 458 | }, |
michael@0 | 459 | function() { |
michael@0 | 460 | ok(true, "== Test window destroyed with strong messages and with GC"); |
michael@0 | 461 | checkWindowDestruction({ messages: [{ name: "foo", weakRef: false }], |
michael@0 | 462 | gc: true }, function(uninitCalled) { |
michael@0 | 463 | ok(uninitCalled, "uninit() should have been called"); |
michael@0 | 464 | next(); |
michael@0 | 465 | }); |
michael@0 | 466 | } |
michael@0 | 467 | ]; |
michael@0 | 468 | |
michael@0 | 469 | function next() { |
michael@0 | 470 | if (!tests.length) { |
michael@0 | 471 | SimpleTest.finish(); |
michael@0 | 472 | return; |
michael@0 | 473 | } |
michael@0 | 474 | |
michael@0 | 475 | var test = tests.shift(); |
michael@0 | 476 | test(); |
michael@0 | 477 | } |
michael@0 | 478 | |
michael@0 | 479 | function start() { |
michael@0 | 480 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 481 | next(); |
michael@0 | 482 | } |
michael@0 | 483 | ]]> |
michael@0 | 484 | </script> |
michael@0 | 485 | |
michael@0 | 486 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 487 | <p id="display"></p> |
michael@0 | 488 | <div id="content" style="display: none"></div> |
michael@0 | 489 | <pre id="test"></pre> |
michael@0 | 490 | </body> |
michael@0 | 491 | </window> |