Bug 1288440 - Part 3: Test that sdk/tab/events does not leak. r=gabor, a=sledru
authorBen Kelly <ben@wanderview.com>
Fri, 22 Jul 2016 06:26:49 -0700
changeset 340135 7ead20a4ee6e8d6642ad6a2aa9862761ff1cd324
parent 340134 9b232ee6823a5dfbac8aa2d7c627ccfe1fcafff7
child 340136 cc2c70e60632d87e27545833f55419c86a3d41a5
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor, sledru
bugs1288440
milestone49.0a2
Bug 1288440 - Part 3: Test that sdk/tab/events does not leak. r=gabor, a=sledru
addon-sdk/source/test/leak/jetpack-package.ini
addon-sdk/source/test/leak/test-leak-tab-events.js
--- a/addon-sdk/source/test/leak/jetpack-package.ini
+++ b/addon-sdk/source/test/leak/jetpack-package.ini
@@ -1,5 +1,6 @@
 [DEFAULT]
 support-files =
   leak-utils.js
 
 [test-leak-window-events.js]
+[test-leak-tab-events.js]
new file mode 100644
--- /dev/null
+++ b/addon-sdk/source/test/leak/test-leak-tab-events.js
@@ -0,0 +1,46 @@
+/* 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/tab/events does not leak new window"] = function*(assert) {
+  yield asyncWindowLeakTest(assert, _ => {
+    return new Promise(resolve => {
+      let loader = Loader(module);
+      let { events } = loader.require('sdk/tab/events');
+      let w = openWindow();
+      w.addEventListener("load", function windowLoaded(evt) {
+        w.removeEventListener("load", windowLoaded);
+        w.addEventListener("DOMWindowClose", function windowClosed(evt) {
+          w.removeEventListener("DOMWindowClose", windowClosed);
+          resolve(loader);
+        });
+        w.close();
+      });
+    });
+  });
+}
+
+exports["test sdk/tab/events does not leak when attached to existing window"] = function*(assert) {
+  yield asyncWindowLeakTest(assert, _ => {
+    return new Promise(resolve => {
+      let loader = Loader(module);
+      let w = openWindow();
+      w.addEventListener("load", function windowLoaded(evt) {
+        w.removeEventListener("load", windowLoaded);
+        let { events } = loader.require('sdk/tab/events');
+        w.addEventListener("DOMWindowClose", function windowClosed(evt) {
+          w.removeEventListener("DOMWindowClose", windowClosed);
+          resolve(loader);
+        });
+        w.close();
+      });
+    });
+  });
+}
+
+require("sdk/test").run(exports);