зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1403130 - Support result as value grip on WebExtension InspectorWindow actor eval method. r=ochameau
MozReview-Commit-ID: Efxhsm4bApu --HG-- extra : rebase_source : 3c5b4ff02858b03c878a24089354914f557d4e9a
This commit is contained in:
Родитель
9239725b9a
Коммит
af1538b456
|
@ -501,6 +501,30 @@ var WebExtensionInspectedWindowActor = protocol.ActorClassWithSpec(
|
|||
|
||||
if (evalResult) {
|
||||
try {
|
||||
// Return the evalResult as a grip (used by the WebExtensions
|
||||
// devtools inspector's sidebar.setExpression API method).
|
||||
if (options.evalResultAsGrip) {
|
||||
if (!options.toolboxConsoleActorID) {
|
||||
return {
|
||||
exceptionInfo: {
|
||||
isError: true,
|
||||
code: "E_PROTOCOLERROR",
|
||||
description: "Inspector protocol error: %s - %s",
|
||||
details: [
|
||||
"Unexpected invalid sidebar panel expression request",
|
||||
"missing toolboxConsoleActorID",
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
let consoleActor = DebuggerServer.searchAllConnectionsForActor(
|
||||
options.toolboxConsoleActorID
|
||||
);
|
||||
|
||||
return {valueGrip: consoleActor.createValueGrip(evalResult)};
|
||||
}
|
||||
|
||||
if (evalResult && typeof evalResult === "object") {
|
||||
evalResult = evalResult.unsafeDereference();
|
||||
}
|
||||
|
|
|
@ -99,6 +99,43 @@ add_task(function* test_successfull_inspectedWindowEval_result() {
|
|||
yield teardown({client});
|
||||
});
|
||||
|
||||
add_task(function* test_successfull_inspectedWindowEval_resultAsGrip() {
|
||||
const {client, inspectedWindowFront, form} = yield setup(MAIN_DOMAIN);
|
||||
let result = yield inspectedWindowFront.eval(FAKE_CALLER_INFO, "window", {
|
||||
evalResultAsGrip: true,
|
||||
toolboxConsoleActorID: form.consoleActor
|
||||
});
|
||||
|
||||
ok(result.valueGrip, "Got a result from inspectedWindow eval");
|
||||
ok(result.valueGrip.actor, "Got a object actor as expected");
|
||||
is(result.valueGrip.type, "object", "Got a value grip of type object");
|
||||
is(result.valueGrip.class, "Window", "Got a value grip which is instanceof Location");
|
||||
|
||||
// Test invalid evalResultAsGrip request.
|
||||
result = yield inspectedWindowFront.eval(
|
||||
FAKE_CALLER_INFO, "window", {evalResultAsGrip: true}
|
||||
);
|
||||
|
||||
ok(!result.value && !result.valueGrip,
|
||||
"Got a null result from the invalid inspectedWindow eval call");
|
||||
ok(result.exceptionInfo.isError, "Got an API Error result from inspectedWindow eval");
|
||||
ok(!result.exceptionInfo.isException, "An error isException is false as expected");
|
||||
is(result.exceptionInfo.code, "E_PROTOCOLERROR",
|
||||
"Got the expected 'code' property in the error result");
|
||||
is(result.exceptionInfo.description, "Inspector protocol error: %s - %s",
|
||||
"Got the expected 'description' property in the error result");
|
||||
is(result.exceptionInfo.details.length, 2,
|
||||
"The 'details' array property should contains 1 element");
|
||||
is(result.exceptionInfo.details[0],
|
||||
"Unexpected invalid sidebar panel expression request",
|
||||
"Got the expected content in the error results's details");
|
||||
is(result.exceptionInfo.details[1],
|
||||
"missing toolboxConsoleActorID",
|
||||
"Got the expected content in the error results's details");
|
||||
|
||||
yield teardown({client});
|
||||
});
|
||||
|
||||
add_task(function* test_error_inspectedWindowEval_result() {
|
||||
const {client, inspectedWindowFront} = yield setup(MAIN_DOMAIN);
|
||||
const result = yield inspectedWindowFront.eval(FAKE_CALLER_INFO, "window", {});
|
||||
|
|
|
@ -37,6 +37,10 @@ types.addDictType("webExtensionEvalOptions", {
|
|||
contextSecurityOrigin: "nullable:string",
|
||||
useContentScriptContext: "nullable:boolean",
|
||||
|
||||
// Return the evalResult as a grip (used by the WebExtensions
|
||||
// devtools inspector's sidebar.setExpression API method).
|
||||
evalResultAsGrip: "nullable:boolean",
|
||||
|
||||
// The actor ID of the node selected in the inspector if any,
|
||||
// used to provide the '$0' binding.
|
||||
toolboxSelectedNodeActorID: "nullable:string",
|
||||
|
@ -73,6 +77,7 @@ types.addDictType("webExtensionEvalResult", {
|
|||
// The following properties are set if the evaluation has been
|
||||
// completed successfully.
|
||||
value: "nullable:json",
|
||||
valueGrip: "nullable:json",
|
||||
// The following properties are set if the evalutation has been
|
||||
// completed with errors.
|
||||
exceptionInfo: "nullable:webExtensionEvalExceptionInfo",
|
||||
|
|
Загрузка…
Ссылка в новой задаче