From 00547d373970a83da38f686540d2003593eaaf25 Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Thu, 12 Feb 2009 13:35:03 +0000 Subject: [PATCH] Bug 474763: Add automated tests for xpinstall. r=bsmedberg --- xpinstall/Makefile.in | 4 + xpinstall/tests/Makefile.in | 99 ++++++++ xpinstall/tests/authRedirect.sjs | 21 ++ xpinstall/tests/browser_auth.js | 50 ++++ xpinstall/tests/browser_auth2.js | 47 ++++ xpinstall/tests/browser_auth3.js | 47 ++++ xpinstall/tests/browser_badhash.js | 41 ++++ xpinstall/tests/browser_badhashtype.js | 41 ++++ xpinstall/tests/browser_cancel.js | 45 ++++ xpinstall/tests/browser_chrome.js | 45 ++++ xpinstall/tests/browser_cookies.js | 38 +++ xpinstall/tests/browser_cookies2.js | 51 ++++ xpinstall/tests/browser_cookies3.js | 59 +++++ xpinstall/tests/browser_cookies4.js | 56 +++++ xpinstall/tests/browser_corrupt.js | 39 +++ xpinstall/tests/browser_empty.js | 36 +++ xpinstall/tests/browser_enabled.js | 25 ++ xpinstall/tests/browser_enabled2.js | 33 +++ xpinstall/tests/browser_enabled3.js | 37 +++ xpinstall/tests/browser_hash.js | 45 ++++ xpinstall/tests/browser_installchrome.js | 37 +++ xpinstall/tests/browser_localfile.js | 33 +++ xpinstall/tests/browser_localfile2.js | 35 +++ xpinstall/tests/browser_navigateaway.js | 47 ++++ xpinstall/tests/browser_navigateaway2.js | 46 ++++ xpinstall/tests/browser_offline.js | 43 ++++ xpinstall/tests/browser_opendialog.js | 42 ++++ xpinstall/tests/browser_signed_multiple.js | 58 +++++ xpinstall/tests/browser_signed_tampered.js | 47 ++++ xpinstall/tests/browser_signed_trigger.js | 52 ++++ xpinstall/tests/browser_signed_untrusted.js | 48 ++++ xpinstall/tests/browser_signed_url.js | 40 +++ xpinstall/tests/browser_softwareupdate.js | 37 +++ xpinstall/tests/browser_unsigned_trigger.js | 60 +++++ xpinstall/tests/browser_unsigned_url.js | 40 +++ xpinstall/tests/browser_whitelist.js | 49 ++++ xpinstall/tests/browser_whitelist2.js | 38 +++ xpinstall/tests/browser_whitelist3.js | 37 +++ xpinstall/tests/browser_whitelist4.js | 37 +++ xpinstall/tests/browser_whitelist5.js | 27 ++ xpinstall/tests/browser_whitelist6.js | 27 ++ xpinstall/tests/cookieRedirect.sjs | 24 ++ xpinstall/tests/corrupt.xpi | 1 + xpinstall/tests/empty.xpi | Bin 0 -> 197 bytes xpinstall/tests/enabled.html | 20 ++ xpinstall/tests/harness.js | 257 ++++++++++++++++++++ xpinstall/tests/installchrome.html | 21 ++ xpinstall/tests/installtrigger.html | 32 +++ xpinstall/tests/signed-tampered.xpi | Bin 0 -> 2260 bytes xpinstall/tests/signed-untrusted.xpi | Bin 0 -> 2276 bytes xpinstall/tests/signed.xpi | Bin 0 -> 2250 bytes xpinstall/tests/signed2.xpi | Bin 0 -> 2938 bytes xpinstall/tests/startsoftwareupdate.html | 19 ++ xpinstall/tests/unsigned.xpi | Bin 0 -> 452 bytes 54 files changed, 2113 insertions(+) create mode 100644 xpinstall/tests/Makefile.in create mode 100644 xpinstall/tests/authRedirect.sjs create mode 100644 xpinstall/tests/browser_auth.js create mode 100644 xpinstall/tests/browser_auth2.js create mode 100644 xpinstall/tests/browser_auth3.js create mode 100644 xpinstall/tests/browser_badhash.js create mode 100644 xpinstall/tests/browser_badhashtype.js create mode 100644 xpinstall/tests/browser_cancel.js create mode 100644 xpinstall/tests/browser_chrome.js create mode 100644 xpinstall/tests/browser_cookies.js create mode 100644 xpinstall/tests/browser_cookies2.js create mode 100644 xpinstall/tests/browser_cookies3.js create mode 100644 xpinstall/tests/browser_cookies4.js create mode 100644 xpinstall/tests/browser_corrupt.js create mode 100644 xpinstall/tests/browser_empty.js create mode 100644 xpinstall/tests/browser_enabled.js create mode 100644 xpinstall/tests/browser_enabled2.js create mode 100644 xpinstall/tests/browser_enabled3.js create mode 100644 xpinstall/tests/browser_hash.js create mode 100644 xpinstall/tests/browser_installchrome.js create mode 100644 xpinstall/tests/browser_localfile.js create mode 100644 xpinstall/tests/browser_localfile2.js create mode 100644 xpinstall/tests/browser_navigateaway.js create mode 100644 xpinstall/tests/browser_navigateaway2.js create mode 100644 xpinstall/tests/browser_offline.js create mode 100644 xpinstall/tests/browser_opendialog.js create mode 100644 xpinstall/tests/browser_signed_multiple.js create mode 100644 xpinstall/tests/browser_signed_tampered.js create mode 100644 xpinstall/tests/browser_signed_trigger.js create mode 100644 xpinstall/tests/browser_signed_untrusted.js create mode 100644 xpinstall/tests/browser_signed_url.js create mode 100644 xpinstall/tests/browser_softwareupdate.js create mode 100644 xpinstall/tests/browser_unsigned_trigger.js create mode 100644 xpinstall/tests/browser_unsigned_url.js create mode 100644 xpinstall/tests/browser_whitelist.js create mode 100644 xpinstall/tests/browser_whitelist2.js create mode 100644 xpinstall/tests/browser_whitelist3.js create mode 100644 xpinstall/tests/browser_whitelist4.js create mode 100644 xpinstall/tests/browser_whitelist5.js create mode 100644 xpinstall/tests/browser_whitelist6.js create mode 100644 xpinstall/tests/cookieRedirect.sjs create mode 100644 xpinstall/tests/corrupt.xpi create mode 100644 xpinstall/tests/empty.xpi create mode 100644 xpinstall/tests/enabled.html create mode 100644 xpinstall/tests/harness.js create mode 100644 xpinstall/tests/installchrome.html create mode 100644 xpinstall/tests/installtrigger.html create mode 100644 xpinstall/tests/signed-tampered.xpi create mode 100644 xpinstall/tests/signed-untrusted.xpi create mode 100644 xpinstall/tests/signed.xpi create mode 100644 xpinstall/tests/signed2.xpi create mode 100644 xpinstall/tests/startsoftwareupdate.html create mode 100644 xpinstall/tests/unsigned.xpi diff --git a/xpinstall/Makefile.in b/xpinstall/Makefile.in index b721d286d019..c552df397933 100644 --- a/xpinstall/Makefile.in +++ b/xpinstall/Makefile.in @@ -50,4 +50,8 @@ include $(DEPTH)/config/autoconf.mk MODULE = xpinstall DIRS = public src +ifdef ENABLE_TESTS +DIRS += tests +endif + include $(topsrcdir)/config/rules.mk diff --git a/xpinstall/tests/Makefile.in b/xpinstall/tests/Makefile.in new file mode 100644 index 000000000000..7e147858bd1e --- /dev/null +++ b/xpinstall/tests/Makefile.in @@ -0,0 +1,99 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Mozilla Foundation. +# Portions created by the Initial Developer are Copyright (C) 2008 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +relativesrcdir = xpinstall/tests + +include $(DEPTH)/config/autoconf.mk +include $(topsrcdir)/config/rules.mk + +_BROWSER_FILES = harness.js \ + browser_unsigned_url.js \ + browser_unsigned_trigger.js \ + browser_whitelist.js \ + browser_whitelist2.js \ + browser_whitelist3.js \ + browser_whitelist4.js \ + browser_whitelist5.js \ + browser_whitelist6.js \ + browser_hash.js \ + browser_badhash.js \ + browser_badhashtype.js \ + browser_signed_url.js \ + browser_signed_trigger.js \ + browser_signed_untrusted.js \ + browser_signed_tampered.js \ + browser_signed_multiple.js \ + browser_empty.js \ + browser_corrupt.js \ + browser_cookies.js \ + browser_cookies2.js \ + browser_cookies3.js \ + browser_cookies4.js \ + browser_enabled.js \ + browser_enabled2.js \ + browser_enabled3.js \ + browser_softwareupdate.js \ + browser_installchrome.js \ + browser_opendialog.js \ + browser_localfile.js \ + browser_localfile2.js \ + browser_auth.js \ + browser_auth2.js \ + browser_auth3.js \ + browser_offline.js \ + browser_chrome.js \ + browser_cancel.js \ + unsigned.xpi \ + signed.xpi \ + signed2.xpi \ + signed-untrusted.xpi \ + signed-tampered.xpi \ + empty.xpi \ + corrupt.xpi \ + enabled.html \ + installtrigger.html \ + startsoftwareupdate.html \ + installchrome.html \ + authRedirect.sjs \ + cookieRedirect.sjs \ + $(NULL) + +libs:: $(_BROWSER_FILES) + $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir) diff --git a/xpinstall/tests/authRedirect.sjs b/xpinstall/tests/authRedirect.sjs new file mode 100644 index 000000000000..7d8a3bbfb556 --- /dev/null +++ b/xpinstall/tests/authRedirect.sjs @@ -0,0 +1,21 @@ +// Simple script redirects to the query part of the uri if the browser +// authenticates with username "testuser" password "testpass" + +function handleRequest(request, response) { + if (request.hasHeader("Authorization")) { + if (request.getHeader("Authorization") == "Basic dGVzdHVzZXI6dGVzdHBhc3M=") { + response.setStatusLine(request.httpVersion, 302, "Found"); + response.setHeader("Location", request.queryString); + response.write("See " + request.queryString); + } + else { + response.setStatusLine(request.httpVersion, 403, "Forbidden"); + response.write("Invalid credentials"); + } + } + else { + response.setStatusLine(request.httpVersion, 401, "Authentication required"); + response.setHeader("WWW-Authenticate", "basic realm=\"XPInstall\"", false); + response.write("Unauthenticed request"); + } +} diff --git a/xpinstall/tests/browser_auth.js b/xpinstall/tests/browser_auth.js new file mode 100644 index 000000000000..d1275830afc8 --- /dev/null +++ b/xpinstall/tests/browser_auth.js @@ -0,0 +1,50 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install succeeds when authentication is required +// This verifies bug 312473 +function test() { + Harness.authenticationCallback = get_auth_info; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT + "authRedirect.sjs?" + TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function get_auth_info() { + return [ "testuser", "testpass" ]; +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var authMgr = Components.classes['@mozilla.org/network/http-auth-manager;1'] + .getService(Components.interfaces.nsIHttpAuthManager); + authMgr.clearAll(); + + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_auth2.js b/xpinstall/tests/browser_auth2.js new file mode 100644 index 000000000000..c1a69673a53f --- /dev/null +++ b/xpinstall/tests/browser_auth2.js @@ -0,0 +1,47 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install fails when authentication is required and bad +// credentials are given +// This verifies bug 312473 +function test() { + Harness.authenticationCallback = get_auth_info; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT + "authRedirect.sjs?" + TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function get_auth_info() { + return [ "baduser", "badpass" ]; +} + +function check_xpi_install(addon, status) { + is(status, -228, "Install should fail"); +} + +function finish_test() { + var authMgr = Components.classes['@mozilla.org/network/http-auth-manager;1'] + .getService(Components.interfaces.nsIHttpAuthManager); + authMgr.clearAll(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_auth3.js b/xpinstall/tests/browser_auth3.js new file mode 100644 index 000000000000..010dc63da86f --- /dev/null +++ b/xpinstall/tests/browser_auth3.js @@ -0,0 +1,47 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install fails when authentication is required and it is +// canceled +// This verifies bug 312473 +function test() { + Harness.authenticationCallback = get_auth_info; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT + "authRedirect.sjs?" + TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function get_auth_info() { + return null; +} + +function check_xpi_install(addon, status) { + is(status, -228, "Install should fail"); +} + +function finish_test() { + var authMgr = Components.classes['@mozilla.org/network/http-auth-manager;1'] + .getService(Components.interfaces.nsIHttpAuthManager); + authMgr.clearAll(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_badhash.js b/xpinstall/tests/browser_badhash.js new file mode 100644 index 000000000000..d2d1d6a0d720 --- /dev/null +++ b/xpinstall/tests/browser_badhash.js @@ -0,0 +1,41 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install fails when an invalid hash is included +// This verifies bug 302284 +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": { + URL: TESTROOT + "unsigned.xpi", + Hash: "sha1:643b08418599ddbd1ea8a511c90696578fb844b9", + toString: function() { return this.URL; } + } + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, -261, "Install should fail"); +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_badhashtype.js b/xpinstall/tests/browser_badhashtype.js new file mode 100644 index 000000000000..fa4339c70deb --- /dev/null +++ b/xpinstall/tests/browser_badhashtype.js @@ -0,0 +1,41 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install fails when an unknown hash type is included +// This verifies bug 302284 +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": { + URL: TESTROOT + "unsigned.xpi", + Hash: "foo:3d0dc22e1f394e159b08aaf5f0f97de4d5c65f4f", + toString: function() { return this.URL; } + } + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, -261, "Install should fail"); +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_cancel.js b/xpinstall/tests/browser_cancel.js new file mode 100644 index 000000000000..1a6ef4a60258 --- /dev/null +++ b/xpinstall/tests/browser_cancel.js @@ -0,0 +1,45 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests that cancelling an in progress download works. +var gManager = null; + +function test() { + waitForExplicitFinish(); + gManager = Components.classes["@mozilla.org/xpinstall/install-manager;1"] + .createInstance(Components.interfaces.nsIXPInstallManager); + gManager.initManagerFromChrome([ TESTROOT + "unsigned.xpi" ], + 1, listener); +} + +function finish_test() { + finish(); +} + +var listener = { + onStateChange: function(index, state, value) { + is(index, 0, "There is only one download"); + if (state == Components.interfaces.nsIXPIProgressDialog.INSTALL_DONE) + is(value, -210, "Install should have been cancelled"); + else if (state == Components.interfaces.nsIXPIProgressDialog.DIALOG_CLOSE) + finish_test(); + }, + + onProgress: function(index, value, maxValue) { + is(index, 0, "There is only one download"); + gManager.QueryInterface(Components.interfaces.nsIObserver); + gManager.observe(null, "xpinstall-progress", "cancel"); + }, + + QueryInterface: function(iid) { + if (iid.equals(Components.interfaces.nsIXPIProgressDialog) || + iid.equals(Components.interfaces.nsISupports)) + return this; + + throw Components.results.NS_ERROR_NO_INTERFACE; + } +}; +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_chrome.js b/xpinstall/tests/browser_chrome.js new file mode 100644 index 000000000000..c23258c1f639 --- /dev/null +++ b/xpinstall/tests/browser_chrome.js @@ -0,0 +1,45 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests that starting a download from chrome works and bypasses the whitelist +function test() { + waitForExplicitFinish(); + var xpimgr = Components.classes["@mozilla.org/xpinstall/install-manager;1"] + .createInstance(Components.interfaces.nsIXPInstallManager); + xpimgr.initManagerFromChrome([ TESTROOT + "unsigned.xpi" ], + 1, listener); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + finish(); +} + +var listener = { + onStateChange: function(index, state, value) { + is(index, 0, "There is only one download"); + if (state == Components.interfaces.nsIXPIProgressDialog.INSTALL_DONE) + is(value, 0, "Install should have succeeded"); + else if (state == Components.interfaces.nsIXPIProgressDialog.DIALOG_CLOSE) + finish_test(); + }, + + onProgress: function(index, value, maxValue) { + is(index, 0, "There is only one download"); + }, + + QueryInterface: function(iid) { + if (iid.equals(Components.interfaces.nsIXPIProgressDialog) || + iid.equals(Components.interfaces.nsISupports)) + return this; + + throw Components.results.NS_ERROR_NO_INTERFACE; + } +}; +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_cookies.js b/xpinstall/tests/browser_cookies.js new file mode 100644 index 000000000000..5aa534f28c41 --- /dev/null +++ b/xpinstall/tests/browser_cookies.js @@ -0,0 +1,38 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test that an install that requires cookies to be sent fails when no cookies +// are set +// This verifies bug 462739 +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, -228, "Install should fail"); +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_cookies2.js b/xpinstall/tests/browser_cookies2.js new file mode 100644 index 000000000000..a7656bc60622 --- /dev/null +++ b/xpinstall/tests/browser_cookies2.js @@ -0,0 +1,51 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test that an install that requires cookies to be sent succeeds when cookies +// are set +// This verifies bug 462739 +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var cm = Components.classes["@mozilla.org/cookiemanager;1"] + .getService(Components.interfaces.nsICookieManager2); + cm.add("example.com", "/browser/xpinstall/tests", "xpinstall", "true", false, + false, true, (Date.now() / 1000) + 60); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + var cm = Components.classes["@mozilla.org/cookiemanager;1"] + .getService(Components.interfaces.nsICookieManager2); + cm.remove("example.com", "xpinstall", "/browser/xpinstall/tests", false); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_cookies3.js b/xpinstall/tests/browser_cookies3.js new file mode 100644 index 000000000000..47cfb08a6ac3 --- /dev/null +++ b/xpinstall/tests/browser_cookies3.js @@ -0,0 +1,59 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test that an install that requires cookies to be sent succeeds when cookies +// are set and third party cookies are disabled. +// This verifies bug 462739 +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var cm = Components.classes["@mozilla.org/cookiemanager;1"] + .getService(Components.interfaces.nsICookieManager2); + cm.add("example.com", "/browser/xpinstall/tests", "xpinstall", "true", false, + false, true, (Date.now() / 1000) + 60); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var prefs = Components.classes["@mozilla.org/preferences;1"] + .getService(Components.interfaces.nsIPrefBranch); + prefs.setIntPref("network.cookie.cookieBehavior", 1); + + var triggers = encodeURIComponent(JSON.stringify({ + "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + var cm = Components.classes["@mozilla.org/cookiemanager;1"] + .getService(Components.interfaces.nsICookieManager2); + cm.remove("example.com", "xpinstall", "/browser/xpinstall/tests", false); + + var prefs = Components.classes["@mozilla.org/preferences;1"] + .getService(Components.interfaces.nsIPrefBranch); + prefs.clearUserPref("network.cookie.cookieBehavior"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_cookies4.js b/xpinstall/tests/browser_cookies4.js new file mode 100644 index 000000000000..b5e035a05a7c --- /dev/null +++ b/xpinstall/tests/browser_cookies4.js @@ -0,0 +1,56 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test that an install that requires cookies to be sent fails when cookies +// are set and third party cookies are disabled and the request is to a third +// party. +// This verifies bug 462739 +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var cm = Components.classes["@mozilla.org/cookiemanager;1"] + .getService(Components.interfaces.nsICookieManager2); + cm.add("example.com", "/browser/xpinstall/tests", "xpinstall", "true", false, + false, true, (Date.now() / 1000) + 60); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var prefs = Components.classes["@mozilla.org/preferences;1"] + .getService(Components.interfaces.nsIPrefBranch); + prefs.setIntPref("network.cookie.cookieBehavior", 1); + + var triggers = encodeURIComponent(JSON.stringify({ + "Cookie check": TESTROOT2 + "cookieRedirect.sjs?" + TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, -228, "Install should fail"); +} + +function finish_test() { + var cm = Components.classes["@mozilla.org/cookiemanager;1"] + .getService(Components.interfaces.nsICookieManager2); + cm.remove("example.com", "xpinstall", "/browser/xpinstall/tests", false); + + var prefs = Components.classes["@mozilla.org/preferences;1"] + .getService(Components.interfaces.nsIPrefBranch); + prefs.clearUserPref("network.cookie.cookieBehavior"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_corrupt.js b/xpinstall/tests/browser_corrupt.js new file mode 100644 index 000000000000..c63300d73fd9 --- /dev/null +++ b/xpinstall/tests/browser_corrupt.js @@ -0,0 +1,39 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install fails when the xpi is corrupt. +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Corrupt XPI": TESTROOT + "corrupt.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, -207, "Install should fail"); +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + var doc = gBrowser.contentDocument; + is(doc.getElementById("status").textContent, "-207", "Callback should have seen the failure"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_empty.js b/xpinstall/tests/browser_empty.js new file mode 100644 index 000000000000..8d82fed09c12 --- /dev/null +++ b/xpinstall/tests/browser_empty.js @@ -0,0 +1,36 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install fails when there is no install script present. +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Empty XPI": TESTROOT + "empty.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, -204, "Install should fail"); +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_enabled.js b/xpinstall/tests/browser_enabled.js new file mode 100644 index 000000000000..d62d2a37703a --- /dev/null +++ b/xpinstall/tests/browser_enabled.js @@ -0,0 +1,25 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an InstallTrigger.enabled is working +function test() { + waitForExplicitFinish(); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function() { + // Allow the in-page load handler to run first + executeSoon(page_loaded); + }, true); + gBrowser.loadURI(TESTROOT + "enabled.html"); +} + +function page_loaded() { + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, false); + var doc = gBrowser.contentDocument; + is(doc.getElementById("enabled").textContent, "true", "installTrigger should have been enabled"); + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/xpinstall/tests/browser_enabled2.js b/xpinstall/tests/browser_enabled2.js new file mode 100644 index 000000000000..d79df036c449 --- /dev/null +++ b/xpinstall/tests/browser_enabled2.js @@ -0,0 +1,33 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an InstallTrigger.enabled is working +function test() { + waitForExplicitFinish(); + + var prefs = Components.classes["@mozilla.org/preferences;1"] + .getService(Components.interfaces.nsIPrefBranch); + prefs.setBoolPref("xpinstall.enabled", false); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function() { + // Allow the in-page load handler to run first + executeSoon(page_loaded); + }, true); + gBrowser.loadURI(TESTROOT + "enabled.html"); +} + +function page_loaded() { + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, false); + var prefs = Components.classes["@mozilla.org/preferences;1"] + .getService(Components.interfaces.nsIPrefBranch); + prefs.clearUserPref("xpinstall.enabled"); + + var doc = gBrowser.contentDocument; + is(doc.getElementById("enabled").textContent, "false", "installTrigger should have not been enabled"); + gBrowser.removeCurrentTab(); + finish(); +} diff --git a/xpinstall/tests/browser_enabled3.js b/xpinstall/tests/browser_enabled3.js new file mode 100644 index 000000000000..3d139eaf385f --- /dev/null +++ b/xpinstall/tests/browser_enabled3.js @@ -0,0 +1,37 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an InstallTrigger.install call fails when xpinstall is disabled +function test() { + waitForExplicitFinish(); + + var prefs = Components.classes["@mozilla.org/preferences;1"] + .getService(Components.interfaces.nsIPrefBranch); + prefs.setBoolPref("xpinstall.enabled", false); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function() { + // Allow the in-page load handler to run first + executeSoon(page_loaded); + }, true); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function page_loaded() { + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, false); + var prefs = Components.classes["@mozilla.org/preferences;1"] + .getService(Components.interfaces.nsIPrefBranch); + prefs.clearUserPref("xpinstall.enabled"); + + var doc = gBrowser.contentDocument; + is(doc.getElementById("return").textContent, "false", "installTrigger should have not been enabled"); + gBrowser.removeCurrentTab(); + finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_hash.js b/xpinstall/tests/browser_hash.js new file mode 100644 index 000000000000..359fb9aaf469 --- /dev/null +++ b/xpinstall/tests/browser_hash.js @@ -0,0 +1,45 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install succeeds when a valid hash is included +// This verifies bug 302284 +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": { + URL: TESTROOT + "unsigned.xpi", + Hash: "sha1:3d0dc22e1f394e159b08aaf5f0f97de4d5c65f4f", + toString: function() { return this.URL; } + } + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_installchrome.js b/xpinstall/tests/browser_installchrome.js new file mode 100644 index 000000000000..6bf3aacdc72e --- /dev/null +++ b/xpinstall/tests/browser_installchrome.js @@ -0,0 +1,37 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests that calling InstallTrigger.installChrome works +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installchrome.html? " + encodeURIComponent(TESTROOT + "unsigned.xpi")); +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_localfile.js b/xpinstall/tests/browser_localfile.js new file mode 100644 index 000000000000..d7910b0dd82f --- /dev/null +++ b/xpinstall/tests/browser_localfile.js @@ -0,0 +1,33 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an local file works when loading the url +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"] + .getService(Components.interfaces.nsIChromeRegistry); + var path = cr.convertChromeURL(makeURI(CHROMEROOT + "unsigned.xpi")).spec; + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(path); +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_localfile2.js b/xpinstall/tests/browser_localfile2.js new file mode 100644 index 000000000000..ba7202e3d5da --- /dev/null +++ b/xpinstall/tests/browser_localfile2.js @@ -0,0 +1,35 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install fails if the url is a local file when requested from +// web content +function test() { + waitForExplicitFinish(); + + var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"] + .getService(Components.interfaces.nsIChromeRegistry); + var path = cr.convertChromeURL(makeURI(CHROMEROOT + "unsigned.xpi")).spec; + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": path + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function() { + // Allow the in-page load handler to run first + executeSoon(page_loaded); + }, true); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function page_loaded() { + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, false); + + var doc = gBrowser.contentDocument; + is(doc.getElementById("return").textContent, "exception", "installTrigger should have failed"); + gBrowser.removeCurrentTab(); + finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_navigateaway.js b/xpinstall/tests/browser_navigateaway.js new file mode 100644 index 000000000000..99471741be03 --- /dev/null +++ b/xpinstall/tests/browser_navigateaway.js @@ -0,0 +1,47 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests that navigating away from the initiating page during the install +// doesn't break the install. +// This verifies bug 473060 +function test() { + Harness.downloadProgressCallback = download_progress; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function download_progress(addon, value, maxValue) { + gBrowser.loadURI("about:blank"); +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_navigateaway2.js b/xpinstall/tests/browser_navigateaway2.js new file mode 100644 index 000000000000..f45ffe51c916 --- /dev/null +++ b/xpinstall/tests/browser_navigateaway2.js @@ -0,0 +1,46 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests that closing the initiating page during the install doesn't break the +// install. +// This verifies bugs 473060 and 475347 +function test() { + Harness.downloadProgressCallback = download_progress; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function download_progress(addon, value, maxValue) { + gBrowser.removeCurrentTab(); +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_offline.js b/xpinstall/tests/browser_offline.js new file mode 100644 index 000000000000..dc07397b9ccd --- /dev/null +++ b/xpinstall/tests/browser_offline.js @@ -0,0 +1,43 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests that going offline cancels an in progress download. +function test() { + Harness.downloadProgressCallback = download_progress; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function download_progress(addon, value, maxValue) { + BrowserOffline.toggleOfflineStatus(); +} + +function check_xpi_install(addon, status) { + is(status, -210, "Install should be cancelled"); +} + +function finish_test() { + BrowserOffline.toggleOfflineStatus(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_opendialog.js b/xpinstall/tests/browser_opendialog.js new file mode 100644 index 000000000000..4ce93a2bd45e --- /dev/null +++ b/xpinstall/tests/browser_opendialog.js @@ -0,0 +1,42 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Test whether an install succeeds when the progress dialog is already open. +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + BrowserOpenAddonsMgr(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_signed_multiple.js b/xpinstall/tests/browser_signed_multiple.js new file mode 100644 index 000000000000..b6adbe656ef6 --- /dev/null +++ b/xpinstall/tests/browser_signed_multiple.js @@ -0,0 +1,58 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing two signed add-ons in the same trigger works. +// This verifies bug 453545 +function test() { + Harness.installConfirmCallback = confirm_install; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Signed XPI": TESTROOT + "signed.xpi", + "Signed XPI 2": TESTROOT + "signed2.xpi", + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function confirm_install(window) { + items = window.document.getElementById("itemList").childNodes; + is(items.length, 2, "Should be 2 items listed in the confirmation dialog"); + is(items[0].name, "Signed XPI", "Should have seen the name from the trigger list"); + is(items[0].url, TESTROOT + "signed.xpi", "Should have listed the correct url for the item"); + is(items[0].cert, "(Mozilla Testing)", "Should have seen the signer"); + is(items[0].signed, "true", "Should have listed the item as signed"); + is(items[1].name, "Signed XPI 2", "Should have seen the name from the trigger list"); + is(items[1].url, TESTROOT + "signed2.xpi", "Should have listed the correct url for the item"); + is(items[1].cert, "(Mozilla Testing)", "Should have seen the signer"); + is(items[1].signed, "true", "Should have listed the item as signed"); + return true; +} + +function check_xpi_install(addon, status) { + is(status, 0, "Installs should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("signed-xpi@tests.mozilla.org"); + em.cancelInstallItem("signed-xpi2@tests.mozilla.org"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_signed_tampered.js b/xpinstall/tests/browser_signed_tampered.js new file mode 100644 index 000000000000..4d3a4530b914 --- /dev/null +++ b/xpinstall/tests/browser_signed_tampered.js @@ -0,0 +1,47 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing a signed add-on that has been tampered with after signing. +function test() { + Harness.installConfirmCallback = confirm_install; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Tampered Signed XPI": TESTROOT + "signed-tampered.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function confirm_install(window) { + items = window.document.getElementById("itemList").childNodes; + is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); + is(items[0].name, "Tampered Signed XPI", "Should have seen the name from the trigger list"); + is(items[0].url, TESTROOT + "signed-tampered.xpi", "Should have listed the correct url for the item"); + is(items[0].cert, "(Mozilla Testing)", "Should have seen the signer"); + is(items[0].signed, "true", "Should have listed the item as signed"); + return true; +} + +function check_xpi_install(addon, status) { + is(status, -260, "Install should fail"); +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_signed_trigger.js b/xpinstall/tests/browser_signed_trigger.js new file mode 100644 index 000000000000..0f5b25a31243 --- /dev/null +++ b/xpinstall/tests/browser_signed_trigger.js @@ -0,0 +1,52 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an signed add-on through an InstallTrigger call in web +// content. +function test() { + Harness.installConfirmCallback = confirm_install; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Signed XPI": TESTROOT + "signed.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function confirm_install(window) { + items = window.document.getElementById("itemList").childNodes; + is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); + is(items[0].name, "Signed XPI", "Should have seen the name from the trigger list"); + is(items[0].url, TESTROOT + "signed.xpi", "Should have listed the correct url for the item"); + is(items[0].cert, "(Mozilla Testing)", "Should have seen the signer"); + is(items[0].signed, "true", "Should have listed the item as signed"); + return true; +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("signed-xpi@tests.mozilla.org"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_signed_untrusted.js b/xpinstall/tests/browser_signed_untrusted.js new file mode 100644 index 000000000000..9ecbc71ea918 --- /dev/null +++ b/xpinstall/tests/browser_signed_untrusted.js @@ -0,0 +1,48 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an add-on signed by an untrusted certificate through an +// InstallTrigger call in web content. +function test() { + Harness.installConfirmCallback = confirm_install; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Untrusted Signed XPI": TESTROOT + "signed-untrusted.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function confirm_install(window) { + items = window.document.getElementById("itemList").childNodes; + is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); + is(items[0].name, "Untrusted Signed XPI", "Should have seen the name from the trigger list"); + is(items[0].url, TESTROOT + "signed-untrusted.xpi", "Should have listed the correct url for the item"); + is(items[0].cert, "(Unknown Organisation)", "Should have seen the supposed signer"); + is(items[0].signed, "true", "Should have listed the item as signed"); + return true; +} + +function check_xpi_install(addon, status) { + is(status, -260, "Install should fail"); +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_signed_url.js b/xpinstall/tests/browser_signed_url.js new file mode 100644 index 000000000000..3cf1a06584ea --- /dev/null +++ b/xpinstall/tests/browser_signed_url.js @@ -0,0 +1,40 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an signed add-on by navigating directly to the url +function test() { + Harness.installConfirmCallback = confirm_install; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "signed.xpi"); +} + +function confirm_install(window) { + items = window.document.getElementById("itemList").childNodes; + is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); + is(items[0].name, "signed.xpi", "Should have had the filename for the item name"); + is(items[0].url, TESTROOT + "signed.xpi", "Should have listed the correct url for the item"); + is(items[0].cert, "(Mozilla Testing)", "Should have seen the signer"); + is(items[0].signed, "true", "Should have listed the item as signed"); + return true; +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("signed-xpi@tests.mozilla.org"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_softwareupdate.js b/xpinstall/tests/browser_softwareupdate.js new file mode 100644 index 000000000000..7f6b4fffe245 --- /dev/null +++ b/xpinstall/tests/browser_softwareupdate.js @@ -0,0 +1,37 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests that calling InstallTrigger.startSoftwareUpdate works +function test() { + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "startsoftwareupdate.html? " + encodeURIComponent(TESTROOT + "unsigned.xpi")); +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_unsigned_trigger.js b/xpinstall/tests/browser_unsigned_trigger.js new file mode 100644 index 000000000000..e09a1ffc7f6a --- /dev/null +++ b/xpinstall/tests/browser_unsigned_trigger.js @@ -0,0 +1,60 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an unsigned add-on through an InstallTrigger call in web +// content. +function test() { + Harness.installConfirmCallback = confirm_install; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": { + URL: TESTROOT + "unsigned.xpi", + IconURL: TESTROOT + "icon.png", + toString: function() { return this.URL; } + } + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function confirm_install(window) { + items = window.document.getElementById("itemList").childNodes; + is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); + is(items[0].name, "Unsigned XPI", "Should have seen the name from the trigger list"); + is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item"); + is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item"); + is(items[0].signed, "false", "Should have listed the item as unsigned"); + return true; +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + var doc = gBrowser.contentDocument; + is(doc.getElementById("return").textContent, "true", "installTrigger should have claimed success"); + is(doc.getElementById("status").textContent, "0", "Callback should have seen a success"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_unsigned_url.js b/xpinstall/tests/browser_unsigned_url.js new file mode 100644 index 000000000000..ff38bc48a706 --- /dev/null +++ b/xpinstall/tests/browser_unsigned_url.js @@ -0,0 +1,40 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an unsigned add-on by navigating directly to the url +function test() { + Harness.installConfirmCallback = confirm_install; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "unsigned.xpi"); +} + +function confirm_install(window) { + items = window.document.getElementById("itemList").childNodes; + is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); + is(items[0].name, "unsigned.xpi", "Should have had the filename for the item name"); + is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item"); + is(items[0].icon, "", "Should have listed no icon for the item"); + is(items[0].signed, "false", "Should have listed the item as unsigned"); + return true; +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_whitelist.js b/xpinstall/tests/browser_whitelist.js new file mode 100644 index 000000000000..19a72f0bd621 --- /dev/null +++ b/xpinstall/tests/browser_whitelist.js @@ -0,0 +1,49 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an unsigned add-on through an InstallTrigger call in web +// content. This should be blocked by the whitelist check. +// This verifies bug 252830 +function test() { + Harness.installConfirmCallback = confirm_install; + Harness.installBlockedCallback = allow_blocked; + Harness.installEndedCallback = check_xpi_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function allow_blocked() { + return true; +} + +function confirm_install(window) { + items = window.document.getElementById("itemList").childNodes; + is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); + is(items[0].name, "Unsigned XPI", "Should have seen the name from the trigger list"); + is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item"); + is(items[0].signed, "false", "Should have listed the item as unsigned"); + return true; +} + +function check_xpi_install(addon, status) { + is(status, 0, "Install should succeed"); +} + +function finish_test() { + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.cancelInstallItem("unsigned-xpi@tests.mozilla.org"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_whitelist2.js b/xpinstall/tests/browser_whitelist2.js new file mode 100644 index 000000000000..3618b1cc8e55 --- /dev/null +++ b/xpinstall/tests/browser_whitelist2.js @@ -0,0 +1,38 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an unsigned add-on through an InstallTrigger call in web +// content. This should be blocked by the whitelist check because the source +// is not whitelisted, even though the target is. +function test() { + Harness.installBlockedCallback = allow_blocked; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT2 + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); +} + +function allow_blocked() { + return false; +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.org", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_whitelist3.js b/xpinstall/tests/browser_whitelist3.js new file mode 100644 index 000000000000..d37efc7ceeae --- /dev/null +++ b/xpinstall/tests/browser_whitelist3.js @@ -0,0 +1,37 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an unsigned add-on through a navigation. Should not be +// blocked since the referer is whitelisted. +function test() { + Harness.installConfirmCallback = confirm_install; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT2 + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "unsigned.xpi", makeURI(TESTROOT2 + "test.html")); +} + +function confirm_install(window) { + return false; +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.org", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_whitelist4.js b/xpinstall/tests/browser_whitelist4.js new file mode 100644 index 000000000000..365710213c2a --- /dev/null +++ b/xpinstall/tests/browser_whitelist4.js @@ -0,0 +1,37 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an unsigned add-on through a navigation. Should be +// blocked since the referer is not whitelisted even though the target is. +function test() { + Harness.installBlockedCallback = allow_blocked; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); + + var triggers = encodeURIComponent(JSON.stringify({ + "Unsigned XPI": TESTROOT2 + "unsigned.xpi" + })); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "unsigned.xpi", makeURI(TESTROOT2 + "test.html")); +} + +function allow_blocked() { + return false; +} + +function finish_test() { + var pm = Components.classes["@mozilla.org/permissionmanager;1"] + .getService(Components.interfaces.nsIPermissionManager); + pm.remove("example.com", "install"); + + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_whitelist5.js b/xpinstall/tests/browser_whitelist5.js new file mode 100644 index 000000000000..c1227e1dee9d --- /dev/null +++ b/xpinstall/tests/browser_whitelist5.js @@ -0,0 +1,27 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an unsigned add-on through a startSoftwareUpdate call in web +// content. This should be blocked by the whitelist check. +// This verifies bug 252830 +function test() { + Harness.installBlockedCallback = allow_blocked; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "startsoftwareupdate.html? " + encodeURIComponent(TESTROOT + "unsigned.xpi")); +} + +function allow_blocked() { + return false; +} + +function finish_test() { + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/browser_whitelist6.js b/xpinstall/tests/browser_whitelist6.js new file mode 100644 index 000000000000..84e9baa1d985 --- /dev/null +++ b/xpinstall/tests/browser_whitelist6.js @@ -0,0 +1,27 @@ +// Load in the test harness +var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader); +scriptLoader.loadSubScript("chrome://mochikit/content/browser/xpinstall/tests/harness.js", this); + +// ---------------------------------------------------------------------------- +// Tests installing an unsigned add-on through an installChrome call in web +// content. This should be blocked by the whitelist check. +// This verifies bug 252830 +function test() { + Harness.installBlockedCallback = allow_blocked; + Harness.installsCompletedCallback = finish_test; + Harness.setup(); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.loadURI(TESTROOT + "installchrome.html? " + encodeURIComponent(TESTROOT + "unsigned.xpi")); +} + +function allow_blocked() { + return false; +} + +function finish_test() { + gBrowser.removeCurrentTab(); + Harness.finish(); +} +// ---------------------------------------------------------------------------- diff --git a/xpinstall/tests/cookieRedirect.sjs b/xpinstall/tests/cookieRedirect.sjs new file mode 100644 index 000000000000..92bccd9ec1ac --- /dev/null +++ b/xpinstall/tests/cookieRedirect.sjs @@ -0,0 +1,24 @@ +// Simple script redirects to the query part of the uri if the cookie "xpinstall" +// has the value "true", otherwise gives a 500 error. + +function handleRequest(request, response) +{ + let cookie = null; + if (request.hasHeader("Cookie")) { + let cookies = request.getHeader("Cookie").split(";"); + for (let i = 0; i < cookies.length; i++) { + if (cookies[i].substring(0, 10) == "xpinstall=") + cookie = cookies[i].substring(10); + } + } + + if (cookie == "true") { + response.setStatusLine(request.httpVersion, 302, "Found"); + response.setHeader("Location", request.queryString); + response.write("See " + request.queryString); + } + else { + response.setStatusLine(request.httpVersion, 500, "Internal Server Error"); + response.write("Invalid request"); + } +} diff --git a/xpinstall/tests/corrupt.xpi b/xpinstall/tests/corrupt.xpi new file mode 100644 index 000000000000..35d7bd5e5dd6 --- /dev/null +++ b/xpinstall/tests/corrupt.xpi @@ -0,0 +1 @@ +This is a corrupt zip file diff --git a/xpinstall/tests/empty.xpi b/xpinstall/tests/empty.xpi new file mode 100644 index 0000000000000000000000000000000000000000..74ed2b817426d02c0bf2313ed0f2ac728d354800 GIT binary patch literal 197 zcmWIWW@Zs#U}E545KK3>dZx8L$((_K!48O78AKUUa|=o;Lqj+jm>c(1dV+9h1q;Jh zMiBuxbx7oxTI$dzZAv*8rh9mZ!{Z}V4 z`%HCp$Su6a7~svwB+iV>LSCS?3=E7wyrdDtf?CfCu|Bkdfg!+~l?^1r2!swmIv>Pg F0089VGZO#+ literal 0 HcmV?d00001 diff --git a/xpinstall/tests/enabled.html b/xpinstall/tests/enabled.html new file mode 100644 index 000000000000..9b9bc0a29163 --- /dev/null +++ b/xpinstall/tests/enabled.html @@ -0,0 +1,20 @@ + + + + + + + +InstallTrigger tests + + + +

InstallTrigger tests

+

+ + diff --git a/xpinstall/tests/harness.js b/xpinstall/tests/harness.js new file mode 100644 index 000000000000..9fd3ae33a7cd --- /dev/null +++ b/xpinstall/tests/harness.js @@ -0,0 +1,257 @@ +const TESTROOT = "http://example.com/browser/xpinstall/tests/"; +const TESTROOT2 = "http://example.org/browser/xpinstall/tests/"; +const CHROMEROOT = "chrome://mochikit/content/browser/xpinstall/tests/" +const XPINSTALL_URL = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul"; +const PROMPT_URL = "chrome://global/content/commonDialog.xul"; +const ADDONS_URL = "chrome://mozapps/content/extensions/extensions.xul"; + +/** + * This is a test harness designed to handle responding to UI during the process + * of installing an XPI. A test can set callbacks to hear about specific parts + * of the sequence. + * Before use setup must be called and finish must be called afterwards. + */ +var Harness = { + // If set then the install is expected to be blocked by the whitelist. The + // callback should return true to continue with the install anyway. + installBlockedCallback: null, + // If set will be called in the event of authentication being needed to get + // the xpi. Should return a 2 element array of username and password, or + // null to not authenticate. + authenticationCallback: null, + // If set this will be called to allow checking the contents of the xpinstall + // confirmation dialog. The callback should return true to continue the install. + installConfirmCallback: null, + // If set will be called when downloading of an item has begun. + downloadStartedCallback: null, + // If set will be called during the download of an item. + downloadProgressCallback: null, + // If set will be called when downloading of an item has ended. + downloadEndedCallback: null, + // If set will be called when installation by the extension manager of an xpi + // item starts + installStartedCallback: null, + // If set will be called when each xpi item to be installed completes + // installation. + installEndedCallback: null, + // If set will be called when all triggered items are installed or the install + // is canceled. + installsCompletedCallback: null, + + listenerIndex: null, + + // Setup and tear down functions + setup: function() { + waitForExplicitFinish(); + + var os = Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService); + os.addObserver(this, "xpinstall-install-blocked", false); + + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + wm.addListener(this); + + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + this.listenerIndex = em.addInstallListener(this); + }, + + finish: function() { + var os = Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService); + os.removeObserver(this, "xpinstall-install-blocked"); + + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + wm.removeListener(this); + var win = wm.getMostRecentWindow("Extension:Manager"); + if (win) + win.close(); + + var em = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + em.removeInstallListenerAt(this.listenerIndex); + finish(); + }, + + endTest: function() { + // Defer the final notification to allow things like the InstallTrigger + // callback to complete + executeSoon(this.installsCompletedCallback); + + this.installBlockedCallback = null; + this.authenticationCallback = null; + this.installConfirmCallback = null; + this.downloadStartedCallback = null; + this.downloadProgressCallback = null; + this.downloadEndedCallback = null; + this.installStartedCallback = null; + this.installEndedCallback = null; + this.installsCompletedCallback = null; + }, + + // Window open handling + windowLoad: function(window) { + // Allow any other load handlers to execute + var self = this; + executeSoon(function() { self.windowReady(window); } ); + }, + + windowReady: function(window) { + if (window.document.location.href == XPINSTALL_URL) { + if (this.installBlockedCallback) + ok(false, "Should have been blocked by the whitelist"); + + // If there is a confirm callback then its return status determines whether + // to install the items or not. If not the test is over. + if (this.installConfirmCallback && !this.installConfirmCallback(window)) { + window.document.documentElement.cancelDialog(); + this.endTest(); + } + else { + // Initially the accept button is disabled on a countdown timer + var button = window.document.documentElement.getButton("accept"); + button.disabled = false; + window.document.documentElement.acceptDialog(); + } + } + else if (window.document.location.href == PROMPT_URL) { + switch (window.gCommonDialogParam.GetInt(3)) { + case 0: if (window.opener.document.location.href == ADDONS_URL) { + // A prompt opened by the add-ons manager is liable to be an + // xpinstall error, just close it, we'll see the error in + // onInstallEnded anyway. + window.document.documentElement.acceptDialog(); + } + break; + case 2: if (window.gCommonDialogParam.GetInt(4) != 1) { + // This is a login dialog, hopefully an authentication prompt + // for the xpi. + if (this.authenticationCallback) { + var auth = this.authenticationCallback(); + if (auth && auth.length == 2) { + window.document.getElementById("loginTextbox").value = auth[0]; + window.document.getElementById("password1Textbox").value = auth[1]; + window.document.documentElement.acceptDialog(); + } + else { + window.document.documentElement.cancelDialog(); + } + } + else { + window.document.documentElement.cancelDialog(); + } + } + break; + } + } + }, + + // Install blocked handling + + installBlocked: function() { + // The browser should have a notification box animating now + var notificationBox = gBrowser.getNotificationBox(gBrowser.selectedBrowser); + var self = this; + this.waitForNotification(notificationBox, function() { self.notificationComplete() }); + }, + + // This delays until a notification has finished animating it. It's a bit of a + // hack due to the timeout use but should be safe. + waitForNotification: function(notificationBox, callback) { + if (!notificationBox._timer) { + callback(); + return; + } + + setTimeout(arguments.callee, 50, notificationBox, callback); + }, + + notificationComplete: function() { + ok(!!this.installBlockedCallback, "Shouldn't have been blocked by the whitelist"); + var notification = gBrowser.getNotificationBox(gBrowser.selectedBrowser) + .getNotificationWithValue("xpinstall"); + if (this.installBlockedCallback && this.installBlockedCallback()) { + this.installBlockedCallback = null; + notification.firstChild.click(); + } + else { + notification.close(); + this.endTest(); + } + }, + + // nsIWindowMediatorListener + + onWindowTitleChange: function(window, title) { + }, + + onOpenWindow: function(window) { + var domwindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsIDOMWindowInternal); + var self = this; + domwindow.addEventListener("load", function() { + self.windowLoad(domwindow); + }, false); + }, + + onCloseWindow: function(window) { + }, + + // nsIAddonInstallListener + + onDownloadStarted: function(addon) { + if (this.downloadStartedCallback) + this.downloadStartedCallback(addon); + }, + + onDownloadProgress: function(addon, value, maxValue) { + if (this.downloadProgressCallback) + this.downloadProgressCallback(addon, value, maxValue); + }, + + onDownloadEnded: function(addon) { + if (this.downloadEndedCallback) + this.downloadEndedCallback(addon); + }, + + onInstallStarted: function(addon) { + if (this.installStartedCallback) + this.installStartedCallback(addon); + }, + + onCompatibilityCheckStarted: function(addon) { + }, + + onCompatibilityCheckEnded: function(addon, status) { + }, + + onInstallEnded: function(addon, status) { + if (this.installEndedCallback) + this.installEndedCallback(addon, status); + }, + + onInstallsCompleted: function() { + this.endTest(); + }, + + // nsIObserver + + observe: function(subject, topic, data) { + // Make sure the main UI has received the event too and so has started + // displaying the notification. + var self = this; + executeSoon(function() { self.installBlocked() }); + }, + + QueryInterface: function(iid) { + if (iid.equals(Components.interfaces.nsIObserver) || + iid.equals(Components.interfaces.nsIAddonInstallListener) || + iid.equals(Components.interfaces.nsIWindowMediatorListener) || + iid.equals(Components.interfaces.nsISupports)) + return this; + + throw Components.results.NS_ERROR_NO_INTERFACE; + } +} diff --git a/xpinstall/tests/installchrome.html b/xpinstall/tests/installchrome.html new file mode 100644 index 000000000000..71c072d3aa16 --- /dev/null +++ b/xpinstall/tests/installchrome.html @@ -0,0 +1,21 @@ + + + + + + + +InstallTrigger tests + + + +

InstallTrigger tests

+ + diff --git a/xpinstall/tests/installtrigger.html b/xpinstall/tests/installtrigger.html new file mode 100644 index 000000000000..e6a08764e125 --- /dev/null +++ b/xpinstall/tests/installtrigger.html @@ -0,0 +1,32 @@ + + + + + + + +InstallTrigger tests + + + +

InstallTrigger tests

+

+

+ + diff --git a/xpinstall/tests/signed-tampered.xpi b/xpinstall/tests/signed-tampered.xpi new file mode 100644 index 0000000000000000000000000000000000000000..8c951881e5fbe10504eee8280dd9a3d995b5c881 GIT binary patch literal 2260 zcmaKtc|4T+9>*UuW|*;djHRP&;iSTtF}6@6#u`~F9oxYSO$cKUWgAPDk~O-YTed%u3q=k@)3zQ-)Vya)gU@B@nB z+IqXE@nYpgP>$m-IigfVELZ~5qjPAj`|LFgF2$t8jOTtUJ7 zT(V%kRGHczULJT5U28Ia{~ve={R#@9C5rbHCcKhh!Mi#R*z%jJs;OvYAw|J35{&bS zb&|lER;09}IsHNyq32jsXDj?s-dxx%6}W3E7T$f!L@AG$_cTfA7CiNa($000Jf&Xh0#JS^el4vQgd@#_RdbueBkpPzXX3|)JdDKzWr4vYMf3+2Gu6d)l`)DEEONj zG%Z*3dBQGdIPUfRaFfgM$zx4veCv=8kryjmXq z#Ic>J!?sO~Jr;eqstex{s$FwM?{p>nsD((COMk63rv=+vd`8&|2W7O=pmLQYqrEu%M5rgE&R7n}~{_`TP!Wu@SH zsj>HrWbEUYi`NbJjqDr${fqAhPd;M%xW3&BHH0+Unbqm>@?q9jG@6uZLs?7S)l+t- z%39zAx;pWG7dbq*zR;8Uyh5$O;=LHwrqN$D02Q^`Q*QWmtzrF_CjS$z!z;upcQH>m zvRN@Y!$M!xp6?0B_`Zv%j~tJPfVJ0=X}qsoY??b}+Ej7hksxr&UN9l*+|dc zeUvt$kW&$fX+Wi?`%|nR%GRv2t&#^tV%G)_`8Ds6F`SE&ZM1g!+&psrs`35?2x@c! z&93}XTUFhCU2p7dbL!K4`;;6elO2Zr&8NWTUDv_Km(~tietO{A-GA@pwU6>H3K8ic zbIR*v;275>aA5PkIa{o;dG@En1leyAN4RGpJpbb`KliglFG3Jm z&ClxxW~;*tQe7{Q9W<=05TXH zW^e~_2eaBnS*Gum|Ghr_P+V|OiD$t6r^1KzMV#q$r)gL>v8)6#pQfY2b0}eNck~(- zI-+3aE)i#ZF`_A6f&WN=*p$9e+T0Uwp=^twQQWeX0cZa4Gub2e1FXo9#q)J?!khs- zCG>o6wK>Q}r$wD4`%vt+u*Co$x@4&}9E+|HBWJE#^T z3yH`y<);QSZ*R)9Glk{cNOd(dBU$k9Mcv5*hK@x=4tc%8d0EC9sv%?4le>#Z6)0N? z>jjLuxqTAkV`-yi2eD)MGjX`J=hyIYUBDo|b4l0GAsgY85D}GIeR~DlE48i^5ZKjn zB)hjD(@%PehU7gpFzD~}FXvfMUsMt(j6jj7m*+h(bUMz|r4?;ji+>WG#wpgcZ#pMX z5Wkx9o8zZ0Pz=Uiysk-5CI+^u&EE%2A-%n3yJLgrm?aNL68zKW+b5~ekH{#A+1&p1 zT!nm_tH;j)+`!qy{axgI$B6=qSY__0{((F0@F&L4D{YUSZwzi*03|UVTN&Ge=>Ooh wJ9R6L!n@^4TYdXCv_CiLR@xv0*xs^S%C~milnDae)DyyeL%9E9#<%(PZx`>A<^TWy literal 0 HcmV?d00001 diff --git a/xpinstall/tests/signed-untrusted.xpi b/xpinstall/tests/signed-untrusted.xpi new file mode 100644 index 0000000000000000000000000000000000000000..4c40ab818ed40583847a2f9478d7839c10031e8b GIT binary patch literal 2276 zcmaKtc{tnI9>zlm326;Mw4GX7T$9AUO{x`Ixu~^7X>CCewZ^`dxVBnSwKOqQua;8O zTIvd>f*{l~v_@Oos2OwBzT8-E+}>%qGjq@HIp;a&kMnuX?|r`S`?a_Vavgd-Em$zHk^7mWVYF5oUMes(g#tDQt z@AWOkM&Ga~6ni!oBI;P>A)nz#Ne?dwQgZ$Ax!t~#{>Xrt2EHm|D%0{#p|JeT^WTRw z{5|POXLuXh$~0Q^yZ2>cxzJX&{J2&B&aTty#puwcNWb39lN!@1T5{W?3tQb*VhyOg zNZD+MC9+7-Ca}R>E4$CivzlT|K5o)~i4I=rU=}T*_RO6MqU#Q( z^FnicQuA`P`Bq-kGxu(Ut}`!Fpx#eeg5SZdVpHU}vK?oLv?~}fDd8ouEf5@L>#urR z<_Q5P@i)P8Y29nRwaPWgsutMpTKJusq_}-4;TF*T|df!7Pp5FZCer*UahX_ zzr&}~7CytyrTOI(9)RbuXCfv8Uq>vmm(Noupq-NWH)fEZ?y^NZ{9tWC0nACZu4K}K zWH5MizR=&c>~fj(^VPkA;w{bWe}%1FvZO5!P9O06m4&Lyp`JwE_19?f3EAAy{ih(d z*r4I|H|FJ3o>b5Ln;Q>(F9VpP_ci;t&6sAiey1TmfCa}v5WwL$bkKh`|6RaG9rW2Y z*dw+%y!*v{VQcZFW1PF(T>s-fAG|Nooe&tL=;QtwbJTqoGlq;A%5dz`8tkChRlNdH zgjg>ks^-$_gDby|5O=U)42#{1-QEllY`L)f^`#8!N8jF(EHb;`SE7;tuddCcUah4PM%|AiCo1Ec} z<>J~T>DV*2`#khc{v5AC1?mtV0TuE@t*E38`=OyQA6&?YLd;)OZ`Q%8U1^NYfSO!N zX2h^tYleMVCFVC55v;+{-A34259#I)yET=C0(KD7=GoQP0i>QmrQ`D4E3Hcx;7H@k znIcD}{VkjV|5%;$bUi<^GCXlLb`cJDjIh`k$Cg9p`w?7V8yvce3=WM&n{kXM8P;&cyab5w0ejcUBS@K(E-l< zW2;*f*XbpTvITXd@P|ncDuZU&Djin3% zw9R{FyP9+!8uTk>X98vTAnUDv4gTcXtz~Sjj^y)m6XTlOs<%-Rrrv@m@MJp2A`3ME8`<>O*bkH^Y5O2Su*ar z^C&jN_D2Kw!~HOP@2m-8LrI*x4Kg}2DJ&PcArlnBPmryH(eA*|n!-f-=4QsJtxy9oAKYo>#9C^}Fv;GO~_qBPHw#W-OUa1_)VWobOi5GOJCoks<;rxp& H-{I-sK1YwE literal 0 HcmV?d00001 diff --git a/xpinstall/tests/signed.xpi b/xpinstall/tests/signed.xpi new file mode 100644 index 0000000000000000000000000000000000000000..bd7f78b7c7712c0aca18776e08541e87898da119 GIT binary patch literal 2250 zcmaKtc{tnI9>!xy5NpxUOKZ7}sUk@1Yoe7w)mBt3Z9{^z)`%@?i?Ot|Z$&YeQA_O9 z)|x6AsoJ+`(Te42FsjC0Z833s+j3{-p5JrMbIu>Atr;31DMk$h#j!W zA`C#dJL^$tWxq0pw({sO;>7#ojNR*KqmwA^(pkdg!!RujOw@Zn}43~*nMyd|fx0!&sdT}gnAi@>%1 zk#QNvm^)4GM63_z24z8rW z1s7EbfUBy(-wrIV4<%-0wVhd*ezV2lF&PhTH|Q-~dRV@%5k5&FD)}|uS!}2(y7?|& zJMFv!ghuzNwUc`<-CuyKyF(Q5UVf=su=R=HHNUMT2Oag&@glg3QBU zrN&(!XDk+jadqB_fSl+>&aa6r!nFuMIK5eR#KM0kd;_t2clMs?!?zCd_dHj18X0%d zg9TA_2B$7XZ{+XjogF_rX}{;O<-&pQoYb*;2@@7WI5K*jUp-CVM<57^=H&Nx#0N?$ zYt6WA5f9@Y^$|(_&ABcGqgAl`CaXdy^T*x_KJf7EfeO9-_boeut=_g*$2Re`7$Fz1 z($A+OQcZLeE^&0Ro`2*da8r_npWDp!+#J?JGAbFPI`_SaHG>vo3F_v&0y(D)Nx4lD zG%$Oq4p)cO3?=XoNW1a)CLQ~=>v#`=u??+k{qZo`WZpLHRbxxr#QwI@K%OGm*z|c7 zuRL^HpOcuUJDTBcZ&5Dzph7_pT8$kTf$T-M*=l$#(d(B)=S`f9sZURE@z2jW3gt>b zs$W~dBq~-~RO+NO@cuCY#e*+?v)+4ozVgHfE}d^DeD4nd-ZV z?{Whyn2>-02jc*e|7`xda24@x~tnX7X$ao&kT-#YEt1JzcEs? zR&X=Flv0EV4InK6HIFZd9Q9{rGt!Ee>5VUQ3LWNb_UK{+F3-<+cVgTG&qi;vuMKBNx6BZcBH$JLK7DFQAfYsj+b$DHYpc#i^& zOB-PzKb(&ZZH<=ZJm(`ct7DM7*yYBXVd6J|-Z0f&UwYOpaqf|iDG|6F(j>{ZK7u6& zhTPG-pCr-!Yr3M?EA%x+^(KK{*3GG~XdX06!6j=+s^8Xhl!)R<8yo|{kf z_8wnNcNw`2!KX{W;T<<`@YE-)H|4)E+-=lc?xyCAol>W%2n^MP&-+SyZg73Gbk|W) z3&Sd3F3+^{3NzQanU>G24;TUa*~$b-Z{x$2=5OU>9;GB4I)B-E%hjrT@ZPcO zh<2!6mZ&Q2rIwb*TMqmR`|f5Yd@SzD6lp+nJ2&K&$E0!Olk8f@avevsZ!?T683JqS zlImv6e1}XE9B%X+rJtV|#kSa28s#RRZZDp2`S?>rfZe#E=)d-YFx_*ea+``GkWFb~04EMwuT2&6Q5M)8;5O9&;NT|)N0eKCZm2~CoHA+pZZAFI@ zRec&6;+2^aiC9gdLcDB~5(3S$?2s4xrmOJmQ1Eo7O{C6o8glNM^gydpJF>Y$)HA_0;+;+OsS|^#tcIdLZWWbcJMT`(lfp^J zYOneywH%**>dTE)L7`ty$&&RgF0inQuzkb(X#eE>niNHm2iw2yrohkL)FueP%$WnZ zze}1gasq&56qMPZzslKI|4HN9la40NXANdG0E!|phc%Am&;OA-3g}_ENcKZdI*jYz lsQtM%537v=0Y@v9sd7-MpKSty4*Uc%zX0aH=y4pJ{s3OnkgNaz literal 0 HcmV?d00001 diff --git a/xpinstall/tests/signed2.xpi b/xpinstall/tests/signed2.xpi new file mode 100644 index 0000000000000000000000000000000000000000..085efbbf7fdd8f9cf475e903b16552e614f9139c GIT binary patch literal 2938 zcmc&$4{RIN8Nc({0bdsi`CFwhUef|?GuzKTJ0Y%}#E$L8XjQlVZw-8KDfC4Pfqc9M7-O&wC;xPB2- zSE!n9A`}fO3@(~i!e=KH5Kbz70Vna@vxEXyAZ=J#QovP6KcugQw^R^8<)Ugb$g=_n zFliyJUjpmINwRveCo#dsGE;u7fps-<96*CMF`}A*5h#MjjTf!id}> z7|cDa$mOu3+@n2B{W}xS`{z#o_H4y=9Q0NZwfmax|Gx9`fyOy@&kEC-ZQ(O(-G{=p zQ_pSuz;XBMw|w@ij;UQMmTs&3&E?mEJN~-=@#8y;!r)ZXr@w!v?gaBg`0&OD=AMY$ zag18gP7Qn#=&17DoVM(0z4&3%@s6ffg5g-ex_5fts;kg{KsoeL!tPat^eBI7&giA_=sV4ODGKRO#OH}&BvZ89Cj3KyuUaHjBDQo67c#r<_ z&V$bk69?nV-np;p@TGHu@r6$`ye(cvLPQSHm;Ot~_Zt}Bfe&&MV%GZaUuUm60womo_zo-rS zSL`})sN-+HqhdFzLt9@tm5mxdekhO|-I=-Y)t2xQ#nWs0l5akB)R27pse|UJ=GpCo z?|uP~`bxCmnrJag{80E)%V|O4g8ly(cOOTi$OZFjMM}AH)_=PS$1rh}Q3^-%>=5c^ zEjM&sO7Rrrnm#6#W)r*_=(UjSOfjg7qZ<3TS!ypKk%)tpY1He|8>Q77v=p$@X*L3! zot?nW2=pqlGr@5TFQm=D*W2L=?pv&D0T<#vH77TcU;9hr653u{4 zwspWA(30eOnq$m><$4**x=~M8Q?TD?CChX9 zq}^9Dit;FqYWY4C={bGyG_2 zahpc_J)?gA2d9RL;wla8d=q=32)(BZ_G zU~L>r@#exRb0H2*v6Im%(UXPY%xttx>`Bz9*(7V|5X4hkEAwVSouZ%%x@{_PK41oAgO43nF?_M9l1 zyBYi3RP+(xnHq|;*oNTRuN%9NX%QOO|533LH# i*LJepTHg&=d0!(dVqfP&R8@%iRH5HyMBNwF;@6MGm}MdW literal 0 HcmV?d00001 diff --git a/xpinstall/tests/startsoftwareupdate.html b/xpinstall/tests/startsoftwareupdate.html new file mode 100644 index 000000000000..4845a504a055 --- /dev/null +++ b/xpinstall/tests/startsoftwareupdate.html @@ -0,0 +1,19 @@ + + + + + + + +InstallTrigger tests + + + +

InstallTrigger tests

+ + diff --git a/xpinstall/tests/unsigned.xpi b/xpinstall/tests/unsigned.xpi new file mode 100644 index 0000000000000000000000000000000000000000..51b00475a9641ea9d608874a3ab7679da3a4374b GIT binary patch literal 452 zcmWIWW@Zs#U}E54_?u^9#dA2DRf~~4Pa^m=!CAB@`#_JRJCLMTP zI9DyV<<;!;^s=<;=fu~BJ&BG`=N0*wGwVpVQP-#IS7-g;+M)E%WsUK%S<7acl?Nw( z&oP^SK626~lcn2k1%78f5zUn++E7tLzE!`U8JT5_uOTuP|ifs?i!UE8+CEYjcYy?ajS z8plGZ?O!gpMb-1SG`8M($7*+F>!j#D=h``2kGE-L^!%E%W6!hu!CPCtPtFy8#3UhH zdHeBp*^fM58gJ}(X{=0b>ML;8jErXXkXxv9p6O?ovig*H-&tb1i#~sHx%bD*`FKOi zcd5uS!$os`<_Ejg2Y53wi8JF0X