diff options
Diffstat (limited to 'devtools/shared/shims')
-rw-r--r-- | devtools/shared/shims/Console.jsm | 35 | ||||
-rw-r--r-- | devtools/shared/shims/Loader.jsm | 38 | ||||
-rw-r--r-- | devtools/shared/shims/Simulator.jsm | 34 | ||||
-rw-r--r-- | devtools/shared/shims/dbg-client.jsm | 43 | ||||
-rw-r--r-- | devtools/shared/shims/event-emitter.js | 42 | ||||
-rw-r--r-- | devtools/shared/shims/moz.build | 31 |
6 files changed, 223 insertions, 0 deletions
diff --git a/devtools/shared/shims/Console.jsm b/devtools/shared/shims/Console.jsm new file mode 100644 index 000000000..0bfdcb867 --- /dev/null +++ b/devtools/shared/shims/Console.jsm @@ -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/Console.jsm\") " + + "to load this module.", + "https://bugzil.la/912121"); +} + +this.EXPORTED_SYMBOLS = [ + "console", + "ConsoleAPI" +]; + +const module = + Cu.import("resource://gre/modules/Console.jsm", {}); + +for (let symbol of this.EXPORTED_SYMBOLS) { + this[symbol] = module[symbol]; +} diff --git a/devtools/shared/shims/Loader.jsm b/devtools/shared/shims/Loader.jsm new file mode 100644 index 000000000..8504e08d0 --- /dev/null +++ b/devtools/shared/shims/Loader.jsm @@ -0,0 +1,38 @@ +/* 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://devtools/shared/" + + "Loader.jsm\") to load this module.", + "https://bugzil.la/912121"); +} + +this.EXPORTED_SYMBOLS = [ + "DevToolsLoader", + "devtools", + "BuiltinProvider", + "require", + "loader" +]; + +const module = + Cu.import("resource://devtools/shared/Loader.jsm", {}); + +for (let symbol of this.EXPORTED_SYMBOLS) { + this[symbol] = module[symbol]; +} diff --git a/devtools/shared/shims/Simulator.jsm b/devtools/shared/shims/Simulator.jsm new file mode 100644 index 000000000..7fd4fef53 --- /dev/null +++ b/devtools/shared/shims/Simulator.jsm @@ -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://devtools/shared/" + + "apps/Simulator.jsm\") to load this module.", + "https://bugzil.la/912121"); +} + +this.EXPORTED_SYMBOLS = [ + "Simulator", +]; + +const module = + Cu.import("resource://devtools/shared/apps/Simulator.jsm", {}); + +for (let symbol of this.EXPORTED_SYMBOLS) { + this[symbol] = module[symbol]; +} diff --git a/devtools/shared/shims/dbg-client.jsm b/devtools/shared/shims/dbg-client.jsm new file mode 100644 index 000000000..ec3d500cd --- /dev/null +++ b/devtools/shared/shims/dbg-client.jsm @@ -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://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; diff --git a/devtools/shared/shims/event-emitter.js b/devtools/shared/shims/event-emitter.js new file mode 100644 index 000000000..6b3672162 --- /dev/null +++ b/devtools/shared/shims/event-emitter.js @@ -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://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; +}); diff --git a/devtools/shared/shims/moz.build b/devtools/shared/shims/moz.build new file mode 100644 index 000000000..bee1c82ac --- /dev/null +++ b/devtools/shared/shims/moz.build @@ -0,0 +1,31 @@ +# -*- Mode: python; 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. + +# These shims for legacy paths expect to be installed as if they were part of +# /toolkit modules. Disable any DIST_SUBDIR from parent files here. +DIST_SUBDIR = '' + +EXTRA_JS_MODULES.devtools += [ + 'Console.jsm', + 'dbg-client.jsm', + 'event-emitter.js', + 'Loader.jsm', + 'Simulator.jsm', +] + +# Extra compatibility layer for transitional URLs used for part of 44 cycle +EXTRA_JS_MODULES.devtools.shared += [ + 'Console.jsm', + 'Loader.jsm', +] + +EXTRA_JS_MODULES.devtools.shared.apps += [ + 'Simulator.jsm', +] |