Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Bug 1168270 - making test-tabs.js.testTabsEvent_onClose more verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvold committed Jun 2, 2015
1 parent c5ba482 commit 523f25b
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions test/tabs/test-firefox-tabs.js
Expand Up @@ -537,23 +537,23 @@ exports.testTabsEvent_onOpen = function(assert, done) {
};

// TEST: onClose event handler
exports.testTabsEvent_onClose = function(assert, done) {
open().then(focus).then(window => {
let url = "data:text/html;charset=utf-8,onclose";
let eventCount = 0;

// add listener via property assignment
function listener1(tab) {
eventCount++;
}
tabs.on('close', listener1);
exports.testTabsEvent_onClose = function*(assert) {
let window = yield open().then(focus);
let url = "data:text/html;charset=utf-8,onclose";
let eventCount = 0;

// add listener via property assignment
function listener1(tab) {
eventCount++;
}
tabs.on("close", listener1);

yield new Promise(resolve => {
// add listener via collection add
tabs.on('close', function listener2(tab) {
tabs.on("close", function listener2(tab) {
assert.equal(++eventCount, 2, "both listeners notified");
tabs.removeListener('close', listener1);
tabs.removeListener('close', listener2);
close(window).then(done).then(null, assert.fail);
tabs.removeListener("close", listener2);
resolve();
});

tabs.on('ready', function onReady(tab) {
Expand All @@ -562,7 +562,13 @@ exports.testTabsEvent_onClose = function(assert, done) {
});

tabs.open(url);
}).then(null, assert.fail);
});

tabs.removeListener("close", listener1);
assert.pass("done test!");

yield close(window);
assert.pass("window was closed!");
};

// TEST: onClose event handler when a window is closed
Expand Down

0 comments on commit 523f25b

Please sign in to comment.