Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | function test() { |
michael@0 | 6 | waitForExplicitFinish(); |
michael@0 | 7 | |
michael@0 | 8 | // avoid prompting about phishing |
michael@0 | 9 | Services.prefs.setIntPref(phishyUserPassPref, 32); |
michael@0 | 10 | registerCleanupFunction(function () { |
michael@0 | 11 | Services.prefs.clearUserPref(phishyUserPassPref); |
michael@0 | 12 | }); |
michael@0 | 13 | |
michael@0 | 14 | nextTest(); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | const phishyUserPassPref = "network.http.phishy-userpass-length"; |
michael@0 | 18 | |
michael@0 | 19 | function nextTest() { |
michael@0 | 20 | let test = tests.shift(); |
michael@0 | 21 | if (test) { |
michael@0 | 22 | test(function () { |
michael@0 | 23 | executeSoon(nextTest); |
michael@0 | 24 | }); |
michael@0 | 25 | } else { |
michael@0 | 26 | executeSoon(finish); |
michael@0 | 27 | } |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | let tests = [ |
michael@0 | 31 | function revert(next) { |
michael@0 | 32 | loadTabInWindow(window, function (tab) { |
michael@0 | 33 | gURLBar.handleRevert(); |
michael@0 | 34 | is(gURLBar.value, "example.com", "URL bar had user/pass stripped after reverting"); |
michael@0 | 35 | gBrowser.removeTab(tab); |
michael@0 | 36 | next(); |
michael@0 | 37 | }); |
michael@0 | 38 | }, |
michael@0 | 39 | function customize(next) { |
michael@0 | 40 | whenNewWindowLoaded(undefined, function (win) { |
michael@0 | 41 | // Need to wait for delayedStartup for the customization part of the test, |
michael@0 | 42 | // since that's where BrowserToolboxCustomizeDone is set. |
michael@0 | 43 | whenDelayedStartupFinished(win, function () { |
michael@0 | 44 | loadTabInWindow(win, function () { |
michael@0 | 45 | openToolbarCustomizationUI(function () { |
michael@0 | 46 | closeToolbarCustomizationUI(function () { |
michael@0 | 47 | is(win.gURLBar.value, "example.com", "URL bar had user/pass stripped after customize"); |
michael@0 | 48 | win.close(); |
michael@0 | 49 | next(); |
michael@0 | 50 | }, win); |
michael@0 | 51 | }, win); |
michael@0 | 52 | }); |
michael@0 | 53 | }); |
michael@0 | 54 | }); |
michael@0 | 55 | }, |
michael@0 | 56 | function pageloaderror(next) { |
michael@0 | 57 | loadTabInWindow(window, function (tab) { |
michael@0 | 58 | // Load a new URL and then immediately stop it, to simulate a page load |
michael@0 | 59 | // error. |
michael@0 | 60 | tab.linkedBrowser.loadURI("http://test1.example.com"); |
michael@0 | 61 | tab.linkedBrowser.stop(); |
michael@0 | 62 | is(gURLBar.value, "example.com", "URL bar had user/pass stripped after load error"); |
michael@0 | 63 | gBrowser.removeTab(tab); |
michael@0 | 64 | next(); |
michael@0 | 65 | }); |
michael@0 | 66 | } |
michael@0 | 67 | ]; |
michael@0 | 68 | |
michael@0 | 69 | function loadTabInWindow(win, callback) { |
michael@0 | 70 | info("Loading tab"); |
michael@0 | 71 | let url = "http://user:pass@example.com/"; |
michael@0 | 72 | let tab = win.gBrowser.selectedTab = win.gBrowser.addTab(url); |
michael@0 | 73 | tab.linkedBrowser.addEventListener("load", function listener() { |
michael@0 | 74 | info("Tab loaded"); |
michael@0 | 75 | if (tab.linkedBrowser.currentURI.spec != url) |
michael@0 | 76 | return; |
michael@0 | 77 | tab.linkedBrowser.removeEventListener("load", listener, true); |
michael@0 | 78 | |
michael@0 | 79 | is(win.gURLBar.value, "example.com", "URL bar had user/pass stripped initially"); |
michael@0 | 80 | callback(tab); |
michael@0 | 81 | }, true); |
michael@0 | 82 | } |