browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js

Thu, 15 Jan 2015 21:13:52 +0100

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

Remove forgotten relic of ABI crash risk averse overloaded method change.

     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 // This test makes sure that the window title changes correctly while switching
     6 // from and to private browsing mode.
     8 function test() {
     9   const testPageURL = "http://mochi.test:8888/browser/" +
    10     "browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle_page.html";
    11   waitForExplicitFinish();
    12   requestLongerTimeout(2);
    14   // initialization of expected titles
    15   let test_title = "Test title";
    16   let app_name = document.documentElement.getAttribute("title");
    17   const isOSX = ("nsILocalFileMac" in Ci);
    18   let page_with_title;
    19   let page_without_title;
    20   let about_pb_title;
    21   let pb_page_with_title;
    22   let pb_page_without_title;
    23   let pb_about_pb_title;
    24   if (isOSX) {
    25     page_with_title = test_title;
    26     page_without_title = app_name;
    27     about_pb_title = "Would you like to start Private Browsing?";
    28     pb_page_with_title = test_title + " - (Private Browsing)";
    29     pb_page_without_title = app_name + " - (Private Browsing)";
    30     pb_about_pb_title = pb_page_without_title;
    31   }
    32   else {
    33     page_with_title = test_title + " - " + app_name;
    34     page_without_title = app_name;
    35     about_pb_title = "Would you like to start Private Browsing?" + " - " + app_name;
    36     pb_page_with_title = test_title + " - " + app_name + " (Private Browsing)";
    37     pb_page_without_title = app_name + " (Private Browsing)";
    38     pb_about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)";
    39   }
    41   function testTabTitle(aWindow, url, insidePB, expected_title, funcNext) {
    42     executeSoon(function () {
    43       let tab = aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab();
    44       let browser = aWindow.gBrowser.selectedBrowser;
    45       browser.stop();
    46       // ensure that the test is run after the titlebar has been updated
    47       browser.addEventListener("load", function () {
    48         browser.removeEventListener("load", arguments.callee, true);
    49         executeSoon(function () {
    50           if (aWindow.document.title != expected_title) {
    51             executeSoon(arguments.callee);
    52             return;
    53           }
    54           is(aWindow.document.title, expected_title, "The window title for " + url +
    55              " is correct (" + (insidePB ? "inside" : "outside") +
    56              " private browsing mode)");
    58           let win = aWindow.gBrowser.replaceTabWithWindow(tab);
    59           win.addEventListener("load", function() {
    60             win.removeEventListener("load", arguments.callee, false);
    61             executeSoon(function() {
    62               if (win.document.title != expected_title) {
    63                 executeSoon(arguments.callee);
    64                 return;
    65               }
    66               is(win.document.title, expected_title, "The window title for " + url +
    67                  " detached tab is correct (" + (insidePB ? "inside" : "outside") +
    68                  " private browsing mode)");
    69               win.close();
    70               aWindow.close();
    72               setTimeout(funcNext, 0);
    73             });
    74           }, false);
    75         });
    76       }, true);
    78       browser.loadURI(url);
    79     });
    80   }
    82   whenNewWindowLoaded({private: false}, function(win) {
    83     testTabTitle(win, "about:blank", false, page_without_title, function() {
    84       whenNewWindowLoaded({private: false}, function(win) {
    85         testTabTitle(win, testPageURL, false, page_with_title, function() {
    86           whenNewWindowLoaded({private: false}, function(win) {
    87             testTabTitle(win, "about:privatebrowsing", false, about_pb_title, function() {
    88               whenNewWindowLoaded({private: true}, function(win) {
    89                 testTabTitle(win, "about:blank", true, pb_page_without_title, function() {
    90                   whenNewWindowLoaded({private: true}, function(win) {
    91                     testTabTitle(win, testPageURL, true, pb_page_with_title, function() {
    92                       whenNewWindowLoaded({private: true}, function(win) {
    93                         testTabTitle(win, "about:privatebrowsing", true, pb_about_pb_title, finish);
    94                       });
    95                     });
    96                   });
    97                 });
    98               });
    99             });
   100           });
   101         });
   102       });
   103     });
   104   });
   105   return;
   106 }

mercurial