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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // ----------------------------------------------------------------------------
     2 // Test whether an install fails if the url is a local file when requested from
     3 // web content
     4 function test() {
     5   waitForExplicitFinish();
     7   var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
     8                      .getService(Components.interfaces.nsIChromeRegistry);
    10   var chromeroot = getChromeRoot(gTestPath);              
    11   try {
    12     var xpipath = cr.convertChromeURL(makeURI(chromeroot + "unsigned.xpi")).spec;
    13   } catch (ex) {
    14     var xpipath = chromeroot + "unsigned.xpi"; //scenario where we are running from a .jar and already extracted
    15   }
    17   var triggers = encodeURIComponent(JSON.stringify({
    18     "Unsigned XPI": xpipath
    19   }));
    20   gBrowser.selectedTab = gBrowser.addTab();
    21   gBrowser.selectedBrowser.addEventListener("load", function() {
    22     gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
    23     // Allow the in-page load handler to run first
    24     executeSoon(page_loaded);
    25   }, true);
    26   expectUncaughtException();
    27   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
    28 }
    30 function page_loaded() {
    31   var doc = gBrowser.contentDocument;
    32   is(doc.getElementById("return").textContent, "exception", "installTrigger should have failed");
    33   gBrowser.removeCurrentTab();
    34   finish();
    35 }
    36 // ----------------------------------------------------------------------------

mercurial