Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | function test() { |
michael@0 | 6 | // This test takes quite some time, and timeouts frequently, so we require |
michael@0 | 7 | // more time to run. |
michael@0 | 8 | // See Bug 518970. |
michael@0 | 9 | requestLongerTimeout(2); |
michael@0 | 10 | |
michael@0 | 11 | waitForExplicitFinish(); |
michael@0 | 12 | |
michael@0 | 13 | // helper function that does the actual testing |
michael@0 | 14 | function openWindowRec(windowsToOpen, expectedResults, recCallback) { |
michael@0 | 15 | // do actual checking |
michael@0 | 16 | if (!windowsToOpen.length) { |
michael@0 | 17 | let closedWindowData = JSON.parse(ss.getClosedWindowData()); |
michael@0 | 18 | let numPopups = closedWindowData.filter(function(el, i, arr) { |
michael@0 | 19 | return el.isPopup; |
michael@0 | 20 | }).length; |
michael@0 | 21 | let numNormal = ss.getClosedWindowCount() - numPopups; |
michael@0 | 22 | // #ifdef doesn't work in browser-chrome tests, so do a simple regex on platform |
michael@0 | 23 | let oResults = navigator.platform.match(/Mac/) ? expectedResults.mac |
michael@0 | 24 | : expectedResults.other; |
michael@0 | 25 | is(numPopups, oResults.popup, |
michael@0 | 26 | "There were " + oResults.popup + " popup windows to repoen"); |
michael@0 | 27 | is(numNormal, oResults.normal, |
michael@0 | 28 | "There were " + oResults.normal + " normal windows to repoen"); |
michael@0 | 29 | |
michael@0 | 30 | // cleanup & return |
michael@0 | 31 | executeSoon(recCallback); |
michael@0 | 32 | return; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | // hack to force window to be considered a popup (toolbar=no didn't work) |
michael@0 | 36 | let winData = windowsToOpen.shift(); |
michael@0 | 37 | let settings = "chrome,dialog=no," + |
michael@0 | 38 | (winData.isPopup ? "all=no" : "all"); |
michael@0 | 39 | let url = "http://example.com/?window=" + windowsToOpen.length; |
michael@0 | 40 | |
michael@0 | 41 | provideWindow(function onTestURLLoaded(win) { |
michael@0 | 42 | win.close(); |
michael@0 | 43 | // Give it time to close |
michael@0 | 44 | executeSoon(function() { |
michael@0 | 45 | openWindowRec(windowsToOpen, expectedResults, recCallback); |
michael@0 | 46 | }); |
michael@0 | 47 | }, url, settings); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | let windowsToOpen = [{isPopup: false}, |
michael@0 | 51 | {isPopup: false}, |
michael@0 | 52 | {isPopup: true}, |
michael@0 | 53 | {isPopup: true}, |
michael@0 | 54 | {isPopup: true}]; |
michael@0 | 55 | let expectedResults = {mac: {popup: 3, normal: 0}, |
michael@0 | 56 | other: {popup: 3, normal: 1}}; |
michael@0 | 57 | let windowsToOpen2 = [{isPopup: false}, |
michael@0 | 58 | {isPopup: false}, |
michael@0 | 59 | {isPopup: false}, |
michael@0 | 60 | {isPopup: false}, |
michael@0 | 61 | {isPopup: false}]; |
michael@0 | 62 | let expectedResults2 = {mac: {popup: 0, normal: 3}, |
michael@0 | 63 | other: {popup: 0, normal: 3}}; |
michael@0 | 64 | openWindowRec(windowsToOpen, expectedResults, function() { |
michael@0 | 65 | openWindowRec(windowsToOpen2, expectedResults2, finish); |
michael@0 | 66 | }); |
michael@0 | 67 | } |