Bug 912121 - Create shims for popular DevTools modules in add-ons. rs=devtools

For popular modules used by many DevTools add-ons, add shim files which wrap the
modules and make them available at their previous location.

Each shim includes a deprecation warning to make devs and users aware of the
issue.
This commit is contained in:
J. Ryan Stinnett 2015-09-17 16:28:42 -05:00
parent 79ff031964
commit a22f0c942b
18 changed files with 319 additions and 59 deletions

View File

@ -27,6 +27,7 @@ DIRS += [
'scratchpad',
'shadereditor',
'shared',
'shims',
'sourceeditor',
'storage',
'styleeditor',

View File

@ -0,0 +1,36 @@
/* 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";
/**
* This file only exists to support add-ons which import this module at a
* specific path.
*/
const Cu = Components.utils;
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const WARNING_PREF = "devtools.migration.warnings";
if (Services.prefs.getBoolPref(WARNING_PREF)) {
const { Deprecated } = Cu.import("resource://gre/modules/Deprecated.jsm", {});
Deprecated.warning("This path to gDevTools.jsm is deprecated. Please use " +
"Cu.import(\"resource:///modules/devtools/client/" +
"framework/gDevTools.jsm\") to load this module.",
"https://bugzil.la/912121");
}
this.EXPORTED_SYMBOLS = [
"gDevTools",
"DevTools",
"gDevToolsBrowser"
];
const module =
Cu.import("resource:///modules/devtools/client/framework/gDevTools.jsm", {});
for (let symbol of this.EXPORTED_SYMBOLS) {
this[symbol] = module[symbol];
}

View File

@ -0,0 +1,13 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
# Unlike most DevTools build files, this file does not use DevToolsModules
# because these files are here for add-on compatibility, and so they must be
# installed to previously defined locations.
EXTRA_JS_MODULES.devtools += [
'gDevTools.jsm',
]

View File

@ -1,26 +0,0 @@
/* -*- indent-tabs-mode: nil; 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";
/**
* Loads the remote debugging protocol code into a sandbox, in order to
* shield it from the debuggee. This way, when debugging chrome globals,
* debugger and debuggee will be in separate compartments.
*/
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
const { require } = Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
this.EXPORTED_SYMBOLS = ["DebuggerServer", "ActorPool"];
var server = require("devtools/server/main");
this.DebuggerServer = server.DebuggerServer;
this.ActorPool = server.ActorPool;
this.OriginalLocation = server.OriginalLocation;

View File

@ -8,6 +8,7 @@ include('../templates.mozbuild')
DIRS += [
'actors',
'shims',
]
BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
@ -30,7 +31,6 @@ DevToolsModules(
'child.js',
'content-globals.js',
'content-server.jsm',
'dbg-server.jsm',
'main.js',
'protocol.js',
'worker.js'

View File

@ -0,0 +1,37 @@
/* 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";
/**
* This file only exists to support add-ons which import this module at a
* specific path.
*/
const Cu = Components.utils;
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const WARNING_PREF = "devtools.migration.warnings";
if (Services.prefs.getBoolPref(WARNING_PREF)) {
const { Deprecated } = Cu.import("resource://gre/modules/Deprecated.jsm", {});
Deprecated.warning("dbg-server.jsm is deprecated. Please use " +
"require(\"devtools/server/main\") to load this " +
"module.",
"https://bugzil.la/912121");
}
this.EXPORTED_SYMBOLS = [
"DebuggerServer",
"ActorPool",
"OriginalLocation",
];
const { require } =
Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
const module = require("devtools/server/main");
for (let symbol of this.EXPORTED_SYMBOLS) {
this[symbol] = module[symbol];
}

View File

@ -0,0 +1,13 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
# Unlike most DevTools build files, this file does not use DevToolsModules
# because these files are here for add-on compatibility, and so they must be
# installed to previously defined locations.
EXTRA_JS_MODULES.devtools += [
'dbg-server.jsm',
]

View File

@ -1,29 +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";
// Just a compatibility wrapper for addons that are used
// to import the jsm instead of the js module
const Cu = Components.utils;
const { require } = Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
this.EXPORTED_SYMBOLS = ["DebuggerTransport",
"DebuggerClient",
"RootClient",
"LongStringClient",
"EnvironmentClient",
"ObjectClient"];
var client = require("devtools/shared/client/main");
this.DebuggerClient = client.DebuggerClient;
this.RootClient = client.RootClient;
this.LongStringClient = client.LongStringClient;
this.EnvironmentClient = client.EnvironmentClient;
this.ObjectClient = client.ObjectClient;
this.DebuggerTransport = require("devtools/shared/transport/transport").DebuggerTransport;

View File

@ -6,6 +6,5 @@
DevToolsModules(
'connection-manager.js',
'dbg-client.jsm',
'main.js',
)

View File

@ -21,6 +21,7 @@ DIRS += [
'security',
'sourcemap',
'shared',
'shims',
'styleinspector',
'tern',
'touch',

View File

@ -0,0 +1,35 @@
/* 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";
/**
* This file only exists to support add-ons which import this module at a
* specific path.
*/
const Cu = Components.utils;
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const WARNING_PREF = "devtools.migration.warnings";
if (Services.prefs.getBoolPref(WARNING_PREF)) {
const { Deprecated } = Cu.import("resource://gre/modules/Deprecated.jsm", {});
Deprecated.warning("This path to Console.jsm is deprecated. Please use " +
"Cu.import(\"resource://gre/modules/devtools/shared/" +
"Console.jsm\") to load this module.",
"https://bugzil.la/912121");
}
this.EXPORTED_SYMBOLS = [
"console",
"ConsoleAPI"
];
const module =
Cu.import("resource://gre/modules/devtools/shared/Console.jsm", {});
for (let symbol of this.EXPORTED_SYMBOLS) {
this[symbol] = module[symbol];
}

View File

@ -0,0 +1,39 @@
/* 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";
/**
* This file only exists to support add-ons which import this module at a
* specific path.
*/
const Cu = Components.utils;
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const WARNING_PREF = "devtools.migration.warnings";
if (Services.prefs.getBoolPref(WARNING_PREF)) {
const { Deprecated } = Cu.import("resource://gre/modules/Deprecated.jsm", {});
Deprecated.warning("This path to Loader.jsm is deprecated. Please use " +
"Cu.import(\"resource://gre/modules/devtools/shared/" +
"Loader.jsm\") to load this module.",
"https://bugzil.la/912121");
}
this.EXPORTED_SYMBOLS = [
"DevToolsLoader",
"devtools",
"BuiltinProvider",
"SrcdirProvider",
"require",
"loader"
];
const module =
Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
for (let symbol of this.EXPORTED_SYMBOLS) {
this[symbol] = module[symbol];
}

View File

@ -0,0 +1,34 @@
/* 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";
/**
* This file only exists to support add-ons which import this module at a
* specific path.
*/
const Cu = Components.utils;
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const WARNING_PREF = "devtools.migration.warnings";
if (Services.prefs.getBoolPref(WARNING_PREF)) {
const { Deprecated } = Cu.import("resource://gre/modules/Deprecated.jsm", {});
Deprecated.warning("This path to Simulator.jsm is deprecated. Please use " +
"Cu.import(\"resource://gre/modules/devtools/shared/" +
"apps/Simulator.jsm\") to load this module.",
"https://bugzil.la/912121");
}
this.EXPORTED_SYMBOLS = [
"Simulator",
];
const module =
Cu.import("resource://gre/modules/devtools/shared/apps/Simulator.jsm", {});
for (let symbol of this.EXPORTED_SYMBOLS) {
this[symbol] = module[symbol];
}

View File

@ -0,0 +1,43 @@
/* 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";
/**
* This file only exists to support add-ons which import this module at a
* specific path.
*/
const Cu = Components.utils;
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
const WARNING_PREF = "devtools.migration.warnings";
if (Services.prefs.getBoolPref(WARNING_PREF)) {
const { Deprecated } = Cu.import("resource://gre/modules/Deprecated.jsm", {});
Deprecated.warning("dbg-client.jsm is deprecated. Please use " +
"require(\"devtools/shared/client/main\") to load this " +
"module.", "https://bugzil.la/912121");
}
const { require } =
Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
this.EXPORTED_SYMBOLS = ["DebuggerTransport",
"DebuggerClient",
"RootClient",
"LongStringClient",
"EnvironmentClient",
"ObjectClient"];
let client = require("devtools/shared/client/main");
this.DebuggerClient = client.DebuggerClient;
this.RootClient = client.RootClient;
this.LongStringClient = client.LongStringClient;
this.EnvironmentClient = client.EnvironmentClient;
this.ObjectClient = client.ObjectClient;
this.DebuggerTransport =
require("devtools/shared/transport/transport").DebuggerTransport;

View File

@ -0,0 +1,42 @@
/* 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";
/**
* This file only exists to support add-ons which import this module at a
* specific path.
*/
(function (factory) { // Module boilerplate
if (this.module && module.id.indexOf("event-emitter") >= 0) { // require
factory.call(this, require, exports, module);
} else { // Cu.import
const Cu = Components.utils;
const { require } =
Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
this.isWorker = false;
this.promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
factory.call(this, require, this, { exports: this });
this.EXPORTED_SYMBOLS = ["EventEmitter"];
}
}).call(this, function (require, exports, module) {
const { Cu } = require("chrome");
const Services = require("Services");
const WARNING_PREF = "devtools.migration.warnings";
// Cu and Services aren't accessible from workers
if (Cu && Services && Services.prefs &&
Services.prefs.getBoolPref(WARNING_PREF)) {
const { Deprecated } =
Cu.import("resource://gre/modules/Deprecated.jsm", {});
Deprecated.warning("This path to event-emitter.js is deprecated. Please " +
"use require(\"devtools/shared/event-emitter\") to " +
"load this module.",
"https://bugzil.la/912121");
}
const EventEmitter = require("devtools/shared/event-emitter");
this.EventEmitter = EventEmitter;
module.exports = EventEmitter;
});

View File

@ -0,0 +1,17 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
# Unlike most DevTools build files, this file does not use DevToolsModules
# because these files are here for add-on compatibility, and so they must be
# installed to previously defined locations.
EXTRA_JS_MODULES.devtools += [
'Console.jsm',
'dbg-client.jsm',
'event-emitter.js',
'Loader.jsm',
'Simulator.jsm',
]

View File

@ -19,8 +19,9 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186
const DEBUGGER_USB_ENABLED = "devtools.remote.usb.enabled";
Cu.import("resource://gre/modules/Services.jsm");
const { DebuggerServer } =
Cu.import("resource://gre/modules/devtools/server/dbg-server.jsm", {});
const { require } =
Cu.import("resource://gre/modules/devtools/shared/Loader.jsm", {});
const { DebuggerServer } = require("devtools/server/main");
let win = Services.wm.getMostRecentWindow("navigator:browser");

View File

@ -894,6 +894,10 @@ pref("devtools.commands.dir", "");
// Allows setting the performance marks for which telemetry metrics will be recorded.
pref("devtools.telemetry.supported_performance_marks", "contentInteractive,navigationInteractive,navigationLoaded,visuallyLoaded,fullyLoaded,mediaEnumerated,scanEnd");
// Deprecation warnings after DevTools file migration. Bug 1204127 tracks
// enabling this.
pref("devtools.migration.warnings", false);
// view source
pref("view_source.syntax_highlight", true);
pref("view_source.wrap_long_lines", false);