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.
1 // ----------------------------------------------------------------------------
2 // Test whether a request for auth for an XPI switches to the appropriate tab
3 var gNewTab;
5 function test() {
6 Harness.authenticationCallback = get_auth_info;
7 Harness.downloadFailedCallback = download_failed;
8 Harness.installEndedCallback = install_ended;
9 Harness.installsCompletedCallback = finish_test;
10 Harness.setup();
12 var pm = Services.perms;
13 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
15 var triggers = encodeURIComponent(JSON.stringify({
16 "Unsigned XPI": TESTROOT + "authRedirect.sjs?" + TESTROOT + "unsigned.xpi"
17 }));
18 gNewTab = gBrowser.addTab();
19 gBrowser.getBrowserForTab(gNewTab).loadURI(TESTROOT + "installtrigger.html?" + triggers);
20 }
22 function get_auth_info() {
23 is(gBrowser.selectedTab, gNewTab, "Should have focused the tab loading the XPI");
24 return [ "testuser", "testpass" ];
25 }
27 function download_failed(install) {
28 ok(false, "Install should not have failed");
29 }
31 function install_ended(install, addon) {
32 install.cancel();
33 }
35 function finish_test(count) {
36 is(count, 1, "1 Add-on should have been successfully installed");
37 var authMgr = Components.classes['@mozilla.org/network/http-auth-manager;1']
38 .getService(Components.interfaces.nsIHttpAuthManager);
39 authMgr.clearAll();
41 Services.perms.remove("example.com", "install");
43 gBrowser.removeTab(gNewTab);
44 Harness.finish();
45 }