зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1523942 - Remove unused addonID/addonPath from SourceActor. r=jlast
Differential Revision: https://phabricator.services.mozilla.com/D18244 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1755b722eb
Коммит
b44981a1ea
|
@ -6,8 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { Cc, Ci } = require("chrome");
|
||||
const Services = require("Services");
|
||||
const { Ci } = require("chrome");
|
||||
const { BreakpointActor, setBreakpointAtEntryPoints } = require("devtools/server/actors/breakpoint");
|
||||
const { GeneratedLocation } = require("devtools/server/actors/common");
|
||||
const { createValueGrip } = require("devtools/server/actors/object/utils");
|
||||
|
@ -18,7 +17,6 @@ const { joinURI } = require("devtools/shared/path");
|
|||
const { sourceSpec } = require("devtools/shared/specs/source");
|
||||
const { findClosestScriptBySource } = require("devtools/server/actors/utils/closest-scripts");
|
||||
|
||||
loader.lazyRequireGetter(this, "mapURIToAddonID", "devtools/server/actors/utils/map-uri-to-addon-id");
|
||||
loader.lazyRequireGetter(this, "arrayBufferGrip", "devtools/server/actors/array-buffer", true);
|
||||
|
||||
function isEvalSource(source) {
|
||||
|
@ -72,39 +70,6 @@ function getSourceURL(source, window) {
|
|||
|
||||
exports.getSourceURL = getSourceURL;
|
||||
|
||||
/**
|
||||
* Resolve a URI back to physical file.
|
||||
*
|
||||
* Of course, this works only for URIs pointing to local resources.
|
||||
*
|
||||
* @param uri
|
||||
* URI to resolve
|
||||
* @return
|
||||
* resolved nsIURI
|
||||
*/
|
||||
function resolveURIToLocalPath(uri) {
|
||||
let resolved;
|
||||
switch (uri.scheme) {
|
||||
case "jar":
|
||||
case "file":
|
||||
return uri;
|
||||
|
||||
case "chrome":
|
||||
resolved = Cc["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Ci.nsIChromeRegistry).convertChromeURL(uri);
|
||||
return resolveURIToLocalPath(resolved);
|
||||
|
||||
case "resource":
|
||||
resolved = Cc["@mozilla.org/network/protocol;1?name=resource"]
|
||||
.getService(Ci.nsIResProtocolHandler).resolveURI(uri);
|
||||
uri = Services.io.newURI(resolved);
|
||||
return resolveURIToLocalPath(uri);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A SourceActor provides information about the source of a script. There
|
||||
* are two kinds of source actors: ones that represent real source objects,
|
||||
|
@ -150,8 +115,6 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
this.onSource = this.onSource.bind(this);
|
||||
this._getSourceText = this._getSourceText.bind(this);
|
||||
|
||||
this._mapSourceToAddon();
|
||||
|
||||
this._init = null;
|
||||
},
|
||||
|
||||
|
@ -180,12 +143,6 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
}
|
||||
return this._originalUrl;
|
||||
},
|
||||
get addonID() {
|
||||
return this._addonID;
|
||||
},
|
||||
get addonPath() {
|
||||
return this._addonPath;
|
||||
},
|
||||
|
||||
get isCacheEnabled() {
|
||||
if (this.threadActor._parent._getCacheDisabled) {
|
||||
|
@ -206,8 +163,6 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
return {
|
||||
actor: this.actorID,
|
||||
url: this.url ? this.url.split(" -> ").pop() : null,
|
||||
addonID: this._addonID,
|
||||
addonPath: this._addonPath,
|
||||
isBlackBoxed: this.threadActor.sources.isBlackBoxed(this.url),
|
||||
sourceMapURL: source ? source.sourceMapURL : null,
|
||||
introductionUrl: introductionUrl ? introductionUrl.split(" -> ").pop() : null,
|
||||
|
@ -240,55 +195,6 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
return this.dbg.findScripts(query);
|
||||
},
|
||||
|
||||
_mapSourceToAddon: function() {
|
||||
let nsuri;
|
||||
try {
|
||||
nsuri = Services.io.newURI(this.url.split(" -> ").pop());
|
||||
} catch (e) {
|
||||
// We can't do anything with an invalid URI
|
||||
return;
|
||||
}
|
||||
|
||||
const localURI = resolveURIToLocalPath(nsuri);
|
||||
if (!localURI) {
|
||||
return;
|
||||
}
|
||||
|
||||
const id = mapURIToAddonID(localURI);
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
this._addonID = id;
|
||||
|
||||
if (localURI instanceof Ci.nsIJARURI) {
|
||||
// The path in the add-on is easy for jar: uris
|
||||
this._addonPath = localURI.JAREntry;
|
||||
} else if (localURI instanceof Ci.nsIFileURL) {
|
||||
// For file: uris walk up to find the last directory that is part of the
|
||||
// add-on
|
||||
const target = localURI.file;
|
||||
let path = target.leafName;
|
||||
|
||||
// We can assume that the directory containing the source file is part
|
||||
// of the add-on
|
||||
let root = target.parent;
|
||||
let file = root.parent;
|
||||
while (file && mapURIToAddonID(Services.io.newFileURI(file))) {
|
||||
path = root.leafName + "/" + path;
|
||||
root = file;
|
||||
file = file.parent;
|
||||
}
|
||||
|
||||
if (!file) {
|
||||
const error = new Error("Could not find the root of the add-on for " + this.url);
|
||||
DevToolsUtils.reportException("SourceActor.prototype._mapSourceToAddon", error);
|
||||
return;
|
||||
}
|
||||
|
||||
this._addonPath = path;
|
||||
}
|
||||
},
|
||||
|
||||
_reportLoadSourceError: function(error) {
|
||||
try {
|
||||
DevToolsUtils.reportException("SourceActor", error);
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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";
|
||||
|
||||
const {Cu} = require("chrome");
|
||||
|
||||
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||
const Services = require("Services");
|
||||
const {WebExtensionPolicy} = Cu.getGlobalForObject(Services);
|
||||
|
||||
const B2G_ID = "{3c2e2abc-06d4-11e1-ac3b-374f68613e61}";
|
||||
const GRAPHENE_ID = "{d1bfe7d9-c01e-4237-998b-7b5f960a4314}";
|
||||
|
||||
/**
|
||||
* This is a wrapper around amIAddonPathService.mapURIToAddonID which always returns
|
||||
* false on B2G and graphene to avoid loading the add-on manager there and
|
||||
* reports any exceptions rather than throwing so that the caller doesn't have
|
||||
* to worry about them.
|
||||
*/
|
||||
if (!Services.appinfo
|
||||
|| Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT
|
||||
|| Services.appinfo.ID === undefined /* XPCShell */
|
||||
|| Services.appinfo.ID == B2G_ID
|
||||
|| Services.appinfo.ID == GRAPHENE_ID
|
||||
|| !WebExtensionPolicy) {
|
||||
module.exports = function mapURIToAddonId(uri) {
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
module.exports = function mapURIToAddonId(uri) {
|
||||
try {
|
||||
const policy = WebExtensionPolicy.getByURI(uri);
|
||||
return policy && policy.id;
|
||||
} catch (e) {
|
||||
DevToolsUtils.reportException("mapURIToAddonId", e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
|
@ -18,7 +18,6 @@ DevToolsModules(
|
|||
'event-loop.js',
|
||||
'function-call.js',
|
||||
'make-debugger.js',
|
||||
'map-uri-to-addon-id.js',
|
||||
'shapes-utils.js',
|
||||
'source-actor-store.js',
|
||||
'stack.js',
|
||||
|
|
Загрузка…
Ссылка в новой задаче