michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: // This test takes quite some time, and timeouts frequently, so we require michael@0: // more time to run. michael@0: // See Bug 518970. michael@0: requestLongerTimeout(2); michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: // helper function that does the actual testing michael@0: function openWindowRec(windowsToOpen, expectedResults, recCallback) { michael@0: // do actual checking michael@0: if (!windowsToOpen.length) { michael@0: let closedWindowData = JSON.parse(ss.getClosedWindowData()); michael@0: let numPopups = closedWindowData.filter(function(el, i, arr) { michael@0: return el.isPopup; michael@0: }).length; michael@0: let numNormal = ss.getClosedWindowCount() - numPopups; michael@0: // #ifdef doesn't work in browser-chrome tests, so do a simple regex on platform michael@0: let oResults = navigator.platform.match(/Mac/) ? expectedResults.mac michael@0: : expectedResults.other; michael@0: is(numPopups, oResults.popup, michael@0: "There were " + oResults.popup + " popup windows to repoen"); michael@0: is(numNormal, oResults.normal, michael@0: "There were " + oResults.normal + " normal windows to repoen"); michael@0: michael@0: // cleanup & return michael@0: executeSoon(recCallback); michael@0: return; michael@0: } michael@0: michael@0: // hack to force window to be considered a popup (toolbar=no didn't work) michael@0: let winData = windowsToOpen.shift(); michael@0: let settings = "chrome,dialog=no," + michael@0: (winData.isPopup ? "all=no" : "all"); michael@0: let url = "http://example.com/?window=" + windowsToOpen.length; michael@0: michael@0: provideWindow(function onTestURLLoaded(win) { michael@0: win.close(); michael@0: // Give it time to close michael@0: executeSoon(function() { michael@0: openWindowRec(windowsToOpen, expectedResults, recCallback); michael@0: }); michael@0: }, url, settings); michael@0: } michael@0: michael@0: let windowsToOpen = [{isPopup: false}, michael@0: {isPopup: false}, michael@0: {isPopup: true}, michael@0: {isPopup: true}, michael@0: {isPopup: true}]; michael@0: let expectedResults = {mac: {popup: 3, normal: 0}, michael@0: other: {popup: 3, normal: 1}}; michael@0: let windowsToOpen2 = [{isPopup: false}, michael@0: {isPopup: false}, michael@0: {isPopup: false}, michael@0: {isPopup: false}, michael@0: {isPopup: false}]; michael@0: let expectedResults2 = {mac: {popup: 0, normal: 3}, michael@0: other: {popup: 0, normal: 3}}; michael@0: openWindowRec(windowsToOpen, expectedResults, function() { michael@0: openWindowRec(windowsToOpen2, expectedResults2, finish); michael@0: }); michael@0: }