Bug 1384943 - add initial implementation of SourceMapServiceWrapper; r?bgrins
This adds a simple wrapper for the source map service. This wrapper
logs errors using console.error, preserving the status quo from before
this series.
MozReview-Commit-ID: 2ckUZaerrcJ
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -539,18 +539,30 @@ Toolbox.prototype = {
/**
* Unconditionally create and get the source map service.
*/
_createSourceMapService: function () {
if (this._sourceMapService) {
return this._sourceMapService;
}
// Uses browser loader to access the `Worker` global.
- this._sourceMapService =
- this.browserRequire("devtools/client/shared/source-map/index");
+ let service = this.browserRequire("devtools/client/shared/source-map/index");
+
+ // Provide a wrapper for the service that reports errors more nicely.
+ this._sourceMapService = new Proxy(service, {
+ get: (target, name) => {
+ if (name === "getOriginalURLs") {
+ return (urlInfo) => {
+ return target.getOriginalURLs(urlInfo).catch(console.error);
+ };
+ }
+ return target[name];
+ },
+ });
+
this._sourceMapService.startSourceMapWorker(SOURCE_MAP_WORKER);
return this._sourceMapService;
},
/**
* A common access point for the client-side mapping service for source maps that
* any panel can use. This is a "low-level" API that connects to
* the source map worker.