Bug 1250430 - Remove SrcDir loader support from devtools. r=jryans

This commit is contained in:
Alexandre Poirot 2016-02-27 04:51:11 -08:00
parent 1e96ba50cf
commit 0e5e11ebc6
12 changed files with 6 additions and 312 deletions

View File

@ -563,11 +563,6 @@ Toolbox.prototype = {
let toggleKey = this.doc.getElementById("toolbox-toggle-host-key");
toggleKey.addEventListener("command", this.switchToPreviousHost.bind(this), true);
if (Services.prefs.prefHasUserValue("devtools.loader.srcdir")) {
let reloadKey = this.doc.getElementById("tools-reload-key");
reloadKey.addEventListener("command", this.reload.bind(this), true);
}
// Split console uses keypress instead of command so the event can be
// cancelled with stopPropagation on the keypress, and not preventDefault.
this.doc.addEventListener("keypress", this._splitConsoleOnKeypress, false);
@ -1702,11 +1697,6 @@ Toolbox.prototype = {
return newHost;
},
reload: function () {
const {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {});
devtools.reload(true);
},
/**
* Switch to the last used host for the toolbox UI.
* This is determined by the devtools.toolbox.previousHost pref.

View File

@ -94,10 +94,6 @@
key="&toolboxToggle.key;"
oncommand="void(0);"
modifiers="accel shift"/>
<key id="tools-reload-key"
key="&toolboxReload.key;"
oncommand="void(0);"
modifiers="accel alt"/>
</keyset>
<popupset>

View File

@ -75,9 +75,6 @@
<!ENTITY key_zoomin2 "=">
<!ENTITY key_zoomout "-">
<!ENTITY key_resetzoom "0">
<!-- reload WebIDE and devtools from local checkout -->
<!-- this binding is with accel+alt, whereas all others are just accel -->
<!ENTITY key_reload_devtools "R">
<!ENTITY projectPanel_myProjects "My Projects">
<!ENTITY projectPanel_runtimeApps "Runtime Apps">

View File

@ -1155,12 +1155,5 @@ var Cmds = {
resetZoom: function() {
UI.contentViewer.fullZoom = 1;
Services.prefs.setCharPref("devtools.webide.zoom", 1);
},
reloadDevtools: function(event) {
if (Services.prefs.prefHasUserValue("devtools.loader.srcdir")) {
let {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {});
devtools.reload();
}
}
};

View File

@ -58,7 +58,6 @@
<command id="cmd_zoomin" label="&viewMenu_zoomin_label;" oncommand="Cmds.zoomIn()"/>
<command id="cmd_zoomout" label="&viewMenu_zoomout_label;" oncommand="Cmds.zoomOut()"/>
<command id="cmd_resetzoom" label="&viewMenu_resetzoom_label;" oncommand="Cmds.resetZoom()"/>
<command id="cmd_reload_devtools" oncommand="Cmds.reloadDevtools()"/>
</commandset>
</commandset>
@ -116,7 +115,6 @@
<key key="&key_zoomin2;" id="key_zoomin2" command="cmd_zoomin" modifiers="accel"/>
<key key="&key_zoomout;" id="key_zoomout" command="cmd_zoomout" modifiers="accel"/>
<key key="&key_resetzoom;" id="key_resetzoom" command="cmd_resetzoom" modifiers="accel"/>
<key key="&key_reload_devtools;" id="key_reload_devtools" command="cmd_reload_devtools" modifiers="accel alt"/>
</keyset>
<tooltip id="aHTMLTooltip" page="true"/>

View File

@ -22,7 +22,7 @@ var { Loader } = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js",
var promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
this.EXPORTED_SYMBOLS = ["DevToolsLoader", "devtools", "BuiltinProvider",
"SrcdirProvider", "require", "loader"];
"require", "loader"];
/**
* Providers are different strategies for loading the devtools.
@ -88,8 +88,6 @@ BuiltinProvider.prototype = {
id: "fx-devtools",
modules: loaderModules,
paths: {
// When you add a line to this mapping, don't forget to make a
// corresponding addition to the SrcdirProvider mapping below as well.
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"": "resource://gre/modules/commonjs/",
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
@ -124,125 +122,6 @@ BuiltinProvider.prototype = {
},
};
/**
* Used when the tools should be loaded from a mozilla-central checkout. In
* addition to different paths, it needs to write chrome.manifest files to
* override chrome urls from the builtin tools.
*/
function SrcdirProvider() {}
SrcdirProvider.prototype = {
fileURI: function(path) {
let file = new FileUtils.File(path);
return Services.io.newFileURI(file).spec;
},
load: function() {
let srcDir = Services.prefs.getComplexValue("devtools.loader.srcdir",
Ci.nsISupportsString);
srcDir = OS.Path.normalize(srcDir.data.trim());
let devtoolsDir = OS.Path.join(srcDir, "devtools");
let sharedDir = OS.Path.join(devtoolsDir, "shared");
let modulesDir = OS.Path.join(srcDir, "toolkit", "modules");
let devtoolsURI = this.fileURI(devtoolsDir);
let gcliURI = this.fileURI(OS.Path.join(sharedDir,
"gcli", "source", "lib", "gcli"));
let promiseURI = this.fileURI(OS.Path.join(modulesDir,
"Promise-backend.js"));
let acornURI = this.fileURI(OS.Path.join(sharedDir, "acorn"));
let acornWalkURI = OS.Path.join(acornURI, "walk.js");
let sourceMapURI = this.fileURI(OS.Path.join(sharedDir,
"sourcemap", "source-map.js"));
this.loader = new Loader.Loader({
id: "fx-devtools",
modules: loaderModules,
paths: {
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"": "resource://gre/modules/commonjs/",
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"devtools": devtoolsURI,
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"gcli": gcliURI,
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"promise": promiseURI,
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"acorn": acornURI,
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"acorn/util/walk": acornWalkURI,
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
"source-map": sourceMapURI,
// ⚠ DISCUSSION ON DEV-DEVELOPER-TOOLS REQUIRED BEFORE MODIFYING ⚠
},
globals: this.globals,
invisibleToDebugger: this.invisibleToDebugger,
sharedGlobal: true,
sharedGlobalBlocklist,
});
return this._writeManifest(srcDir).then(null, Cu.reportError);
},
unload: function(reason) {
Loader.unload(this.loader, reason);
delete this.loader;
},
_readFile: function(filename) {
let deferred = promise.defer();
let file = new FileUtils.File(filename);
NetUtil.asyncFetch({
uri: NetUtil.newURI(file),
loadUsingSystemPrincipal: true
}, (inputStream, status) => {
if (!Components.isSuccessCode(status)) {
deferred.reject(new Error("Couldn't load manifest: " + filename + "\n"));
return;
}
var data = NetUtil.readInputStreamToString(inputStream, inputStream.available());
deferred.resolve(data);
});
return deferred.promise;
},
_writeFile: function(filename, data) {
let promise = OS.File.writeAtomic(filename, data, {encoding: "utf-8"});
return promise.then(null, (ex) => new Error("Couldn't write manifest: " + ex + "\n"));
},
_writeManifest: function(srcDir) {
let clientDir = OS.Path.join(srcDir, "devtools", "client");
return this._readFile(OS.Path.join(clientDir, "jar.mn")).then((data) => {
// The file data is contained within inputStream.
// You can read it into a string with
let entries = [];
let lines = data.split(/\n/);
let preprocessed = /^\s*\*/;
let contentEntry = /^\s+content\/(\S+)\s+\((\S+)\)/;
for (let line of lines) {
if (preprocessed.test(line)) {
dump("Unable to override preprocessed file: " + line + "\n");
continue;
}
let match = contentEntry.exec(line);
if (match) {
let pathComponents = match[2].split("/");
pathComponents.unshift(clientDir);
let path = OS.Path.join.apply(OS.Path, pathComponents);
let uri = this.fileURI(path);
let chromeURI = "chrome://devtools/content/" + match[1];
let entry = "override " + chromeURI + "\t" + uri;
entries.push(entry);
}
}
return this._writeFile(OS.Path.join(clientDir, "chrome.manifest"),
entries.join("\n"));
}).then(() => {
let clientDirFile = new FileUtils.File(clientDir);
Components.manager.addBootstrappedManifestLocation(clientDirFile);
});
}
};
var gNextLoaderID = 0;
/**
@ -264,7 +143,7 @@ this.DevToolsLoader = function DevToolsLoader() {
DevToolsLoader.prototype = {
get provider() {
if (!this._provider) {
this._chooseProvider();
this._loadProvider();
}
return this._provider;
},
@ -286,7 +165,7 @@ DevToolsLoader.prototype = {
*/
require: function() {
if (!this._provider) {
this._chooseProvider();
this._loadProvider();
}
return this.require.apply(this, arguments);
},
@ -431,12 +310,8 @@ DevToolsLoader.prototype = {
/**
* Choose a default tools provider based on the preferences.
*/
_chooseProvider: function() {
if (Services.prefs.prefHasUserValue("devtools.loader.srcdir")) {
this.setProvider(new SrcdirProvider());
} else {
this.setProvider(new BuiltinProvider());
}
_loadProvider: function() {
this.setProvider(new BuiltinProvider());
},
/**
@ -450,7 +325,7 @@ DevToolsLoader.prototype = {
this._provider.unload("reload");
delete this._provider;
delete this._mainid;
this._chooseProvider();
this._loadProvider();
this.main("devtools/client/main");
},

View File

@ -75,7 +75,6 @@ exports.devtoolsModules = [
"devtools/shared/gcli/commands/rulers",
"devtools/shared/gcli/commands/screenshot",
"devtools/shared/gcli/commands/security",
"devtools/shared/gcli/commands/tools",
];
/**

View File

@ -27,5 +27,4 @@ DevToolsModules(
'rulers.js',
'screenshot.js',
'security.js',
'tools.js',
)

View File

@ -1,99 +0,0 @@
/* 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 { Cc, Ci, Cu } = require("chrome");
const Services = require("Services");
const { OS } = require("resource://gre/modules/osfile.jsm");
const { devtools } = require("resource://devtools/shared/Loader.jsm");
const gcli = require("gcli/index");
const l10n = require("gcli/l10n");
const BRAND_SHORT_NAME = Cc["@mozilla.org/intl/stringbundle;1"]
.getService(Ci.nsIStringBundleService)
.createBundle("chrome://branding/locale/brand.properties")
.GetStringFromName("brandShortName");
exports.items = [
{
name: "tools",
description: l10n.lookupFormat("toolsDesc2", [ BRAND_SHORT_NAME ]),
manual: l10n.lookupFormat("toolsManual2", [ BRAND_SHORT_NAME ]),
get hidden() {
return gcli.hiddenByChromePref();
}
},
{
item: "command",
runAt: "client",
name: "tools srcdir",
description: l10n.lookup("toolsSrcdirDesc"),
manual: l10n.lookupFormat("toolsSrcdirManual2", [ BRAND_SHORT_NAME ]),
get hidden() {
return gcli.hiddenByChromePref();
},
params: [
{
name: "srcdir",
type: "string" /* {
name: "file",
filetype: "directory",
existing: "yes"
} */,
description: l10n.lookup("toolsSrcdirDir")
}
],
returnType: "string",
exec: function(args, context) {
let clobber = OS.Path.join(args.srcdir, "CLOBBER");
return OS.File.exists(clobber).then(function(exists) {
if (exists) {
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = args.srcdir;
Services.prefs.setComplexValue("devtools.loader.srcdir",
Ci.nsISupportsString, str);
devtools.reload();
return l10n.lookupFormat("toolsSrcdirReloaded2", [ args.srcdir ]);
}
return l10n.lookupFormat("toolsSrcdirNotFound2", [ args.srcdir ]);
});
}
},
{
item: "command",
runAt: "client",
name: "tools builtin",
description: l10n.lookup("toolsBuiltinDesc"),
manual: l10n.lookup("toolsBuiltinManual"),
get hidden() {
return gcli.hiddenByChromePref();
},
returnType: "string",
exec: function(args, context) {
Services.prefs.clearUserPref("devtools.loader.srcdir");
devtools.reload();
return l10n.lookup("toolsBuiltinReloaded");
}
},
{
item: "command",
runAt: "client",
name: "tools reload",
description: l10n.lookup("toolsReloadDesc"),
get hidden() {
return gcli.hiddenByChromePref() ||
!Services.prefs.prefHasUserValue("devtools.loader.srcdir");
},
returnType: "string",
exec: function(args, context) {
devtools.reload();
return l10n.lookup("toolsReloaded2");
}
}
];

View File

@ -26,7 +26,6 @@ this.EXPORTED_SYMBOLS = [
"DevToolsLoader",
"devtools",
"BuiltinProvider",
"SrcdirProvider",
"require",
"loader"
];

View File

@ -5,4 +5,3 @@ skip-if = buildapp == 'b2g' || os == 'android'
[test_eventemitter_basic.html]
[test_devtools_extensions.html]
skip-if = os == 'linux' && debug # Bug 1205739
[test_loader_paths.html]

View File

@ -1,52 +0,0 @@
<!DOCTYPE html>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<meta charset="utf8">
<title></title>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<script type="application/javascript;version=1.8">
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const SRCDIR_PREF = "devtools.loader.srcdir";
let srcDir = Cc["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("CurWorkD", Components.interfaces.nsIFile).path;
let srcDirStr = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
srcDirStr.data = srcDir;
Services.prefs.setComplexValue(SRCDIR_PREF, Ci.nsISupportsString,
srcDirStr);
const { BuiltinProvider, SrcdirProvider } =
Cu.import("resource://devtools/shared/Loader.jsm", {});
let builtin = new BuiltinProvider();
builtin.load();
let srcdir = new SrcdirProvider();
srcdir.load();
is(builtin.loader.mapping.length,
srcdir.loader.mapping.length + 1,
"The built-in loader has one additional mappings.");
Services.prefs.clearUserPref(SRCDIR_PREF);
</script>
</body>
</html>