Bug 1173385 - Calling $$("") should throw an exception. r=fitzgen

This commit is contained in:
Florent Fayolle 2015-06-15 14:22:00 -04:00
parent 09c0e2cd11
commit d4141a4a01
2 changed files with 27 additions and 10 deletions

View File

@ -811,18 +811,14 @@ WebConsoleActor.prototype =
if (evalResult) {
if ("return" in evalResult) {
result = evalResult.return;
}
else if ("yield" in evalResult) {
} else if ("yield" in evalResult) {
result = evalResult.yield;
}
else if ("throw" in evalResult) {
} else if ("throw" in evalResult) {
let error = evalResult.throw;
errorGrip = this.createValueGrip(error);
let errorToString = evalInfo.window
.evalInGlobalWithBindings("ex + ''", {ex: error});
if (errorToString && typeof errorToString.return == "string") {
errorMessage = errorToString.return;
}
errorMessage = error && (typeof error === "object")
? error.unsafeDereference().toString()
: "" + error;
}
}

View File

@ -23,7 +23,11 @@ function startTest() {
removeEventListener("load", startTest);
attachConsole([], state => {
gState = state;
let tests = [checkQuerySelectorAll, checkQuerySelectorAllNotExist];
let tests = [
checkQuerySelectorAll,
checkQuerySelectorAllNotExist,
checkQuerySelectorAllException
];
runTests(tests, testEnd);
}, true);
}
@ -54,6 +58,23 @@ let checkQuerySelectorAllNotExist = Task.async(function*() {
nextTest();
});
let checkQuerySelectorAllException = Task.async(function*() {
info ("$$ returns an exception if an invalid selector was provided");
let response = yield evaluateJS("$$(':foo')");
checkObject(response, {
input: "$$(':foo')",
exceptionMessage: "SyntaxError: An invalid or illegal string was specified",
exception: {
preview: {
kind: "DOMException",
name: "SyntaxError",
message: "An invalid or illegal string was specified"
}
}
});
nextTest();
});
function basicResultCheck(response, input, output) {
checkObject(response, {
from: gState.actor,