/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * A WebConsoleFront is used as a front end for the WebConsoleActor that is * created on the server, hiding implementation details. * * @param object client * The DevToolsClient instance we live for.
*/ class WebConsoleFront extends FrontClassWithSpec(webconsoleSpec) {
constructor(client, targetFront, parentFront) { super(client, targetFront, parentFront); this._client = client; this.events = [];
// Attribute name from which to retrieve the actorID out of the target actor's form this.formAttributeName = "consoleActor";
beforeConsoleAPICall(packet) { if (packet.message && Array.isArray(packet.message.arguments)) { // We might need to create fronts for each of the message arguments.
packet.message.arguments = packet.message.arguments.map(arg =>
getAdHocFrontOrPrimitiveGrip(arg, this)
);
} return packet;
}
beforePageError(packet) { if (packet?.pageError?.errorMessage) {
packet.pageError.errorMessage = getAdHocFrontOrPrimitiveGrip(
packet.pageError.errorMessage, this
);
}
if (packet?.pageError?.exception) {
packet.pageError.exception = getAdHocFrontOrPrimitiveGrip(
packet.pageError.exception, this
);
} return packet;
}
async getCachedMessages(messageTypes) { const response = await super.getCachedMessages(messageTypes); if (Array.isArray(response.messages)) {
response.messages = response.messages.map(packet => { if (Array.isArray(packet?.message?.arguments)) { // We might need to create fronts for each of the message arguments.
packet.message.arguments = packet.message.arguments.map(arg =>
getAdHocFrontOrPrimitiveGrip(arg, this)
);
}
if (packet.pageError?.exception) {
packet.pageError.exception = getAdHocFrontOrPrimitiveGrip(
packet.pageError.exception, this
);
}
return packet;
});
} return response;
}
/** * Close the WebConsoleFront. *
*/
destroy() { if (!this._client) { returnnull;
}
// This will make future calls to this function harmless because of the early return // at the top of the function. this._client = null;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.