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

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:9b4e74379a5c
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();
6
7 var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
8 .getService(Components.interfaces.nsIChromeRegistry);
9
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 }
16
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 }
29
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