зеркало из https://github.com/mozilla/gecko-dev.git
Bug 608680: Throw an exception if illegal arguments are passed to InstallTrigger.install. r=Unfocused, a=blocks-betaN
This commit is contained in:
Родитель
666a25ba40
Коммит
2a6c021c1f
|
@ -93,6 +93,9 @@ InstallTrigger.prototype = {
|
|||
* @see amIInstallTriggerInstaller.idl
|
||||
*/
|
||||
install: function(aArgs, aCallback) {
|
||||
if (!aArgs || typeof aArgs != "object")
|
||||
throw new Error("Incorrect arguments passed to InstallTrigger.install()");
|
||||
|
||||
var params = {
|
||||
installerId: this.installerId,
|
||||
mimetype: "application/x-xpinstall",
|
||||
|
@ -250,7 +253,7 @@ InstallTriggerManager.prototype = {
|
|||
* @return The callback ID, an integer identifying this callback.
|
||||
*/
|
||||
addCallback: function(aCallback, aUrls) {
|
||||
if (!aCallback)
|
||||
if (!aCallback || typeof aCallback != "function")
|
||||
return -1;
|
||||
var callbackId = 0;
|
||||
while (callbackId in this.callbacks)
|
||||
|
|
|
@ -92,6 +92,7 @@ _BROWSER_FILES = head.js \
|
|||
browser_httphash3.js \
|
||||
browser_httphash4.js \
|
||||
browser_httphash5.js \
|
||||
browser_badargs.js \
|
||||
unsigned.xpi \
|
||||
signed.xpi \
|
||||
signed2.xpi \
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
// Test whether passing a simple string to InstallTrigger.install throws an
|
||||
// exception
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
var triggers = encodeURIComponent(JSON.stringify(TESTROOT + "unsigned.xpi"));
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
// Allow the in-page load handler to run first
|
||||
executeSoon(page_loaded);
|
||||
}, true);
|
||||
gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
|
||||
}
|
||||
|
||||
function page_loaded() {
|
||||
var doc = gBrowser.contentDocument;
|
||||
is(doc.getElementById("return").textContent, "exception", "installTrigger should have failed");
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
Загрузка…
Ссылка в новой задаче