Bug 1286673 - Test sdk/event/dom.js for leaks when used on a closed window. r=gabor, a=test-only
authorBen Kelly <ben@wanderview.com>
Fri, 15 Jul 2016 14:30:08 -0700
changeset 342150 e7f05d6e1e2f181602977a24c75152287b2b8a95
parent 342149 cc2c70e60632d87e27545833f55419c86a3d41a5
child 342151 52ed81c056013146ae61522464bca83f70d486d8
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor, test-only
bugs1286673
milestone49.0a2
Bug 1286673 - Test sdk/event/dom.js for leaks when used on a closed window. r=gabor, a=test-only
addon-sdk/source/test/leak/jetpack-package.ini
addon-sdk/source/test/leak/test-leak-event-dom-closed-window.js
--- a/addon-sdk/source/test/leak/jetpack-package.ini
+++ b/addon-sdk/source/test/leak/jetpack-package.ini
@@ -1,6 +1,7 @@
 [DEFAULT]
 support-files =
   leak-utils.js
 
 [test-leak-window-events.js]
+[test-leak-event-dom-closed-window.js]
 [test-leak-tab-events.js]
new file mode 100644
--- /dev/null
+++ b/addon-sdk/source/test/leak/test-leak-event-dom-closed-window.js
@@ -0,0 +1,29 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+'use strict';
+
+const { asyncWindowLeakTest } = require("./leak-utils");
+const { Loader } = require('sdk/test/loader');
+const openWindow = require("sdk/window/utils").open;
+
+exports["test sdk/event/dom does not leak when attached to closed window"] = function*(assert) {
+  yield asyncWindowLeakTest(assert, _ => {
+    return new Promise(resolve => {
+      let loader = Loader(module);
+      let { open } = loader.require('sdk/event/dom');
+      let w = openWindow();
+      w.addEventListener("DOMWindowClose", function windowClosed(evt) {
+        w.removeEventListener("DOMWindowClose", windowClosed);
+        // The sdk/event/dom module tries to clean itself up when DOMWindowClose
+        // is fired.  Verify that it doesn't leak if its attached to an
+        // already closed window either. (See bug 1268898.)
+        open(w.document, "TestEvent1");
+        resolve(loader);
+      });
+      w.close();
+    });
+  });
+}
+
+require("sdk/test").run(exports);