Я пытаюсь оценить код javascript по протоколу удаленной отладки из Node.js в Firefox.
Я отправляю следующие сообщения:
31:{"to":"root","type":"listTabs"}
После этого я получаю списоквкладки, одна из них может выглядеть так:
{
"actor": "server1.conn0.child1/frameTarget1",
"traits": { "isBrowsingContext": true },
"title": "New Tab",
"url": "about:home",
"outerWindowID": 5,
"consoleActor": "server1.conn0.child1/consoleActor2",
"inspectorActor": "server1.conn0.child1/inspectorActor3",
"styleSheetsActor": "server1.conn0.child1/styleSheetsActor4",
"storageActor": "server1.conn0.child1/storageActor5",
"memoryActor": "server1.conn0.child1/memoryActor6",
"framerateActor": "server1.conn0.child1/framerateActor7",
"reflowActor": "server1.conn0.child1/reflowActor8",
"cssPropertiesActor": "server1.conn0.child1/cssPropertiesActor9",
"performanceActor": "server1.conn0.child1/performanceActor10",
"animationsActor": "server1.conn0.child1/animationsActor11",
"promisesActor": "server1.conn0.child1/promisesActor12",
"emulationActor": "server1.conn0.child1/emulationActor13",
"webExtensionInspectedWindowActor": "server1.conn0.child1/webExtensionInspectedWindowActor14",
"accessibilityActor": "server1.conn0.child1/accessibilityActor15",
"screenshotActor": "server1.conn0.child1/screenshotActor16",
"changesActor": "server1.conn0.child1/changesActor17",
"webSocketActor": "server1.conn0.child1/webSocketActor18",
"manifestActor": "server1.conn0.child1/manifestActor19"
}
Затем я пытаюсь отправить сообщение evaluateJS
на одну из вкладок, например:
83:{"to":"server1.conn0.child1/consoleActor2","type":"evaluateJS","text":"alert('d')"}
Но ответэто:
{
"from": "server1.conn0.child1/consoleActor2",
"error": "unknownError",
"message": "this.parentActor.threadActor is undefined"
}
Что не так?Как я могу оценить JS по удаленной отладке?
На самом деле я обнаружил проблемную строку в коде Firefox (которую мне пришлось искать в любом случае, так как никто не удосужился документировать удаленную отладку):
/**
* Handler for the "evaluateJS" request. This method evaluates the given
* JavaScript string and sends back the result.
*
* @param object request
* The JSON request object received from the Web Console client.
* @return object
* The evaluation response packet.
*/
/* eslint-disable complexity */
evaluateJS: function(request) {
const input = request.text;
const timestamp = Date.now();
const evalOptions = {
frameActor: request.frameActor,
url: request.url,
selectedNodeActor: request.selectedNodeActor,
selectedObjectActor: request.selectedObjectActor,
};
const { mapped } = request;
// Set a flag on the thread actor which indicates an evaluation is being
// done for the client. This can affect how debugger handlers behave.
this.parentActor.threadActor.insideClientEvaluation = true;
const evalInfo = evalWithDebugger(input, evalOptions, this);
this.parentActor.threadActor.insideClientEvaluation = false;