зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1325191 - Fix Eslint errors in devtools/server/*.js. r=jryans
MozReview-Commit-ID: 6t7lUP2Ip3v
This commit is contained in:
Родитель
252e684884
Коммит
f8ea7f6a39
|
@ -83,11 +83,9 @@ devtools/client/debugger/**
|
|||
devtools/client/framework/**
|
||||
!devtools/client/framework/selection.js
|
||||
!devtools/client/framework/toolbox.js
|
||||
devtools/client/jsonview/lib/**
|
||||
devtools/client/netmonitor/test/**
|
||||
devtools/client/netmonitor/har/test/**
|
||||
devtools/client/projecteditor/**
|
||||
devtools/client/promisedebugger/**
|
||||
devtools/client/responsivedesign/**
|
||||
devtools/client/scratchpad/**
|
||||
devtools/client/shadereditor/**
|
||||
|
@ -104,17 +102,9 @@ devtools/client/webconsole/webconsole-connection-proxy.js
|
|||
devtools/client/webconsole/webconsole.js
|
||||
devtools/client/webide/**
|
||||
!devtools/client/webide/components/webideCli.js
|
||||
devtools/server/*.js
|
||||
devtools/server/*.jsm
|
||||
!devtools/server/child.js
|
||||
!devtools/server/css-logic.js
|
||||
!devtools/server/main.js
|
||||
!devtools/server/websocket-server.js
|
||||
devtools/server/actors/**
|
||||
devtools/server/actors/*.js
|
||||
!devtools/server/actors/csscoverage.js
|
||||
!devtools/server/actors/inspector.js
|
||||
!devtools/server/actors/highlighters/css-grid.js
|
||||
!devtools/server/actors/highlighters/eye-dropper.js
|
||||
!devtools/server/actors/layout.js
|
||||
!devtools/server/actors/string.js
|
||||
!devtools/server/actors/styles.js
|
||||
|
@ -134,7 +124,6 @@ devtools/shared/gcli/**
|
|||
!devtools/shared/gcli/templater.js
|
||||
devtools/shared/heapsnapshot/**
|
||||
devtools/shared/layout/**
|
||||
devtools/shared/locales/**
|
||||
devtools/shared/performance/**
|
||||
!devtools/shared/platform/**
|
||||
devtools/shared/qrcode/**
|
||||
|
|
|
@ -150,12 +150,10 @@ RulersHighlighter.prototype = {
|
|||
} else {
|
||||
dGraduations += `M${i} 0 L${i} ${graduationLength} `;
|
||||
}
|
||||
} else if (i % 50 === 0) {
|
||||
dMarkers += `M0 ${i} L${graduationLength} ${i}`;
|
||||
} else {
|
||||
if (i % 50 === 0) {
|
||||
dMarkers += `M0 ${i} L${graduationLength} ${i}`;
|
||||
} else {
|
||||
dGraduations += `M0 ${i} L${graduationLength} ${i}`;
|
||||
}
|
||||
dGraduations += `M0 ${i} L${graduationLength} ${i}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ function CanvasFrameAnonymousContentHelper(highlighterEnv, nodeBuilder) {
|
|||
this._insert();
|
||||
}
|
||||
|
||||
this._onWindowReady= this._onWindowReady.bind(this);
|
||||
this._onWindowReady = this._onWindowReady.bind(this);
|
||||
this.highlighterEnv.on("window-ready", this._onWindowReady);
|
||||
|
||||
this.listeners = new Map();
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { Ci, Cu } = require("chrome");
|
||||
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||
const { assert, fetch } = DevToolsUtils;
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
@ -137,18 +136,16 @@ TabSources.prototype = {
|
|||
// is the HTML url.
|
||||
originalUrl = source.url;
|
||||
source = null;
|
||||
}
|
||||
else if (this._sourceActors.has(source)) {
|
||||
} else if (this._sourceActors.has(source)) {
|
||||
return this._sourceActors.get(source);
|
||||
}
|
||||
}
|
||||
else if (originalUrl) {
|
||||
} else if (originalUrl) {
|
||||
// Not all "original" scripts are distinctly separate from the
|
||||
// generated script. Pretty-printed sources have a sourcemap for
|
||||
// themselves, so we need to make sure there a real source
|
||||
// doesn't already exist with this URL.
|
||||
for (let [source, actor] of this._sourceActors) {
|
||||
if (source.url === originalUrl) {
|
||||
for (let [sourceData, actor] of this._sourceActors) {
|
||||
if (sourceData.url === originalUrl) {
|
||||
return actor;
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +165,7 @@ TabSources.prototype = {
|
|||
});
|
||||
|
||||
let sourceActorStore = this._thread.sourceActorStore;
|
||||
var id = sourceActorStore.getReusableActorId(source, originalUrl);
|
||||
let id = sourceActorStore.getReusableActorId(source, originalUrl);
|
||||
if (id) {
|
||||
actor.actorID = id;
|
||||
}
|
||||
|
@ -179,15 +176,13 @@ TabSources.prototype = {
|
|||
if (this._autoBlackBox &&
|
||||
!this.neverAutoBlackBoxSources.has(actor.url) &&
|
||||
this._isMinifiedURL(actor.url)) {
|
||||
|
||||
this.blackBox(actor.url);
|
||||
this.neverAutoBlackBoxSources.add(actor.url);
|
||||
}
|
||||
|
||||
if (source) {
|
||||
this._sourceActors.set(source, actor);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this._sourceMappedSourceActors[originalUrl] = actor;
|
||||
}
|
||||
|
||||
|
@ -201,8 +196,7 @@ TabSources.prototype = {
|
|||
// it's something that has been sourcemapped, or it represents
|
||||
// the HTML file that contains inline sources.
|
||||
this.emit("newSource", actor);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// If sourcemapping is enabled and a source has sourcemaps, we
|
||||
// create `SourceActor` instances for both the original and
|
||||
// generated sources. The source actors for the generated
|
||||
|
@ -246,30 +240,29 @@ TabSources.prototype = {
|
|||
}
|
||||
|
||||
throw new Error("getSourceActorByURL: could not find source for " + url);
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if the URL likely points to a minified resource, false
|
||||
* otherwise.
|
||||
*
|
||||
* @param String aURL
|
||||
* The URL to test.
|
||||
* @param String uri
|
||||
* The url to test.
|
||||
* @returns Boolean
|
||||
*/
|
||||
_isMinifiedURL: function (aURL) {
|
||||
if (!aURL) {
|
||||
_isMinifiedURL: function (uri) {
|
||||
if (!uri) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
let url = new URL(aURL);
|
||||
let url = new URL(uri);
|
||||
let pathname = url.pathname;
|
||||
return MINIFIED_SOURCE_REGEXP.test(pathname.slice(pathname.lastIndexOf("/") + 1));
|
||||
} catch (e) {
|
||||
// Not a valid URL so don't try to parse out the filename, just test the
|
||||
// whole thing with the minified source regexp.
|
||||
return MINIFIED_SOURCE_REGEXP.test(aURL);
|
||||
return MINIFIED_SOURCE_REGEXP.test(uri);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -278,19 +271,19 @@ TabSources.prototype = {
|
|||
* source mapping and always returns an actor representing this real
|
||||
* source. Use `createSourceActors` if you want to respect source maps.
|
||||
*
|
||||
* @param Debugger.Source aSource
|
||||
* @param Debugger.Source source
|
||||
* The source instance to create an actor for.
|
||||
* @returns SourceActor
|
||||
*/
|
||||
createNonSourceMappedActor: function (aSource) {
|
||||
createNonSourceMappedActor: function (source) {
|
||||
// Don't use getSourceURL because we don't want to consider the
|
||||
// displayURL property if it's an eval source. We only want to
|
||||
// consider real URLs, otherwise if there is a URL but it's
|
||||
// invalid the code below will not set the content type, and we
|
||||
// will later try to fetch the contents of the URL to figure out
|
||||
// the content type, but it's a made up URL for eval sources.
|
||||
let url = isEvalSource(aSource) ? null : aSource.url;
|
||||
let spec = { source: aSource };
|
||||
let url = isEvalSource(source) ? null : source.url;
|
||||
let spec = { source };
|
||||
|
||||
// XXX bug 915433: We can't rely on Debugger.Source.prototype.text
|
||||
// if the source is an HTML-embedded <script> tag. Since we don't
|
||||
|
@ -301,51 +294,47 @@ TabSources.prototype = {
|
|||
|
||||
// Assume the source is inline if the element that introduced it is not a
|
||||
// script element, or does not have a src attribute.
|
||||
let element = aSource.element ? aSource.element.unsafeDereference() : null;
|
||||
let element = source.element ? source.element.unsafeDereference() : null;
|
||||
if (element && (element.tagName !== "SCRIPT" || !element.hasAttribute("src"))) {
|
||||
spec.isInlineSource = true;
|
||||
} else if (aSource.introductionType === "wasm") {
|
||||
} else if (source.introductionType === "wasm") {
|
||||
// Wasm sources are not JavaScript. Give them their own content-type.
|
||||
spec.contentType = "text/wasm";
|
||||
} else {
|
||||
if (url) {
|
||||
// There are a few special URLs that we know are JavaScript:
|
||||
// inline `javascript:` and code coming from the console
|
||||
if (url.indexOf("Scratchpad/") === 0 ||
|
||||
url.indexOf("javascript:") === 0 ||
|
||||
url === "debugger eval code") {
|
||||
spec.contentType = "text/javascript";
|
||||
} else {
|
||||
try {
|
||||
let pathname = new URL(url).pathname;
|
||||
let filename = pathname.slice(pathname.lastIndexOf("/") + 1);
|
||||
let index = filename.lastIndexOf(".");
|
||||
let extension = index >= 0 ? filename.slice(index + 1) : "";
|
||||
if (extension === "xml") {
|
||||
// XUL inline scripts may not correctly have the
|
||||
// `source.element` property, so do a blunt check here if
|
||||
// it's an xml page.
|
||||
spec.isInlineSource = true;
|
||||
}
|
||||
else if (extension === "js") {
|
||||
spec.contentType = "text/javascript";
|
||||
}
|
||||
} catch (e) {
|
||||
// This only needs to be here because URL is not yet exposed to
|
||||
// workers. (BUG 1258892)
|
||||
const filename = url;
|
||||
const index = filename.lastIndexOf(".");
|
||||
const extension = index >= 0 ? filename.slice(index + 1) : "";
|
||||
if (extension === "js") {
|
||||
spec.contentType = "text/javascript";
|
||||
}
|
||||
} else if (url) {
|
||||
// There are a few special URLs that we know are JavaScript:
|
||||
// inline `javascript:` and code coming from the console
|
||||
if (url.indexOf("Scratchpad/") === 0 ||
|
||||
url.indexOf("javascript:") === 0 ||
|
||||
url === "debugger eval code") {
|
||||
spec.contentType = "text/javascript";
|
||||
} else {
|
||||
try {
|
||||
let pathname = new URL(url).pathname;
|
||||
let filename = pathname.slice(pathname.lastIndexOf("/") + 1);
|
||||
let index = filename.lastIndexOf(".");
|
||||
let extension = index >= 0 ? filename.slice(index + 1) : "";
|
||||
if (extension === "xml") {
|
||||
// XUL inline scripts may not correctly have the
|
||||
// `source.element` property, so do a blunt check here if
|
||||
// it's an xml page.
|
||||
spec.isInlineSource = true;
|
||||
} else if (extension === "js") {
|
||||
spec.contentType = "text/javascript";
|
||||
}
|
||||
} catch (e) {
|
||||
// This only needs to be here because URL is not yet exposed to
|
||||
// workers. (BUG 1258892)
|
||||
const filename = url;
|
||||
const index = filename.lastIndexOf(".");
|
||||
const extension = index >= 0 ? filename.slice(index + 1) : "";
|
||||
if (extension === "js") {
|
||||
spec.contentType = "text/javascript";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Assume the content is javascript if there's no URL
|
||||
spec.contentType = "text/javascript";
|
||||
}
|
||||
} else {
|
||||
// Assume the content is javascript if there's no URL
|
||||
spec.contentType = "text/javascript";
|
||||
}
|
||||
|
||||
return this.source(spec);
|
||||
|
@ -354,24 +343,24 @@ TabSources.prototype = {
|
|||
/**
|
||||
* This is an internal function that returns a promise of an array
|
||||
* of source actors representing all the source mapped sources of
|
||||
* `aSource`, or `null` if the source is not sourcemapped or
|
||||
* `source`, or `null` if the source is not sourcemapped or
|
||||
* sourcemapping is disabled. Users should call `createSourceActors`
|
||||
* instead of this.
|
||||
*
|
||||
* @param Debugger.Source aSource
|
||||
* @param Debugger.Source source
|
||||
* The source instance to create actors for.
|
||||
* @return Promise of an array of source actors
|
||||
*/
|
||||
_createSourceMappedActors: function (aSource) {
|
||||
if (!this._useSourceMaps || !aSource.sourceMapURL) {
|
||||
_createSourceMappedActors: function (source) {
|
||||
if (!this._useSourceMaps || !source.sourceMapURL) {
|
||||
return resolve(null);
|
||||
}
|
||||
|
||||
return this.fetchSourceMap(aSource)
|
||||
return this.fetchSourceMap(source)
|
||||
.then(map => {
|
||||
if (map) {
|
||||
return map.sources.map(s => {
|
||||
return this.source({ originalUrl: s, generatedSource: aSource });
|
||||
return this.source({ originalUrl: s, generatedSource: source });
|
||||
}).filter(isNotNull);
|
||||
}
|
||||
return null;
|
||||
|
@ -380,97 +369,94 @@ TabSources.prototype = {
|
|||
|
||||
/**
|
||||
* Creates the source actors representing the appropriate sources
|
||||
* of `aSource`. If sourcemapped, returns actors for all of the original
|
||||
* of `source`. If sourcemapped, returns actors for all of the original
|
||||
* sources, otherwise returns a 1-element array with the actor for
|
||||
* `aSource`.
|
||||
* `source`.
|
||||
*
|
||||
* @param Debugger.Source aSource
|
||||
* @param Debugger.Source source
|
||||
* The source instance to create actors for.
|
||||
* @param Promise of an array of source actors
|
||||
*/
|
||||
createSourceActors: function (aSource) {
|
||||
return this._createSourceMappedActors(aSource).then(actors => {
|
||||
let actor = this.createNonSourceMappedActor(aSource);
|
||||
createSourceActors: function (source) {
|
||||
return this._createSourceMappedActors(source).then(actors => {
|
||||
let actor = this.createNonSourceMappedActor(source);
|
||||
return (actors || [actor]).filter(isNotNull);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a promise of a SourceMapConsumer for the source map for
|
||||
* `aSource`; if we already have such a promise extant, return that.
|
||||
* `source`; if we already have such a promise extant, return that.
|
||||
* This will fetch the source map if we don't have a cached object
|
||||
* and source maps are enabled (see `_fetchSourceMap`).
|
||||
*
|
||||
* @param Debugger.Source aSource
|
||||
* @param Debugger.Source source
|
||||
* The source instance to get sourcemaps for.
|
||||
* @return Promise of a SourceMapConsumer
|
||||
*/
|
||||
fetchSourceMap: function (aSource) {
|
||||
fetchSourceMap: function (source) {
|
||||
if (!this._useSourceMaps) {
|
||||
return resolve(null);
|
||||
}
|
||||
else if (this._sourceMaps.has(aSource)) {
|
||||
return this._sourceMaps.get(aSource);
|
||||
}
|
||||
else if (!aSource || !aSource.sourceMapURL) {
|
||||
} else if (this._sourceMaps.has(source)) {
|
||||
return this._sourceMaps.get(source);
|
||||
} else if (!source || !source.sourceMapURL) {
|
||||
return resolve(null);
|
||||
}
|
||||
|
||||
let sourceMapURL = aSource.sourceMapURL;
|
||||
if (aSource.url) {
|
||||
sourceMapURL = joinURI(aSource.url, sourceMapURL);
|
||||
let sourceMapURL = source.sourceMapURL;
|
||||
if (source.url) {
|
||||
sourceMapURL = joinURI(source.url, sourceMapURL);
|
||||
}
|
||||
let result = this._fetchSourceMap(sourceMapURL, aSource.url);
|
||||
let result = this._fetchSourceMap(sourceMapURL, source.url);
|
||||
|
||||
// The promises in `_sourceMaps` must be the exact same instances
|
||||
// as returned by `_fetchSourceMap` for `clearSourceMapCache` to
|
||||
// work.
|
||||
this._sourceMaps.set(aSource, result);
|
||||
this._sourceMaps.set(source, result);
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a promise of a SourceMapConsumer for the source map for
|
||||
* `aSource`. The resolved result may be null if the source does not
|
||||
* `source`. The resolved result may be null if the source does not
|
||||
* have a source map or source maps are disabled.
|
||||
*/
|
||||
getSourceMap: function (aSource) {
|
||||
return resolve(this._sourceMaps.get(aSource));
|
||||
getSourceMap: function (source) {
|
||||
return resolve(this._sourceMaps.get(source));
|
||||
},
|
||||
|
||||
/**
|
||||
* Set a SourceMapConsumer for the source map for
|
||||
* |aSource|.
|
||||
* Set a SourceMapConsumer for the source map for |source|.
|
||||
*/
|
||||
setSourceMap: function (aSource, aMap) {
|
||||
this._sourceMaps.set(aSource, resolve(aMap));
|
||||
setSourceMap: function (source, map) {
|
||||
this._sourceMaps.set(source, resolve(map));
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a promise of a SourceMapConsumer for the source map located at
|
||||
* |aAbsSourceMapURL|, which must be absolute. If there is already such a
|
||||
* |absSourceMapURL|, which must be absolute. If there is already such a
|
||||
* promise extant, return it. This will not fetch if source maps are
|
||||
* disabled.
|
||||
*
|
||||
* @param string aAbsSourceMapURL
|
||||
* @param string absSourceMapURL
|
||||
* The source map URL, in absolute form, not relative.
|
||||
* @param string aScriptURL
|
||||
* @param string sourceURL
|
||||
* When the source map URL is a data URI, there is no sourceRoot on the
|
||||
* source map, and the source map's sources are relative, we resolve
|
||||
* them from aScriptURL.
|
||||
* them from sourceURL.
|
||||
*/
|
||||
_fetchSourceMap: function (aAbsSourceMapURL, aSourceURL) {
|
||||
_fetchSourceMap: function (absSourceMapURL, sourceURL) {
|
||||
assert(this._useSourceMaps,
|
||||
"Cannot fetch sourcemaps if they are disabled");
|
||||
|
||||
if (this._sourceMapCache[aAbsSourceMapURL]) {
|
||||
return this._sourceMapCache[aAbsSourceMapURL];
|
||||
if (this._sourceMapCache[absSourceMapURL]) {
|
||||
return this._sourceMapCache[absSourceMapURL];
|
||||
}
|
||||
|
||||
let fetching = fetch(aAbsSourceMapURL, { loadFromCache: false })
|
||||
let fetching = fetch(absSourceMapURL, { loadFromCache: false })
|
||||
.then(({ content }) => {
|
||||
let map = new SourceMapConsumer(content);
|
||||
this._setSourceMapRoot(map, aAbsSourceMapURL, aSourceURL);
|
||||
this._setSourceMapRoot(map, absSourceMapURL, sourceURL);
|
||||
return map;
|
||||
})
|
||||
.then(null, error => {
|
||||
|
@ -479,31 +465,31 @@ TabSources.prototype = {
|
|||
}
|
||||
return null;
|
||||
});
|
||||
this._sourceMapCache[aAbsSourceMapURL] = fetching;
|
||||
this._sourceMapCache[absSourceMapURL] = fetching;
|
||||
return fetching;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the source map's sourceRoot to be relative to the source map url.
|
||||
*/
|
||||
_setSourceMapRoot: function (aSourceMap, aAbsSourceMapURL, aScriptURL) {
|
||||
_setSourceMapRoot: function (sourceMap, absSourceMapURL, scriptURL) {
|
||||
// No need to do this fiddling if we won't be fetching any sources over the
|
||||
// wire.
|
||||
if (aSourceMap.hasContentsOfAllSources()) {
|
||||
if (sourceMap.hasContentsOfAllSources()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const base = this._dirname(
|
||||
aAbsSourceMapURL.indexOf("data:") === 0
|
||||
? aScriptURL
|
||||
: aAbsSourceMapURL);
|
||||
aSourceMap.sourceRoot = aSourceMap.sourceRoot
|
||||
? joinURI(base, aSourceMap.sourceRoot)
|
||||
absSourceMapURL.indexOf("data:") === 0
|
||||
? scriptURL
|
||||
: absSourceMapURL);
|
||||
sourceMap.sourceRoot = sourceMap.sourceRoot
|
||||
? joinURI(base, sourceMap.sourceRoot)
|
||||
: base;
|
||||
},
|
||||
|
||||
_dirname: function (aPath) {
|
||||
let url = new URL(aPath);
|
||||
_dirname: function (path) {
|
||||
let url = new URL(path);
|
||||
let href = url.href;
|
||||
return href.slice(0, href.lastIndexOf("/"));
|
||||
},
|
||||
|
@ -516,18 +502,18 @@ TabSources.prototype = {
|
|||
* this just removes the Debugger.Source cache, but you can remove
|
||||
* the lower-level URL cache with the `hard` option.
|
||||
*
|
||||
* @param aSourceMapURL string
|
||||
* @param sourceMapURL string
|
||||
* The source map URL to uncache
|
||||
* @param opts object
|
||||
* An object with the following properties:
|
||||
* - hard: Also remove the lower-level URL cache, which will
|
||||
* make us completely forget about the source map.
|
||||
*/
|
||||
clearSourceMapCache: function (aSourceMapURL, opts = { hard: false }) {
|
||||
let oldSm = this._sourceMapCache[aSourceMapURL];
|
||||
clearSourceMapCache: function (sourceMapURL, opts = { hard: false }) {
|
||||
let oldSm = this._sourceMapCache[sourceMapURL];
|
||||
|
||||
if (opts.hard) {
|
||||
delete this._sourceMapCache[aSourceMapURL];
|
||||
delete this._sourceMapCache[sourceMapURL];
|
||||
}
|
||||
|
||||
if (oldSm) {
|
||||
|
@ -547,15 +533,14 @@ TabSources.prototype = {
|
|||
* (pretty-printing is the use case). Generate a random url if one
|
||||
* isn't specified, allowing you to set "anonymous" source maps.
|
||||
*
|
||||
* @param aSource Debugger.Source
|
||||
* @param source Debugger.Source
|
||||
* The source to change the sourceMapURL property
|
||||
* @param aUrl string
|
||||
* @param url string
|
||||
* The source map URL (optional)
|
||||
* @param aMap SourceMapConsumer
|
||||
* @param map SourceMapConsumer
|
||||
* The source map instance
|
||||
*/
|
||||
setSourceMapHard: function (aSource, aUrl, aMap) {
|
||||
let url = aUrl;
|
||||
setSourceMapHard: function (source, url, map) {
|
||||
if (!url) {
|
||||
// This is a littly hacky, but we want to forcefully set a
|
||||
// sourcemap regardless of sourcemap settings. We want to
|
||||
|
@ -566,31 +551,31 @@ TabSources.prototype = {
|
|||
// just make a fake URL and stick the sourcemap there.
|
||||
url = "internal://sourcemap" + (this._anonSourceMapId++) + "/";
|
||||
}
|
||||
aSource.sourceMapURL = url;
|
||||
source.sourceMapURL = url;
|
||||
|
||||
// Forcefully set the sourcemap cache. This will be used even if
|
||||
// sourcemaps are disabled.
|
||||
this._sourceMapCache[url] = resolve(aMap);
|
||||
this.emit("updatedSource", this.getSourceActor(aSource));
|
||||
this._sourceMapCache[url] = resolve(map);
|
||||
this.emit("updatedSource", this.getSourceActor(source));
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the non-source-mapped location of the given Debugger.Frame. If the
|
||||
* frame does not have a script, the location's properties are all null.
|
||||
*
|
||||
* @param Debugger.Frame aFrame
|
||||
* @param Debugger.Frame frame
|
||||
* The frame whose location we are getting.
|
||||
* @returns Object
|
||||
* Returns an object of the form { source, line, column }
|
||||
*/
|
||||
getFrameLocation: function (aFrame) {
|
||||
if (!aFrame || !aFrame.script) {
|
||||
getFrameLocation: function (frame) {
|
||||
if (!frame || !frame.script) {
|
||||
return new GeneratedLocation();
|
||||
}
|
||||
let {lineNumber, columnNumber} =
|
||||
aFrame.script.getOffsetLocation(aFrame.offset);
|
||||
frame.script.getOffsetLocation(frame.offset);
|
||||
return new GeneratedLocation(
|
||||
this.createNonSourceMappedActor(aFrame.script.source),
|
||||
this.createNonSourceMappedActor(frame.script.source),
|
||||
lineNumber,
|
||||
columnNumber
|
||||
);
|
||||
|
@ -610,7 +595,6 @@ TabSources.prototype = {
|
|||
generatedColumn
|
||||
} = generatedLocation;
|
||||
let source = generatedSourceActor.source;
|
||||
let url = source ? source.url : generatedSourceActor._originalUrl;
|
||||
|
||||
// In certain scenarios the source map may have not been fetched
|
||||
// yet (or at least tied to this Debugger.Source instance), so use
|
||||
|
@ -684,7 +668,6 @@ TabSources.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Returns a promise of the location in the generated source corresponding to
|
||||
* the original source and line given.
|
||||
|
@ -735,69 +718,69 @@ TabSources.prototype = {
|
|||
/**
|
||||
* Returns true if URL for the given source is black boxed.
|
||||
*
|
||||
* @param aURL String
|
||||
* @param url String
|
||||
* The URL of the source which we are checking whether it is black
|
||||
* boxed or not.
|
||||
*/
|
||||
isBlackBoxed: function (aURL) {
|
||||
return this.blackBoxedSources.has(aURL);
|
||||
isBlackBoxed: function (url) {
|
||||
return this.blackBoxedSources.has(url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the given source URL to the set of sources that are black boxed.
|
||||
*
|
||||
* @param aURL String
|
||||
* @param url String
|
||||
* The URL of the source which we are black boxing.
|
||||
*/
|
||||
blackBox: function (aURL) {
|
||||
this.blackBoxedSources.add(aURL);
|
||||
blackBox: function (url) {
|
||||
this.blackBoxedSources.add(url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove the given source URL to the set of sources that are black boxed.
|
||||
*
|
||||
* @param aURL String
|
||||
* @param url String
|
||||
* The URL of the source which we are no longer black boxing.
|
||||
*/
|
||||
unblackBox: function (aURL) {
|
||||
this.blackBoxedSources.delete(aURL);
|
||||
unblackBox: function (url) {
|
||||
this.blackBoxedSources.delete(url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if the given URL is pretty printed.
|
||||
*
|
||||
* @param aURL String
|
||||
* @param url String
|
||||
* The URL of the source that might be pretty printed.
|
||||
*/
|
||||
isPrettyPrinted: function (aURL) {
|
||||
return this.prettyPrintedSources.has(aURL);
|
||||
isPrettyPrinted: function (url) {
|
||||
return this.prettyPrintedSources.has(url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the given URL to the set of sources that are pretty printed.
|
||||
*
|
||||
* @param aURL String
|
||||
* @param url String
|
||||
* The URL of the source to be pretty printed.
|
||||
*/
|
||||
prettyPrint: function (aURL, aIndent) {
|
||||
this.prettyPrintedSources.set(aURL, aIndent);
|
||||
prettyPrint: function (url, indent) {
|
||||
this.prettyPrintedSources.set(url, indent);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the indent the given URL was pretty printed by.
|
||||
*/
|
||||
prettyPrintIndent: function (aURL) {
|
||||
return this.prettyPrintedSources.get(aURL);
|
||||
prettyPrintIndent: function (url) {
|
||||
return this.prettyPrintedSources.get(url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove the given URL from the set of sources that are pretty printed.
|
||||
*
|
||||
* @param aURL String
|
||||
* @param url String
|
||||
* The URL of the source that is no longer pretty printed.
|
||||
*/
|
||||
disablePrettyPrint: function (aURL) {
|
||||
this.prettyPrintedSources.delete(aURL);
|
||||
disablePrettyPrint: function (url) {
|
||||
this.prettyPrintedSources.delete(url);
|
||||
},
|
||||
|
||||
iter: function () {
|
||||
|
@ -817,16 +800,16 @@ TabSources.prototype = {
|
|||
* Checks if a source should never be displayed to the user because
|
||||
* it's either internal or we don't support in the UI yet.
|
||||
*/
|
||||
function isHiddenSource(aSource) {
|
||||
function isHiddenSource(source) {
|
||||
// Ignore the internal Function.prototype script
|
||||
return aSource.text === "() {\n}";
|
||||
return source.text === "() {\n}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if its argument is not null.
|
||||
*/
|
||||
function isNotNull(aThing) {
|
||||
return aThing !== null;
|
||||
function isNotNull(thing) {
|
||||
return thing !== null;
|
||||
}
|
||||
|
||||
exports.TabSources = TabSources;
|
||||
|
|
|
@ -6,10 +6,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var { Cu, CC, Ci, Cc } = require("chrome");
|
||||
const { Cu, CC } = require("chrome");
|
||||
|
||||
const { DebuggerServer } = require("devtools/server/main");
|
||||
const promise = require("promise");
|
||||
|
||||
/**
|
||||
* Support for actor registration. Main used by ActorRegistryActor
|
||||
|
|
|
@ -24,7 +24,10 @@ const GRAPHENE_ID = "{d1bfe7d9-c01e-4237-998b-7b5f960a4314}";
|
|||
*/
|
||||
if (!Services.appinfo
|
||||
|| Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT
|
||||
|| Services.appinfo.ID === undefined /* XPCShell */
|
||||
|
||||
/* XPCShell */
|
||||
|| Services.appinfo.ID === undefined
|
||||
|
||||
|| Services.appinfo.ID == B2G_ID
|
||||
|| Services.appinfo.ID == GRAPHENE_ID
|
||||
|| !AddonPathService) {
|
||||
|
@ -35,8 +38,7 @@ if (!Services.appinfo
|
|||
module.exports = function mapURIToAddonId(uri) {
|
||||
try {
|
||||
return AddonPathService.mapURIToAddonId(uri);
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
DevToolsUtils.reportException("mapURIToAddonId", e);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
* matched.
|
||||
*/
|
||||
|
||||
const {Ci, Cu} = require("chrome");
|
||||
|
||||
/**
|
||||
* The WalkerIndex class indexes the document (and all subdocs) from
|
||||
* a given walker.
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
/* 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/. */
|
||||
|
||||
const {Cc, Ci, Cu, components} = require("chrome");
|
||||
"use strict";
|
||||
|
||||
const {Cc, Ci, components} = require("chrome");
|
||||
const {isWindowIncluded} = require("devtools/shared/layout/utils");
|
||||
const Services = require("Services");
|
||||
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
@ -31,8 +36,7 @@ function ConsoleServiceListener(window, listener) {
|
|||
}
|
||||
exports.ConsoleServiceListener = ConsoleServiceListener;
|
||||
|
||||
ConsoleServiceListener.prototype =
|
||||
{
|
||||
ConsoleServiceListener.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIConsoleListener]),
|
||||
|
||||
/**
|
||||
|
@ -196,8 +200,7 @@ function ConsoleAPIListener(window, owner, {addonId} = {}) {
|
|||
}
|
||||
exports.ConsoleAPIListener = ConsoleAPIListener;
|
||||
|
||||
ConsoleAPIListener.prototype =
|
||||
{
|
||||
ConsoleAPIListener.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||
|
||||
/**
|
||||
|
@ -384,8 +387,7 @@ function ConsoleReflowListener(window, listener) {
|
|||
|
||||
exports.ConsoleReflowListener = ConsoleReflowListener;
|
||||
|
||||
ConsoleReflowListener.prototype =
|
||||
{
|
||||
ConsoleReflowListener.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
docshell: null,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {Cc, Ci, Cu, components} = require("chrome");
|
||||
const {Ci, Cu} = require("chrome");
|
||||
|
||||
// Note that this is only used in WebConsoleCommands, see $0 and pprint().
|
||||
if (!isWorker) {
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* 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/. */
|
||||
|
||||
/* global setConsoleEventHandler, retrieveConsoleEvents */
|
||||
|
||||
"use strict";
|
||||
|
||||
// This file is loaded on the server side for worker debugging.
|
||||
|
@ -18,18 +20,17 @@ function ConsoleAPIListener(window, owner, consoleID) {
|
|||
this.observe = this.observe.bind(this);
|
||||
}
|
||||
|
||||
ConsoleAPIListener.prototype =
|
||||
{
|
||||
ConsoleAPIListener.prototype = {
|
||||
init: function () {
|
||||
setConsoleEventHandler(this.observe);
|
||||
},
|
||||
destroy: function () {
|
||||
setConsoleEventHandler(null);
|
||||
},
|
||||
observe: function(message) {
|
||||
observe: function (message) {
|
||||
this.owner.onConsoleAPICall(message.wrappedJSObject);
|
||||
},
|
||||
getCachedMessages: function() {
|
||||
getCachedMessages: function () {
|
||||
return retrieveConsoleEvents();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -34,8 +34,9 @@ exports.removeContentGlobal = function (options) {
|
|||
return undefined;
|
||||
};
|
||||
|
||||
function getGlobalCache(aInnerWindowID) {
|
||||
return globalsCache[aInnerWindowID] = globalsCache[aInnerWindowID] || [];
|
||||
function getGlobalCache(innerWindowID) {
|
||||
globalsCache[innerWindowID] = globalsCache[innerWindowID] || [];
|
||||
return globalsCache[innerWindowID];
|
||||
}
|
||||
|
||||
// when the window is destroyed, eliminate the associated globals cache
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
const Cu = Components.utils;
|
||||
const { utils: Cu, interfaces: Ci } = Components;
|
||||
|
||||
/* exported init */
|
||||
this.EXPORTED_SYMBOLS = ["init"];
|
||||
|
||||
let gLoader;
|
||||
|
|
|
@ -149,8 +149,9 @@ var parsers = [
|
|||
const MAX_NESTED_HANDLER_COUNT = 2;
|
||||
for (let i = 0; i < MAX_NESTED_HANDLER_COUNT; i++) {
|
||||
let funcDO = getFirstFunctionVariable(handlerDO);
|
||||
if (!funcDO)
|
||||
if (!funcDO) {
|
||||
return handlerDO;
|
||||
}
|
||||
|
||||
handlerDO = funcDO;
|
||||
if (isFunctionInProxy(handlerDO)) {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const { on, once, off, emit } = require("sdk/event/core");
|
||||
const { Class } = require("sdk/core/heritage");
|
||||
|
||||
const WebGLPrimitivesType = {
|
||||
|
@ -23,7 +22,7 @@ const WebGLPrimitivesType = {
|
|||
const WebGLDrawArrays = "drawArrays";
|
||||
const WebGLDrawElements = "drawElements";
|
||||
|
||||
var WebGLPrimitiveCounter = exports.WebGLPrimitiveCounter = Class({
|
||||
exports.WebGLPrimitiveCounter = Class({
|
||||
initialize: function (tabActor) {
|
||||
this.tabActor = tabActor;
|
||||
},
|
||||
|
@ -45,7 +44,7 @@ var WebGLPrimitiveCounter = exports.WebGLPrimitiveCounter = Class({
|
|||
* Stops monitoring primitive draws, returning the recorded values.
|
||||
*/
|
||||
getCounts: function () {
|
||||
var result = {
|
||||
let result = {
|
||||
tris: this._tris,
|
||||
vertices: this._vertices,
|
||||
points: this._points,
|
||||
|
@ -155,6 +154,7 @@ var WebGLPrimitiveCounter = exports.WebGLPrimitiveCounter = Class({
|
|||
case WebGLPrimitivesType.TRIANGLE_FAN:
|
||||
this._tris += (count - 2);
|
||||
this._vertices += count;
|
||||
break;
|
||||
default:
|
||||
console.error("_processDrawElements doesn't define this type.");
|
||||
break;
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
* 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/. */
|
||||
|
||||
/* global addMessageListener */
|
||||
|
||||
"use strict";
|
||||
|
||||
let { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
let swm = Cc["@mozilla.org/serviceworkers/manager;1"].
|
||||
getService(Ci.nsIServiceWorkerManager);
|
||||
let { classes: Cc, interfaces: Ci } = Components;
|
||||
let swm = Cc["@mozilla.org/serviceworkers/manager;1"]
|
||||
.getService(Ci.nsIServiceWorkerManager);
|
||||
|
||||
addMessageListener("serviceWorkerRegistration:start", message => {
|
||||
let { data } = message;
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* eslint-env worker */
|
||||
/* global worker, loadSubScript, global */
|
||||
|
||||
// This function is used to do remote procedure calls from the worker to the
|
||||
// main thread. It is exposed as a built-in global to every module by the
|
||||
// worker loader. To make sure the worker loader can access it, it needs to be
|
||||
|
@ -42,14 +49,14 @@ this.addEventListener("message", function (event) {
|
|||
let packet = JSON.parse(event.data);
|
||||
switch (packet.type) {
|
||||
case "connect":
|
||||
// Step 3: Create a connection to the parent.
|
||||
// Step 3: Create a connection to the parent.
|
||||
let connection = DebuggerServer.connectToParent(packet.id, this);
|
||||
connections[packet.id] = {
|
||||
connection : connection,
|
||||
connection,
|
||||
rpcs: []
|
||||
};
|
||||
|
||||
// Step 4: Create a thread actor for the connection to the parent.
|
||||
// Step 4: Create a thread actor for the connection to the parent.
|
||||
let pool = new ActorPool(connection);
|
||||
connection.addActorPool(pool);
|
||||
|
||||
|
@ -87,8 +94,8 @@ this.addEventListener("message", function (event) {
|
|||
let consoleActor = new WebConsoleActor(connection, parent);
|
||||
pool.addActor(consoleActor);
|
||||
|
||||
// Step 5: Send a response packet to the parent to notify
|
||||
// it that a connection has been established.
|
||||
// Step 5: Send a response packet to the parent to notify
|
||||
// it that a connection has been established.
|
||||
postMessage(JSON.stringify({
|
||||
type: "connected",
|
||||
id: packet.id,
|
||||
|
|
Загрузка…
Ссылка в новой задаче