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 (evalResult) {
if ("return" in evalResult) { if ("return" in evalResult) {
result = evalResult.return; result = evalResult.return;
} } else if ("yield" in evalResult) {
else if ("yield" in evalResult) {
result = evalResult.yield; result = evalResult.yield;
} } else if ("throw" in evalResult) {
else if ("throw" in evalResult) {
let error = evalResult.throw; let error = evalResult.throw;
errorGrip = this.createValueGrip(error); errorGrip = this.createValueGrip(error);
let errorToString = evalInfo.window errorMessage = error && (typeof error === "object")
.evalInGlobalWithBindings("ex + ''", {ex: error}); ? error.unsafeDereference().toString()
if (errorToString && typeof errorToString.return == "string") { : "" + error;
errorMessage = errorToString.return;
}
} }
} }

View File

@ -23,7 +23,11 @@ function startTest() {
removeEventListener("load", startTest); removeEventListener("load", startTest);
attachConsole([], state => { attachConsole([], state => {
gState = state; gState = state;
let tests = [checkQuerySelectorAll, checkQuerySelectorAllNotExist]; let tests = [
checkQuerySelectorAll,
checkQuerySelectorAllNotExist,
checkQuerySelectorAllException
];
runTests(tests, testEnd); runTests(tests, testEnd);
}, true); }, true);
} }
@ -54,6 +58,23 @@ let checkQuerySelectorAllNotExist = Task.async(function*() {
nextTest(); 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) { function basicResultCheck(response, input, output) {
checkObject(response, { checkObject(response, {
from: gState.actor, from: gState.actor,