SourceText(originalSourceId) { try { return await this.#getOriginalSourceText(originalSourceId); } catch (error) { const message = L10N.getFormatStr( "toolbox.sourceMapSourceFailure", error.message, error.metadata ? error.metadata.url : "" ); // Note that tests may not pass the targetCommand if (this.#targetCommand) { // Catch all errors and log them to the Web Console for users to see. this.#targetCommand.targetFront.logWarningInPage(message, "source map"); } // Also replace the result with the error text. // Note that this result has to have the same form // as whatever the upstream getOriginalSourceText // returns. return { text: message, contentType: "text/plain", }; } } clearSourceMaps = this.task("clearSourceMaps"); getOriginalStackFrames = this.task("getOriginalStackFrames"); async setSourceMapForGeneratedSources(generatedIds, sourceMap) { const rv = await this.#setSourceMapForGeneratedSources( generatedIds, sourceMap ); // Notify and ensure waiting for the SourceMapURLService to process the source map before resolving. // Otherwise tests start failing because of pending request made by this component. await this.emitAsync("source-map-created", generatedIds); return rv; } clearSourceMapForGeneratedSources = this.task( "clearSourceMapForGeneratedSources" ); destroy() { // Request to stop the underlying DOM Worker this.stop(); // Unregister all listeners this.clearEvents(); // SourceMapLoader may be leaked and so it is important to clear most outer references this.#targetCommand = null; } } EventEmitter.decorate(SourceMapLoader.prototype); module.exports = { SourceMapLoader, originalToGeneratedId, generatedToOriginalId, isGeneratedId, isOriginalId, }; PK