|
1 // ---------------------------------------------------------------------------- |
|
2 // Test whether an InstallTrigger.install call fails when xpinstall is disabled |
|
3 function test() { |
|
4 Harness.installDisabledCallback = install_disabled; |
|
5 Harness.installBlockedCallback = allow_blocked; |
|
6 Harness.installConfirmCallback = confirm_install; |
|
7 Harness.setup(); |
|
8 |
|
9 Services.prefs.setBoolPref("xpinstall.enabled", false); |
|
10 |
|
11 var triggers = encodeURIComponent(JSON.stringify({ |
|
12 "Unsigned XPI": TESTROOT + "unsigned.xpi" |
|
13 })); |
|
14 gBrowser.selectedTab = gBrowser.addTab(); |
|
15 gBrowser.selectedBrowser.addEventListener("load", function() { |
|
16 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
|
17 // Allow the in-page load handler to run first |
|
18 executeSoon(page_loaded); |
|
19 }, true); |
|
20 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
|
21 } |
|
22 |
|
23 function install_disabled(installInfo) { |
|
24 ok(true, "Saw installation disabled"); |
|
25 } |
|
26 |
|
27 function allow_blocked(installInfo) { |
|
28 ok(false, "Should never see the blocked install notification"); |
|
29 return false; |
|
30 } |
|
31 |
|
32 function confirm_install(window) { |
|
33 ok(false, "Should never see an install confirmation dialog"); |
|
34 return false; |
|
35 } |
|
36 |
|
37 function page_loaded() { |
|
38 Services.prefs.clearUserPref("xpinstall.enabled"); |
|
39 |
|
40 var doc = gBrowser.contentDocument; |
|
41 is(doc.getElementById("return").textContent, "false", "installTrigger should have not been enabled"); |
|
42 gBrowser.removeCurrentTab(); |
|
43 Harness.finish(); |
|
44 } |
|
45 // ---------------------------------------------------------------------------- |