browser/components/sessionstore/test/browser_394759_behavior.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     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);
    11   waitForExplicitFinish();
    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");
    30       // cleanup & return
    31       executeSoon(recCallback);
    32       return;
    33     }
    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;
    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   }
    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