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 for bug 589598 - Ensure that installing through InstallTrigger
3 // works in an iframe in web content.
5 function test() {
6 Harness.installConfirmCallback = confirm_install;
7 Harness.installEndedCallback = install_ended;
8 Harness.installsCompletedCallback = finish_test;
9 Harness.setup();
11 var pm = Services.perms;
12 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
14 var triggers = encodeURIComponent(JSON.stringify({
15 "Unsigned XPI": {
16 URL: TESTROOT + "unsigned.xpi",
17 IconURL: TESTROOT + "icon.png",
18 toString: function() { return this.URL; }
19 }
20 }));
21 gBrowser.selectedTab = gBrowser.addTab();
22 gBrowser.loadURI(TESTROOT + "installtrigger_frame.html?" + triggers);
23 }
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");
29 is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item");
30 is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
31 is(items[0].signed, "false", "Should have listed the item as unsigned");
32 return true;
33 }
35 function install_ended(install, addon) {
36 install.cancel();
37 }
39 function finish_test(count) {
40 is(count, 1, "1 Add-on should have been successfully installed");
42 Services.perms.remove("example.com", "install");
44 var doc = gBrowser.contentWindow.frames[0].document; // Document of iframe
45 is(doc.getElementById("return").textContent, "true", "installTrigger in iframe should have claimed success");
46 is(doc.getElementById("status").textContent, "0", "Callback in iframe should have seen a success");
48 gBrowser.removeCurrentTab();
49 Harness.finish();
50 }