browser/base/content/test/general/browser_private_browsing_window.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Make sure that we can open private browsing windows
     3 function test() {
     4   waitForExplicitFinish();
     5   var nonPrivateWin = OpenBrowserWindow();
     6   ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow() should open a normal window");
     7   nonPrivateWin.close();
     9   var privateWin = OpenBrowserWindow({private: true});
    10   ok(PrivateBrowsingUtils.isWindowPrivate(privateWin), "OpenBrowserWindow({private: true}) should open a private window");
    12   nonPrivateWin = OpenBrowserWindow({private: false});
    13   ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "OpenBrowserWindow({private: false}) should open a normal window");
    14   nonPrivateWin.close();
    16   whenDelayedStartupFinished(privateWin, function() {
    17     nonPrivateWin = privateWin.OpenBrowserWindow({private: false});
    18     ok(!PrivateBrowsingUtils.isWindowPrivate(nonPrivateWin), "privateWin.OpenBrowserWindow({private: false}) should open a normal window");
    20     nonPrivateWin.close();
    22     [
    23       { normal: "menu_newNavigator", private: "menu_newPrivateWindow", accesskey: true },
    24       { normal: "appmenu_newNavigator", private: "appmenu_newPrivateWindow", accesskey: false },
    25     ].forEach(function(menu) {
    26       let newWindow = privateWin.document.getElementById(menu.normal);
    27       let newPrivateWindow = privateWin.document.getElementById(menu.private);
    28       if (newWindow && newPrivateWindow) {
    29         ok(!newPrivateWindow.hidden, "New Private Window menu item should be hidden");
    30         isnot(newWindow.label, newPrivateWindow.label, "New Window's label shouldn't be overwritten");
    31         if (menu.accesskey) {
    32           isnot(newWindow.accessKey, newPrivateWindow.accessKey, "New Window's accessKey shouldn't be overwritten");
    33         }
    34         isnot(newWindow.command, newPrivateWindow.command, "New Window's command shouldn't be overwritten");
    35       }
    36     });
    38     privateWin.close();
    40     Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true);
    41     privateWin = OpenBrowserWindow({private: true});
    42     whenDelayedStartupFinished(privateWin, function() {
    43       [
    44         { normal: "menu_newNavigator", private: "menu_newPrivateWindow", accessKey: true },
    45         { normal: "appmenu_newNavigator", private: "appmenu_newPrivateWindow", accessKey: false },
    46       ].forEach(function(menu) {
    47         let newWindow = privateWin.document.getElementById(menu.normal);
    48         let newPrivateWindow = privateWin.document.getElementById(menu.private);
    49         if (newWindow && newPrivateWindow) {
    50           ok(newPrivateWindow.hidden, "New Private Window menu item should be hidden");
    51           is(newWindow.label, newPrivateWindow.label, "New Window's label should be overwritten");
    52           if (menu.accesskey) {
    53             is(newWindow.accessKey, newPrivateWindow.accessKey, "New Window's accessKey should be overwritten");
    54           }
    55           is(newWindow.command, newPrivateWindow.command, "New Window's command should be overwritten");
    56         }
    57       });
    59       privateWin.close();
    60       Services.prefs.clearUserPref("browser.privatebrowsing.autostart");
    61       finish();
    62     });
    63   });
    64 }

mercurial