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

Commit

Permalink
Merge pull request #862 from erikvold/851557
Browse files Browse the repository at this point in the history
Bug 851557: waiting for windows to close before ending tests r=@Mossop(cherry picked from commit c4ab120)
  • Loading branch information
erikvold authored and KWierso committed Mar 18, 2013
1 parent c91f172 commit be0f704
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/addons/private-browsing-supported/test-selection.js
Expand Up @@ -19,10 +19,9 @@ const FRAME_URL = "data:text/html;charset=utf-8," + encodeURIComponent(FRAME_HTM

const { defer } = require("sdk/core/promise");
const tabs = require("sdk/tabs");
const { setTabURL } = require("sdk/tabs/utils");
const { getActiveTab, getTabContentWindow, closeTab } = require("sdk/tabs/utils")
const { setTabURL, getActiveTab, getTabContentWindow, closeTab } = require("sdk/tabs/utils")
const { getMostRecentBrowserWindow } = require("sdk/window/utils");
const { open: openNewWindow } = require("sdk/window/helpers");
const { open: openNewWindow, close: closeWindow } = require("sdk/window/helpers");
const { Loader } = require("sdk/test/loader");
const { merge } = require("sdk/util/object");
const { isPrivate } = require("sdk/private-browsing");
Expand Down Expand Up @@ -86,18 +85,19 @@ function open(url, options) {
* Close the Active Tab
*/
function close(window) {
let { promise, resolve } = defer();

if (window && typeof(window.close) === "function") {
window.close();
} else {
closeWindow(window).then(function() resolve());
}
else {
// Here we assuming that the most recent browser window is the one we're
// doing the test, and the active tab is the one we just opened.
let tab = getActiveTab(getMostRecentBrowserWindow());
tab.addEventListener("unload", function unload (event) {
this.removeEventListener(event.type, unload);
console.log("unloaded: ", event.target);
})
closeTab(tab);
closeTab(getActiveTab(getMostRecentBrowserWindow()));
resolve();
}

return promise;
}

/**
Expand Down

0 comments on commit be0f704

Please sign in to comment.