toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:c6dd2bc37ca8
1 // ----------------------------------------------------------------------------
2 // Tests installing an unsigned add-on through an InstallTrigger call in web
3 // content. This should be blocked by the whitelist check.
4 // This verifies bug 252830
5 function test() {
6 Harness.installConfirmCallback = confirm_install;
7 Harness.installBlockedCallback = allow_blocked;
8 Harness.installEndedCallback = install_ended;
9 Harness.installsCompletedCallback = finish_test;
10 Harness.setup();
11
12 var triggers = encodeURIComponent(JSON.stringify({
13 "Unsigned XPI": TESTROOT + "unsigned.xpi"
14 }));
15 gBrowser.selectedTab = gBrowser.addTab();
16 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
17 }
18
19 function allow_blocked(installInfo) {
20 is(installInfo.originatingWindow, gBrowser.contentWindow, "Install should have been triggered by the right window");
21 is(installInfo.originatingURI.spec, gBrowser.currentURI.spec, "Install should have been triggered by the right uri");
22 return true;
23 }
24
25 function confirm_install(window) {
26 var items = window.document.getElementById("itemList").childNodes;
27 is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
28 is(items[0].name, "XPI Test", "Should have seen the name from the trigger list");
29 is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item");
30 is(items[0].signed, "false", "Should have listed the item as unsigned");
31 return true;
32 }
33
34 function install_ended(install, addon) {
35 install.cancel();
36 }
37
38 function finish_test(count) {
39 is(count, 1, "1 Add-on should have been successfully installed");
40
41 var doc = gBrowser.contentDocument;
42 is(doc.getElementById("return").textContent, "false", "installTrigger should seen a failure");
43 gBrowser.removeCurrentTab();
44 Harness.finish();
45 }
46 // ----------------------------------------------------------------------------

mercurial