michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: // avoid prompting about phishing michael@0: Services.prefs.setIntPref(phishyUserPassPref, 32); michael@0: registerCleanupFunction(function () { michael@0: Services.prefs.clearUserPref(phishyUserPassPref); michael@0: }); michael@0: michael@0: nextTest(); michael@0: } michael@0: michael@0: const phishyUserPassPref = "network.http.phishy-userpass-length"; michael@0: michael@0: function nextTest() { michael@0: let test = tests.shift(); michael@0: if (test) { michael@0: test(function () { michael@0: executeSoon(nextTest); michael@0: }); michael@0: } else { michael@0: executeSoon(finish); michael@0: } michael@0: } michael@0: michael@0: let tests = [ michael@0: function revert(next) { michael@0: loadTabInWindow(window, function (tab) { michael@0: gURLBar.handleRevert(); michael@0: is(gURLBar.value, "example.com", "URL bar had user/pass stripped after reverting"); michael@0: gBrowser.removeTab(tab); michael@0: next(); michael@0: }); michael@0: }, michael@0: function customize(next) { michael@0: whenNewWindowLoaded(undefined, function (win) { michael@0: // Need to wait for delayedStartup for the customization part of the test, michael@0: // since that's where BrowserToolboxCustomizeDone is set. michael@0: whenDelayedStartupFinished(win, function () { michael@0: loadTabInWindow(win, function () { michael@0: openToolbarCustomizationUI(function () { michael@0: closeToolbarCustomizationUI(function () { michael@0: is(win.gURLBar.value, "example.com", "URL bar had user/pass stripped after customize"); michael@0: win.close(); michael@0: next(); michael@0: }, win); michael@0: }, win); michael@0: }); michael@0: }); michael@0: }); michael@0: }, michael@0: function pageloaderror(next) { michael@0: loadTabInWindow(window, function (tab) { michael@0: // Load a new URL and then immediately stop it, to simulate a page load michael@0: // error. michael@0: tab.linkedBrowser.loadURI("http://test1.example.com"); michael@0: tab.linkedBrowser.stop(); michael@0: is(gURLBar.value, "example.com", "URL bar had user/pass stripped after load error"); michael@0: gBrowser.removeTab(tab); michael@0: next(); michael@0: }); michael@0: } michael@0: ]; michael@0: michael@0: function loadTabInWindow(win, callback) { michael@0: info("Loading tab"); michael@0: let url = "http://user:pass@example.com/"; michael@0: let tab = win.gBrowser.selectedTab = win.gBrowser.addTab(url); michael@0: tab.linkedBrowser.addEventListener("load", function listener() { michael@0: info("Tab loaded"); michael@0: if (tab.linkedBrowser.currentURI.spec != url) michael@0: return; michael@0: tab.linkedBrowser.removeEventListener("load", listener, true); michael@0: michael@0: is(win.gURLBar.value, "example.com", "URL bar had user/pass stripped initially"); michael@0: callback(tab); michael@0: }, true); michael@0: }