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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // ----------------------------------------------------------------------------
     2 // Tests that InstallTrigger deals with relative urls correctly.
     3 function test() {
     4   Harness.installConfirmCallback = confirm_install;
     5   Harness.installEndedCallback = install_ended;
     6   Harness.installsCompletedCallback = finish_test;
     7   Harness.setup();
     9   var pm = Services.perms;
    10   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
    12   var triggers = encodeURIComponent(JSON.stringify({
    13     "Unsigned XPI": {
    14       URL: "unsigned.xpi",
    15       IconURL: "icon.png",
    16       toString: function() { return this.URL; }
    17     }
    18   }));
    19   gBrowser.selectedTab = gBrowser.addTab();
    20   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
    21 }
    23 function confirm_install(window) {
    24   var items = window.document.getElementById("itemList").childNodes;
    25   is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
    26   is(items[0].name, "XPI Test", "Should have seen the name");
    27   is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item");
    28   is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
    29   is(items[0].signed, "false", "Should have listed the item as unsigned");
    30   return true;
    31 }
    33 function install_ended(install, addon) {
    34   install.cancel();
    35 }
    37 function finish_test(count) {
    38   is(count, 1, "1 Add-on should have been successfully installed");
    40   Services.perms.remove("example.com", "install");
    42   var doc = gBrowser.contentDocument;
    43   is(doc.getElementById("return").textContent, "true", "installTrigger should have claimed success");
    44   is(doc.getElementById("status").textContent, "0", "Callback should have seen a success");
    46   gBrowser.removeCurrentTab();
    47   Harness.finish();
    48 }

mercurial