1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_localfile2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +// ---------------------------------------------------------------------------- 1.5 +// Test whether an install fails if the url is a local file when requested from 1.6 +// web content 1.7 +function test() { 1.8 + waitForExplicitFinish(); 1.9 + 1.10 + var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"] 1.11 + .getService(Components.interfaces.nsIChromeRegistry); 1.12 + 1.13 + var chromeroot = getChromeRoot(gTestPath); 1.14 + try { 1.15 + var xpipath = cr.convertChromeURL(makeURI(chromeroot + "unsigned.xpi")).spec; 1.16 + } catch (ex) { 1.17 + var xpipath = chromeroot + "unsigned.xpi"; //scenario where we are running from a .jar and already extracted 1.18 + } 1.19 + 1.20 + var triggers = encodeURIComponent(JSON.stringify({ 1.21 + "Unsigned XPI": xpipath 1.22 + })); 1.23 + gBrowser.selectedTab = gBrowser.addTab(); 1.24 + gBrowser.selectedBrowser.addEventListener("load", function() { 1.25 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.26 + // Allow the in-page load handler to run first 1.27 + executeSoon(page_loaded); 1.28 + }, true); 1.29 + expectUncaughtException(); 1.30 + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); 1.31 +} 1.32 + 1.33 +function page_loaded() { 1.34 + var doc = gBrowser.contentDocument; 1.35 + is(doc.getElementById("return").textContent, "exception", "installTrigger should have failed"); 1.36 + gBrowser.removeCurrentTab(); 1.37 + finish(); 1.38 +} 1.39 +// ----------------------------------------------------------------------------