1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_394759_behavior.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function test() { 1.9 + // This test takes quite some time, and timeouts frequently, so we require 1.10 + // more time to run. 1.11 + // See Bug 518970. 1.12 + requestLongerTimeout(2); 1.13 + 1.14 + waitForExplicitFinish(); 1.15 + 1.16 + // helper function that does the actual testing 1.17 + function openWindowRec(windowsToOpen, expectedResults, recCallback) { 1.18 + // do actual checking 1.19 + if (!windowsToOpen.length) { 1.20 + let closedWindowData = JSON.parse(ss.getClosedWindowData()); 1.21 + let numPopups = closedWindowData.filter(function(el, i, arr) { 1.22 + return el.isPopup; 1.23 + }).length; 1.24 + let numNormal = ss.getClosedWindowCount() - numPopups; 1.25 + // #ifdef doesn't work in browser-chrome tests, so do a simple regex on platform 1.26 + let oResults = navigator.platform.match(/Mac/) ? expectedResults.mac 1.27 + : expectedResults.other; 1.28 + is(numPopups, oResults.popup, 1.29 + "There were " + oResults.popup + " popup windows to repoen"); 1.30 + is(numNormal, oResults.normal, 1.31 + "There were " + oResults.normal + " normal windows to repoen"); 1.32 + 1.33 + // cleanup & return 1.34 + executeSoon(recCallback); 1.35 + return; 1.36 + } 1.37 + 1.38 + // hack to force window to be considered a popup (toolbar=no didn't work) 1.39 + let winData = windowsToOpen.shift(); 1.40 + let settings = "chrome,dialog=no," + 1.41 + (winData.isPopup ? "all=no" : "all"); 1.42 + let url = "http://example.com/?window=" + windowsToOpen.length; 1.43 + 1.44 + provideWindow(function onTestURLLoaded(win) { 1.45 + win.close(); 1.46 + // Give it time to close 1.47 + executeSoon(function() { 1.48 + openWindowRec(windowsToOpen, expectedResults, recCallback); 1.49 + }); 1.50 + }, url, settings); 1.51 + } 1.52 + 1.53 + let windowsToOpen = [{isPopup: false}, 1.54 + {isPopup: false}, 1.55 + {isPopup: true}, 1.56 + {isPopup: true}, 1.57 + {isPopup: true}]; 1.58 + let expectedResults = {mac: {popup: 3, normal: 0}, 1.59 + other: {popup: 3, normal: 1}}; 1.60 + let windowsToOpen2 = [{isPopup: false}, 1.61 + {isPopup: false}, 1.62 + {isPopup: false}, 1.63 + {isPopup: false}, 1.64 + {isPopup: false}]; 1.65 + let expectedResults2 = {mac: {popup: 0, normal: 3}, 1.66 + other: {popup: 0, normal: 3}}; 1.67 + openWindowRec(windowsToOpen, expectedResults, function() { 1.68 + openWindowRec(windowsToOpen2, expectedResults2, finish); 1.69 + }); 1.70 +}