Thu, 15 Jan 2015 21:13:52 +0100
Remove forgotten relic of ABI crash risk averse overloaded method change.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | // This test makes sure that the window title changes correctly while switching |
michael@0 | 6 | // from and to private browsing mode. |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | const testPageURL = "http://mochi.test:8888/browser/" + |
michael@0 | 10 | "browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle_page.html"; |
michael@0 | 11 | waitForExplicitFinish(); |
michael@0 | 12 | requestLongerTimeout(2); |
michael@0 | 13 | |
michael@0 | 14 | // initialization of expected titles |
michael@0 | 15 | let test_title = "Test title"; |
michael@0 | 16 | let app_name = document.documentElement.getAttribute("title"); |
michael@0 | 17 | const isOSX = ("nsILocalFileMac" in Ci); |
michael@0 | 18 | let page_with_title; |
michael@0 | 19 | let page_without_title; |
michael@0 | 20 | let about_pb_title; |
michael@0 | 21 | let pb_page_with_title; |
michael@0 | 22 | let pb_page_without_title; |
michael@0 | 23 | let pb_about_pb_title; |
michael@0 | 24 | if (isOSX) { |
michael@0 | 25 | page_with_title = test_title; |
michael@0 | 26 | page_without_title = app_name; |
michael@0 | 27 | about_pb_title = "Would you like to start Private Browsing?"; |
michael@0 | 28 | pb_page_with_title = test_title + " - (Private Browsing)"; |
michael@0 | 29 | pb_page_without_title = app_name + " - (Private Browsing)"; |
michael@0 | 30 | pb_about_pb_title = pb_page_without_title; |
michael@0 | 31 | } |
michael@0 | 32 | else { |
michael@0 | 33 | page_with_title = test_title + " - " + app_name; |
michael@0 | 34 | page_without_title = app_name; |
michael@0 | 35 | about_pb_title = "Would you like to start Private Browsing?" + " - " + app_name; |
michael@0 | 36 | pb_page_with_title = test_title + " - " + app_name + " (Private Browsing)"; |
michael@0 | 37 | pb_page_without_title = app_name + " (Private Browsing)"; |
michael@0 | 38 | pb_about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)"; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function testTabTitle(aWindow, url, insidePB, expected_title, funcNext) { |
michael@0 | 42 | executeSoon(function () { |
michael@0 | 43 | let tab = aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab(); |
michael@0 | 44 | let browser = aWindow.gBrowser.selectedBrowser; |
michael@0 | 45 | browser.stop(); |
michael@0 | 46 | // ensure that the test is run after the titlebar has been updated |
michael@0 | 47 | browser.addEventListener("load", function () { |
michael@0 | 48 | browser.removeEventListener("load", arguments.callee, true); |
michael@0 | 49 | executeSoon(function () { |
michael@0 | 50 | if (aWindow.document.title != expected_title) { |
michael@0 | 51 | executeSoon(arguments.callee); |
michael@0 | 52 | return; |
michael@0 | 53 | } |
michael@0 | 54 | is(aWindow.document.title, expected_title, "The window title for " + url + |
michael@0 | 55 | " is correct (" + (insidePB ? "inside" : "outside") + |
michael@0 | 56 | " private browsing mode)"); |
michael@0 | 57 | |
michael@0 | 58 | let win = aWindow.gBrowser.replaceTabWithWindow(tab); |
michael@0 | 59 | win.addEventListener("load", function() { |
michael@0 | 60 | win.removeEventListener("load", arguments.callee, false); |
michael@0 | 61 | executeSoon(function() { |
michael@0 | 62 | if (win.document.title != expected_title) { |
michael@0 | 63 | executeSoon(arguments.callee); |
michael@0 | 64 | return; |
michael@0 | 65 | } |
michael@0 | 66 | is(win.document.title, expected_title, "The window title for " + url + |
michael@0 | 67 | " detached tab is correct (" + (insidePB ? "inside" : "outside") + |
michael@0 | 68 | " private browsing mode)"); |
michael@0 | 69 | win.close(); |
michael@0 | 70 | aWindow.close(); |
michael@0 | 71 | |
michael@0 | 72 | setTimeout(funcNext, 0); |
michael@0 | 73 | }); |
michael@0 | 74 | }, false); |
michael@0 | 75 | }); |
michael@0 | 76 | }, true); |
michael@0 | 77 | |
michael@0 | 78 | browser.loadURI(url); |
michael@0 | 79 | }); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | whenNewWindowLoaded({private: false}, function(win) { |
michael@0 | 83 | testTabTitle(win, "about:blank", false, page_without_title, function() { |
michael@0 | 84 | whenNewWindowLoaded({private: false}, function(win) { |
michael@0 | 85 | testTabTitle(win, testPageURL, false, page_with_title, function() { |
michael@0 | 86 | whenNewWindowLoaded({private: false}, function(win) { |
michael@0 | 87 | testTabTitle(win, "about:privatebrowsing", false, about_pb_title, function() { |
michael@0 | 88 | whenNewWindowLoaded({private: true}, function(win) { |
michael@0 | 89 | testTabTitle(win, "about:blank", true, pb_page_without_title, function() { |
michael@0 | 90 | whenNewWindowLoaded({private: true}, function(win) { |
michael@0 | 91 | testTabTitle(win, testPageURL, true, pb_page_with_title, function() { |
michael@0 | 92 | whenNewWindowLoaded({private: true}, function(win) { |
michael@0 | 93 | testTabTitle(win, "about:privatebrowsing", true, pb_about_pb_title, finish); |
michael@0 | 94 | }); |
michael@0 | 95 | }); |
michael@0 | 96 | }); |
michael@0 | 97 | }); |
michael@0 | 98 | }); |
michael@0 | 99 | }); |
michael@0 | 100 | }); |
michael@0 | 101 | }); |
michael@0 | 102 | }); |
michael@0 | 103 | }); |
michael@0 | 104 | }); |
michael@0 | 105 | return; |
michael@0 | 106 | } |