Bug 1288440 P3 Test that sdk/tab/events does not leak. r=gabor
authorBen Kelly <ben@wanderview.com>
Fri, 22 Jul 2016 06:26:49 -0700
changeset 331430 e97c19b04dba7e36953a9b0d86c16ead8863146a
parent 331429 fb9e0b43f99bd1165c40d0b7f6c516d9c36bad0b
child 331431 2b1ddc2f0919755078ed3ea190d263f97609870b
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1288440
milestone50.0a1
Bug 1288440 P3 Test that sdk/tab/events does not leak. r=gabor
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,7 +1,8 @@
 [DEFAULT]
 support-files =
   leak-utils.js
 
 [test-leak-window-events.js]
 [test-leak-event-dom-closed-window.js]
+[test-leak-tab-events.js]
 [test-leak-event-chrome.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);