browser/components/sessionstore/test/browser_394759_behavior.js

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

mercurial