Bug 877262 - Part 2: move the Web Console files over to the new jetpack-based loader; r=dcamp

--HG--
rename : browser/devtools/shared/AutocompletePopup.jsm => browser/devtools/shared/autocomplete-popup.js
rename : browser/devtools/webconsole/HUDService.jsm => browser/devtools/webconsole/hudservice.js
rename : browser/devtools/webconsole/NetworkPanel.jsm => browser/devtools/webconsole/network-panel.js
rename : browser/devtools/webconsole/WebConsolePanel.jsm => browser/devtools/webconsole/panel.js
rename : toolkit/devtools/webconsole/WebConsoleClient.jsm => toolkit/devtools/webconsole/client.js
rename : toolkit/devtools/webconsole/NetworkHelper.jsm => toolkit/devtools/webconsole/network-helper.js
rename : toolkit/devtools/webconsole/WebConsoleUtils.jsm => toolkit/devtools/webconsole/utils.js
This commit is contained in:
Mihai Sucan 2013-08-03 13:29:48 +03:00
parent f2ab2589a3
commit f0c3ce2c9b
33 changed files with 283 additions and 288 deletions

View File

@ -7153,8 +7153,14 @@ XPCOMUtils.defineLazyModuleGetter(this, "gDevTools",
XPCOMUtils.defineLazyModuleGetter(this, "gDevToolsBrowser",
"resource:///modules/devtools/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "HUDService",
"resource:///modules/HUDService.jsm");
Object.defineProperty(this, "HUDService", {
get: function HUDService_getter() {
let devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
return devtools.require("devtools/webconsole/hudservice");
},
configurable: true,
enumerable: true
});
// Prompt user to restart the browser in safe mode
function safeModeRestart()

View File

@ -19,14 +19,12 @@ Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/devtools/gcli.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
var require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools.require;
let Telemetry = require("devtools/shared/telemetry");
let devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
let Telemetry = devtools.require("devtools/shared/telemetry");
let telemetry = new Telemetry();
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools",
"resource:///modules/devtools/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppCacheUtils",
"resource:///modules/devtools/AppCacheUtils.jsm");
@ -799,8 +797,13 @@ XPCOMUtils.defineLazyModuleGetter(this, "AppCacheUtils",
/* CmdConsole -------------------------------------------------------------- */
(function(module) {
XPCOMUtils.defineLazyModuleGetter(this, "HUDService",
"resource:///modules/HUDService.jsm");
Object.defineProperty(this, "HUDService", {
get: function() {
return devtools.require("devtools/webconsole/hudservice");
},
configurable: true,
enumerable: true
});
/**
* 'console' command

View File

@ -29,8 +29,17 @@ Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Parser",
"resource:///modules/devtools/Parser.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetworkHelper",
"resource://gre/modules/devtools/NetworkHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
Object.defineProperty(this, "NetworkHelper", {
get: function() {
return devtools.require("devtools/toolkit/webconsole/network-helper");
},
configurable: true,
enumerable: true
});
/**
* Object defining the debugger controller components.

View File

@ -4,13 +4,10 @@
"use strict";
const {Cu} = require("chrome");
const EventEmitter = require("devtools/shared/event-emitter");
const promise = require("sdk/core/promise");
loader.lazyGetter(this, "AutocompletePopup", () => {
return Cu.import("resource:///modules/devtools/AutocompletePopup.jsm", {}).AutocompletePopup;
});
loader.lazyGetter(this, "AutocompletePopup", () => require("devtools/shared/autocomplete-popup").AutocompletePopup);
// Maximum number of selector suggestions shown in the panel.
const MAX_SUGGESTIONS = 15;

View File

@ -12,7 +12,6 @@ browser.jar:
content/browser/devtools/netmonitor-controller.js (netmonitor/netmonitor-controller.js)
content/browser/devtools/netmonitor-view.js (netmonitor/netmonitor-view.js)
content/browser/devtools/NetworkPanel.xhtml (webconsole/NetworkPanel.xhtml)
content/browser/devtools/webconsole.js (webconsole/webconsole.js)
content/browser/devtools/webconsole.xul (webconsole/webconsole.xul)
* content/browser/devtools/scratchpad.xul (scratchpad/scratchpad.xul)
content/browser/devtools/scratchpad.js (scratchpad/scratchpad.js)

View File

@ -19,10 +19,12 @@ Object.defineProperty(exports, "TargetFactory", {
loader.lazyGetter(this, "osString", () => Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS);
let events = require("sdk/system/events");
// Panels
loader.lazyGetter(this, "OptionsPanel", function() require("devtools/framework/toolbox-options").OptionsPanel);
loader.lazyGetter(this, "InspectorPanel", function() require("devtools/inspector/inspector-panel").InspectorPanel);
loader.lazyImporter(this, "WebConsolePanel", "resource:///modules/WebConsolePanel.jsm");
loader.lazyGetter(this, "WebConsolePanel", function() require("devtools/webconsole/panel").WebConsolePanel);
loader.lazyImporter(this, "DebuggerPanel", "resource:///modules/devtools/DebuggerPanel.jsm");
loader.lazyImporter(this, "StyleEditorPanel", "resource:///modules/devtools/StyleEditorPanel.jsm");
loader.lazyGetter(this, "ProfilerPanel", function() require("devtools/profiler/panel"));
@ -221,6 +223,8 @@ var unloadObserver = {
};
Services.obs.addObserver(unloadObserver, "sdk:loader:destroy", false);
events.emit("devtools-loaded", {});
/**
* Lookup l10n string from a string bundle.
*

View File

@ -21,9 +21,7 @@ Cu.import("resource:///modules/devtools/LayoutHelpers.jsm");
Cu.import("resource://gre/modules/devtools/Templater.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "AutocompletePopup", function() {
return Cu.import("resource:///modules/devtools/AutocompletePopup.jsm", {}).AutocompletePopup;
});
loader.lazyGetter(this, "AutocompletePopup", () => require("devtools/shared/autocomplete-popup").AutocompletePopup);
/**
* Vocabulary for the purposes of this file:

View File

@ -19,8 +19,16 @@ Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetworkHelper",
"resource://gre/modules/devtools/NetworkHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
Object.defineProperty(this, "NetworkHelper", {
get: function() {
return devtools.require("devtools/toolkit/webconsole/network-helper");
},
configurable: true,
enumerable: true
});
XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
"@mozilla.org/widget/clipboardhelper;1", "nsIClipboardHelper");

View File

@ -25,9 +25,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "gcli",
XPCOMUtils.defineLazyModuleGetter(this, "CmdCommands",
"resource:///modules/devtools/BuiltinCommands.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleServiceListener",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
@ -55,6 +52,14 @@ let Telemetry = devtools.require("devtools/shared/telemetry");
const converters = require("gcli/converters");
Object.defineProperty(this, "ConsoleServiceListener", {
get: function() {
return devtools.require("devtools/toolkit/webconsole/utils").ConsoleServiceListener;
},
configurable: true,
enumerable: true
});
/**
* A collection of utilities to help working with commands
*/
@ -400,6 +405,10 @@ DeveloperToolbar.prototype._onload = function DT_onload(aFocus)
tabbrowser.addEventListener("beforeunload", this, true);
this._initErrorsCount(tabbrowser.selectedTab);
this._devtoolsUnloaded = this._devtoolsUnloaded.bind(this);
this._devtoolsLoaded = this._devtoolsLoaded.bind(this);
Services.obs.addObserver(this._devtoolsUnloaded, "devtools-unloaded", false);
Services.obs.addObserver(this._devtoolsLoaded, "devtools-loaded", false);
this._element.hidden = false;
@ -427,6 +436,26 @@ DeveloperToolbar.prototype._onload = function DT_onload(aFocus)
}
};
/**
* The devtools-unloaded event handler.
* @private
*/
DeveloperToolbar.prototype._devtoolsUnloaded = function DT__devtoolsUnloaded()
{
let tabbrowser = this._chromeWindow.getBrowser();
Array.prototype.forEach.call(tabbrowser.tabs, this._stopErrorsCount, this);
};
/**
* The devtools-loaded event handler.
* @private
*/
DeveloperToolbar.prototype._devtoolsLoaded = function DT__devtoolsLoaded()
{
let tabbrowser = this._chromeWindow.getBrowser();
this._initErrorsCount(tabbrowser.selectedTab);
};
/**
* Initialize the listeners needed for tracking the number of errors for a given
* tab.
@ -523,6 +552,8 @@ DeveloperToolbar.prototype.destroy = function DT_destroy()
tabbrowser.removeEventListener("load", this, true);
tabbrowser.removeEventListener("beforeunload", this, true);
Services.obs.removeObserver(this._devtoolsUnloaded, "devtools-unloaded");
Services.obs.removeObserver(this._devtoolsLoaded, "devtools-loaded");
Array.prototype.forEach.call(tabbrowser.tabs, this._stopErrorsCount, this);
this.display.focusManager.removeMonitoredElement(this.outputPanel._frame);

View File

@ -3,20 +3,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/. */
const Cu = Components.utils;
const Ci = Components.interfaces;
"use strict";
// The XUL and XHTML namespace.
const {Cc, Ci, Cu} = require("chrome");
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "gDevTools", function() {
return Cu.import("resource:///modules/devtools/gDevTools.jsm", {}).gDevTools;
});
this.EXPORTED_SYMBOLS = ["AutocompletePopup"];
loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm");
loader.lazyImporter(this, "gDevTools", "resource:///modules/devtools/gDevTools.jsm");
/**
* Autocomplete popup UI implementation.
@ -38,7 +31,6 @@ this.EXPORTED_SYMBOLS = ["AutocompletePopup"];
* - onClick {String} The click event handler for the richlistbox.
* - onKeypress {String} The keypress event handler for the richlistitems.
*/
this.AutocompletePopup =
function AutocompletePopup(aDocument, aOptions = {})
{
this._document = aDocument;
@ -117,6 +109,7 @@ function AutocompletePopup(aDocument, aOptions = {})
this._list.addEventListener("keypress", this.onKeypress, false);
}
}
exports.AutocompletePopup = AutocompletePopup;
AutocompletePopup.prototype = {
_document: null,

View File

@ -14,8 +14,16 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
XPCOMUtils.defineLazyModuleGetter(this, "NetworkHelper",
"resource://gre/modules/devtools/NetworkHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
Object.defineProperty(this, "NetworkHelper", {
get: function() {
return devtools.require("devtools/toolkit/webconsole/network-helper");
},
configurable: true,
enumerable: true
});
this.EXPORTED_SYMBOLS = ["SideMenuWidget"];

View File

@ -23,11 +23,24 @@ Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js").Promise;
XPCOMUtils.defineLazyModuleGetter(this, "NetworkHelper",
"resource://gre/modules/devtools/NetworkHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleUtils",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
Object.defineProperty(this, "WebConsoleUtils", {
get: function() {
return devtools.require("devtools/toolkit/webconsole/utils").Utils;
},
configurable: true,
enumerable: true
});
Object.defineProperty(this, "NetworkHelper", {
get: function() {
return devtools.require("devtools/toolkit/webconsole/network-helper");
},
configurable: true,
enumerable: true
});
this.EXPORTED_SYMBOLS = ["VariablesView"];

View File

@ -12,7 +12,17 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js").Promise;
Cu.import("resource:///modules/devtools/VariablesView.jsm");
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
Cu.import("resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
Object.defineProperty(this, "WebConsoleUtils", {
get: function() {
return devtools.require("devtools/toolkit/webconsole/utils").Utils;
},
configurable: true,
enumerable: true
});
XPCOMUtils.defineLazyGetter(this, "VARIABLES_SORTING_ENABLED", () =>
Services.prefs.getBoolPref("devtools.debugger.ui.variables-sorting-enabled")

View File

@ -1891,6 +1891,4 @@ XPCOMUtils.defineLazyGetter(this, "domUtils", function() {
return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
});
XPCOMUtils.defineLazyGetter(this, "AutocompletePopup", function() {
return Cu.import("resource:///modules/devtools/AutocompletePopup.jsm", {}).AutocompletePopup;
});
loader.lazyGetter(this, "AutocompletePopup", () => require("devtools/shared/autocomplete-popup").AutocompletePopup);

View File

@ -12,4 +12,4 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
libs::
$(NSINSTALL) $(srcdir)/*.js $(FINAL_TARGET)/modules/devtools/framework
$(NSINSTALL) $(srcdir)/*.js $(FINAL_TARGET)/modules/devtools/webconsole

View File

@ -6,37 +6,19 @@
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
let WebConsoleUtils = require("devtools/toolkit/webconsole/utils").Utils;
let Heritage = require("sdk/core/heritage");
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools",
"resource:///modules/devtools/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer",
"resource://gre/modules/devtools/dbg-server.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DebuggerClient",
"resource://gre/modules/devtools/dbg-client.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleUtils",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "promise",
"resource://gre/modules/commonjs/sdk/core/promise.js", "Promise");
XPCOMUtils.defineLazyModuleGetter(this, "Heritage",
"resource:///modules/devtools/ViewHelpers.jsm");
let Telemetry = devtools.require("devtools/shared/telemetry");
loader.lazyGetter(this, "promise", () => require("sdk/core/promise"));
loader.lazyGetter(this, "Telemetry", () => require("devtools/shared/telemetry"));
loader.lazyGetter(this, "WebConsoleFrame", () => require("devtools/webconsole/webconsole").WebConsoleFrame);
loader.lazyImporter(this, "gDevTools", "resource:///modules/devtools/gDevTools.jsm");
loader.lazyImporter(this, "devtools", "resource://gre/modules/devtools/Loader.jsm");
loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm");
loader.lazyImporter(this, "DebuggerServer", "resource://gre/modules/devtools/dbg-server.jsm");
loader.lazyImporter(this, "DebuggerClient", "resource://gre/modules/devtools/dbg-client.jsm");
const STRINGS_URI = "chrome://browser/locale/devtools/webconsole.properties";
let l10n = new WebConsoleUtils.l10n(STRINGS_URI);
@ -46,8 +28,6 @@ const BROWSER_CONSOLE_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,re
// The preference prefix for all of the Browser Console filters.
const BROWSER_CONSOLE_FILTER_PREFS_PREFIX = "devtools.browserconsole.filter.";
this.EXPORTED_SYMBOLS = ["HUDService"];
///////////////////////////////////////////////////////////////////////////
//// The HUD service
@ -330,7 +310,7 @@ function WebConsole(aTarget, aIframeWindow, aChromeWindow)
this.browserWindow = HUDService.currentContext();
}
this.ui = new this.iframeWindow.WebConsoleFrame(this);
this.ui = new WebConsoleFrame(this);
}
WebConsole.prototype = {
@ -724,3 +704,15 @@ BrowserConsole.prototype = Heritage.extend(WebConsole.prototype,
});
const HUDService = new HUD_SERVICE();
(() => {
let methods = ["openWebConsole", "openBrowserConsole", "toggleWebConsole",
"toggleBrowserConsole", "getOpenWebConsole",
"getBrowserConsole", "getHudByWindow", "getHudReferenceById"];
for (let method of methods) {
exports[method] = HUDService[method].bind(HUDService);
}
exports.consoles = HUDService.consoles;
exports.lastFinishedRequest = HUDService.lastFinishedRequest;
})();

View File

@ -5,10 +5,3 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
TEST_DIRS += ['test']
EXTRA_JS_MODULES += [
'HUDService.jsm',
'NetworkPanel.jsm',
'WebConsolePanel.jsm',
]

View File

@ -6,28 +6,17 @@
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
loader.lazyGetter(this, "NetworkHelper", () => require("devtools/toolkit/webconsole/network-helper"));
loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm");
loader.lazyServiceGetter(this, "mimeService", "@mozilla.org/mime;1", "nsIMIMEService");
XPCOMUtils.defineLazyServiceGetter(this, "mimeService", "@mozilla.org/mime;1",
"nsIMIMEService");
XPCOMUtils.defineLazyModuleGetter(this, "NetworkHelper",
"resource://gre/modules/devtools/NetworkHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleUtils",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
let WebConsoleUtils = require("devtools/toolkit/webconsole/utils").Utils;
const STRINGS_URI = "chrome://browser/locale/devtools/webconsole.properties";
let l10n = new WebConsoleUtils.l10n(STRINGS_URI);
this.EXPORTED_SYMBOLS = ["NetworkPanel"];
/**
* Creates a new NetworkPanel.
@ -41,7 +30,6 @@ this.EXPORTED_SYMBOLS = ["NetworkPanel"];
* The parent WebConsoleFrame object that owns this network panel
* instance.
*/
this.NetworkPanel =
function NetworkPanel(aParent, aHttpActivity, aWebConsoleFrame)
{
let doc = aParent.ownerDocument;
@ -108,6 +96,7 @@ function NetworkPanel(aParent, aHttpActivity, aWebConsoleFrame)
aParent.appendChild(this.panel);
}
exports.NetworkPanel = NetworkPanel;
NetworkPanel.prototype =
{

View File

@ -4,29 +4,22 @@
"use strict";
this.EXPORTED_SYMBOLS = [ "WebConsolePanel" ];
const {Cc, Ci, Cu} = require("chrome");
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "promise",
"resource://gre/modules/commonjs/sdk/core/promise.js", "Promise");
XPCOMUtils.defineLazyModuleGetter(this, "HUDService",
"resource:///modules/HUDService.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "EventEmitter",
"resource:///modules/devtools/shared/event-emitter.js");
loader.lazyGetter(this, "promise", () => require("sdk/core/promise"));
loader.lazyGetter(this, "HUDService", () => require("devtools/webconsole/hudservice"));
loader.lazyGetter(this, "EventEmitter", () => require("devtools/shared/event-emitter"));
/**
* A DevToolPanel that controls the Web Console.
*/
function WebConsolePanel(iframeWindow, toolbox) {
function WebConsolePanel(iframeWindow, toolbox)
{
this._frameWindow = iframeWindow;
this._toolbox = toolbox;
EventEmitter.decorate(this);
}
exports.WebConsolePanel = WebConsolePanel;
WebConsolePanel.prototype = {
hud: null,

View File

@ -14,11 +14,8 @@ function test() {
}
function consoleOpened(HUD) {
let tmp = {};
Cu.import("resource://gre/modules/devtools/WebConsoleUtils.jsm", tmp);
let WCU = tmp.WebConsoleUtils;
let JSPropertyProvider = tmp.JSPropertyProvider;
tmp = null;
let tools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
let JSPropertyProvider = tools.require("devtools/toolkit/webconsole/utils").JSPropertyProvider;
let jsterm = HUD.jsterm;
let win = content.wrappedJSObject;

View File

@ -15,11 +15,8 @@ function test() {
function testPropertyProvider() {
browser.removeEventListener("load", testPropertyProvider, true);
let tmp = {};
Cu.import("resource://gre/modules/devtools/WebConsoleUtils.jsm", tmp);
let JSPropertyProvider = tmp.JSPropertyProvider;
tmp = null;
let tools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
let JSPropertyProvider = tools.require("devtools/toolkit/webconsole/utils").JSPropertyProvider;
let completion = JSPropertyProvider(content, "thisIsNotDefined");
is (completion.matches.length, 0, "no match for 'thisIsNotDefined");

View File

@ -3,18 +3,18 @@
* 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/. */
let tempScope = {};
Cu.import("resource:///modules/HUDService.jsm", tempScope);
let HUDService = tempScope.HUDService;
Cu.import("resource://gre/modules/devtools/WebConsoleUtils.jsm", tempScope);
let WebConsoleUtils = tempScope.WebConsoleUtils;
Cu.import("resource:///modules/devtools/gDevTools.jsm", tempScope);
let gDevTools = tempScope.gDevTools;
Cu.import("resource://gre/modules/devtools/Loader.jsm", tempScope);
let TargetFactory = tempScope.devtools.TargetFactory;
Components.utils.import("resource://gre/modules/devtools/Console.jsm", tempScope);
let console = tempScope.console;
let promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {}).Promise;
let WebConsoleUtils, gDevTools, TargetFactory, console, promise;
(() => {
gDevTools = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}).gDevTools;
console = Cu.import("resource://gre/modules/devtools/Console.jsm", {}).console;
promise = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {}).Promise;
let tools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
let utils = tools.require("devtools/toolkit/webconsole/utils");
TargetFactory = tools.TargetFactory;
WebConsoleUtils = utils.Utils;
})();
// promise._reportErrors = true; // please never leave me.
let gPendingOutputTest = 0;

View File

@ -6,45 +6,25 @@
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
let WebConsoleUtils = require("devtools/toolkit/webconsole/utils").Utils;
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
"@mozilla.org/widget/clipboardhelper;1",
"nsIClipboardHelper");
XPCOMUtils.defineLazyModuleGetter(this, "GripClient",
"resource://gre/modules/devtools/dbg-client.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetworkPanel",
"resource:///modules/NetworkPanel.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AutocompletePopup",
"resource:///modules/devtools/AutocompletePopup.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleUtils",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "promise",
"resource://gre/modules/commonjs/sdk/core/promise.js", "Promise");
XPCOMUtils.defineLazyModuleGetter(this, "VariablesView",
"resource:///modules/devtools/VariablesView.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "VariablesViewController",
"resource:///modules/devtools/VariablesViewController.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "EventEmitter",
"resource:///modules/devtools/shared/event-emitter.js");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
loader.lazyServiceGetter(this, "clipboardHelper",
"@mozilla.org/widget/clipboardhelper;1",
"nsIClipboardHelper");
loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm");
loader.lazyGetter(this, "promise", () => require("sdk/core/promise"));
loader.lazyGetter(this, "EventEmitter", () => require("devtools/shared/event-emitter"));
loader.lazyGetter(this, "AutocompletePopup",
() => require("devtools/shared/autocomplete-popup").AutocompletePopup);
loader.lazyGetter(this, "ToolSidebar",
() => require("devtools/framework/sidebar").ToolSidebar);
loader.lazyGetter(this, "NetworkPanel",
() => require("devtools/webconsole/network-panel").NetworkPanel);
loader.lazyImporter(this, "GripClient", "resource://gre/modules/devtools/dbg-client.jsm");
loader.lazyImporter(this, "VariablesView", "resource:///modules/devtools/VariablesView.jsm");
loader.lazyImporter(this, "VariablesViewController", "resource:///modules/devtools/VariablesViewController.jsm");
const STRINGS_URI = "chrome://browser/locale/devtools/webconsole.properties";
let l10n = new WebConsoleUtils.l10n(STRINGS_URI);
@ -199,6 +179,7 @@ function WebConsoleFrame(aWebConsoleOwner)
{
this.owner = aWebConsoleOwner;
this.hudId = this.owner.hudId;
this.window = this.owner.iframeWindow;
this._repeatNodes = {};
this._outputQueue = [];
@ -214,11 +195,12 @@ function WebConsoleFrame(aWebConsoleOwner)
EventEmitter.decorate(this);
}
exports.WebConsoleFrame = WebConsoleFrame;
WebConsoleFrame.prototype = {
/**
* The WebConsole instance that owns this frame.
* @see HUDService.jsm::WebConsole
* @see hudservice.js::WebConsole
* @type object
*/
owner: null,
@ -472,9 +454,6 @@ WebConsoleFrame.prototype = {
*/
_initUI: function WCF__initUI()
{
// Remember that this script is loaded in the webconsole.xul context:
// |window| is the iframe global.
this.window = window;
this.document = this.window.document;
this.rootElement = this.document.documentElement;
@ -3301,7 +3280,6 @@ JSTerm.prototype = {
_createSidebar: function JST__createSidebar()
{
let tabbox = this.hud.document.querySelector("#webconsole-sidebar");
let ToolSidebar = devtools.require("devtools/framework/sidebar").ToolSidebar;
this.sidebar = new ToolSidebar(tabbox, this, "webconsole");
this.sidebar.show();
},

View File

@ -22,7 +22,6 @@
width="900" height="350"
persist="screenX screenY width height sizemode">
<script type="text/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="text/javascript" src="webconsole.js"/>
<script type="text/javascript"><![CDATA[
function goUpdateConsoleCommands() {
goUpdateCommand("consoleCmd_openURL");

View File

@ -1343,7 +1343,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<h1><a id="firebug"></a>Firebug License</h1>
<p>This license applies to the code
<span class="path">browser/devtools/webconsole/NetworkHelper.jsm</span>.</p>
<span class="path">toolkit/devtools/webconsole/network-helper.js</span>.</p>
<pre>
Copyright (c) 2007, Parakey Inc.

View File

@ -28,11 +28,13 @@ this.EXPORTED_SYMBOLS = ["devtools"];
*/
let loaderGlobals = {
btoa: btoa,
console: console,
_Iterator: Iterator,
loader: {
lazyGetter: XPCOMUtils.defineLazyGetter.bind(XPCOMUtils),
lazyImporter: XPCOMUtils.defineLazyModuleGetter.bind(XPCOMUtils)
lazyImporter: XPCOMUtils.defineLazyModuleGetter.bind(XPCOMUtils),
lazyServiceGetter: XPCOMUtils.defineLazyServiceGetter.bind(XPCOMUtils)
}
}
@ -48,6 +50,7 @@ var BuiltinProvider = {
"main": "resource:///modules/devtools/main.js",
"devtools": "resource:///modules/devtools",
"devtools/server": "resource://gre/modules/devtools/server",
"devtools/toolkit/webconsole": "resource://gre/modules/devtools/toolkit/webconsole",
// Allow access to xpcshell test items from the loader.
"xpcshell-test": "resource://test"
@ -81,6 +84,7 @@ var SrcdirProvider = {
let devtoolsURI = this.fileURI(devtoolsDir);
let toolkitURI = this.fileURI(OS.Path.join(srcdir, "toolkit", "devtools"));
let serverURI = this.fileURI(OS.Path.join(srcdir, "toolkit", "devtools", "server"));
let webconsoleURI = this.fileURI(OS.Path.join(srcdir, "toolkit", "devtools", "webconsole"));
let mainURI = this.fileURI(OS.Path.join(srcdir, "browser", "devtools", "main.js"));
this.loader = new loader.Loader({
modules: {
@ -89,6 +93,7 @@ var SrcdirProvider = {
paths: {
"": "resource://gre/modules/commonjs/",
"devtools/server": serverURI,
"devtools/toolkit/webconsole": webconsoleURI,
"devtools": devtoolsURI,
"main": mainURI
},

View File

@ -28,8 +28,16 @@ XPCOMUtils.defineLazyServiceGetter(this, "socketTransportService",
"@mozilla.org/network/socket-transport-service;1",
"nsISocketTransportService");
XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleClient",
"resource://gre/modules/devtools/WebConsoleClient.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
Object.defineProperty(this, "WebConsoleClient", {
get: function() {
return devtools.require("devtools/toolkit/webconsole/client").WebConsoleClient;
},
configurable: true,
enumerable: true
});
Components.utils.import("resource://gre/modules/devtools/DevToolsUtils.jsm");
this.makeInfallible = DevToolsUtils.makeInfallible;

View File

@ -12,33 +12,29 @@ let Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
let devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleUtils",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleServiceListener",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPIListener",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleProgressListener",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "JSTermHelpers",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "JSPropertyProvider",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetworkMonitor",
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPIStorage",
"resource://gre/modules/ConsoleAPIStorage.jsm");
for (let name of ["WebConsoleUtils", "ConsoleServiceListener",
"ConsoleAPIListener", "ConsoleProgressListener",
"JSTermHelpers", "JSPropertyProvider", "NetworkMonitor"]) {
Object.defineProperty(this, name, {
get: function(prop) {
if (prop == "WebConsoleUtils") {
prop = "Utils";
}
return devtools.require("devtools/toolkit/webconsole/utils")[prop];
}.bind(null, name),
configurable: true,
enumerable: true
});
}
/**
* The WebConsoleActor implements capabilities needed for the Web Console
@ -1004,7 +1000,7 @@ WebConsoleActor.prototype =
* is about to be recorded.
*
* @see NetworkEventActor
* @see NetworkMonitor from WebConsoleUtils.jsm
* @see NetworkMonitor from webconsole/utils.js
*
* @param object aEvent
* The initial network request event information.

View File

@ -12,4 +12,4 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
libs::
$(INSTALL) $(IFLAGS1) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
$(INSTALL) $(IFLAGS1) $(srcdir)/*.js $(FINAL_TARGET)/modules/devtools/toolkit/webconsole

View File

@ -6,16 +6,9 @@
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LongStringClient",
"resource://gre/modules/devtools/dbg-client.jsm");
this.EXPORTED_SYMBOLS = ["WebConsoleClient"];
loader.lazyImporter(this, "LongStringClient", "resource://gre/modules/devtools/dbg-client.jsm");
/**
* A WebConsoleClient is used as a front end for the WebConsoleActor that is
@ -26,12 +19,13 @@ this.EXPORTED_SYMBOLS = ["WebConsoleClient"];
* @param string aActor
* The WebConsoleActor ID.
*/
this.WebConsoleClient = function WebConsoleClient(aDebuggerClient, aActor)
function WebConsoleClient(aDebuggerClient, aActor)
{
this._actor = aActor;
this._client = aDebuggerClient;
this._longStrings = {};
}
exports.WebConsoleClient = WebConsoleClient;
WebConsoleClient.prototype = {
_longStrings: null,

View File

@ -52,19 +52,8 @@
* Mihai Sucan (Mozilla Corp.)
*/
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "NetUtil", function () {
var obj = {};
Cu.import("resource://gre/modules/NetUtil.jsm", obj);
return obj.NetUtil;
});
this.EXPORTED_SYMBOLS = ["NetworkHelper"];
const {Cc, Ci, Cu} = require("chrome");
loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm");
/**
* Helper object for networking stuff.
@ -72,9 +61,7 @@ this.EXPORTED_SYMBOLS = ["NetworkHelper"];
* Most of the following functions have been taken from the Firebug source. They
* have been modified to match the Firefox coding rules.
*/
this.NetworkHelper =
{
let NetworkHelper = {
/**
* Converts aText with a given aCharset to unicode.
*
@ -268,8 +255,7 @@ this.NetworkHelper =
let contentCharset = aChannel.contentCharset || aCharset;
// Read the content of the stream using contentCharset as encoding.
aCallback(NetworkHelper.readAndConvertFromStream(aInputStream,
contentCharset));
aCallback(this.readAndConvertFromStream(aInputStream, contentCharset));
});
},
@ -438,7 +424,7 @@ this.NetworkHelper =
return true;
}
switch (NetworkHelper.mimeCategoryMap[aMimeType]) {
switch (this.mimeCategoryMap[aMimeType]) {
case "txt":
case "js":
case "json":
@ -452,4 +438,8 @@ this.NetworkHelper =
return false;
}
},
};
for (let prop of Object.getOwnPropertyNames(NetworkHelper)) {
exports[prop] = NetworkHelper[prop];
}

View File

@ -9,7 +9,12 @@ const XHTML_NS = "http://www.w3.org/1999/xhtml";
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm");
Cu.import("resource://gre/modules/devtools/WebConsoleUtils.jsm");
let devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
let WebConsoleUtils = devtools.require("devtools/toolkit/webconsole/utils").Utils;
let {ConsoleServiceListener, ConsoleAPIListener} =
devtools.require("devtools/toolkit/webconsole/utils");
function initCommon()
{

View File

@ -6,45 +6,24 @@
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const {Cc, Ci, Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPIStorage",
"resource://gre/modules/ConsoleAPIStorage.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetworkHelper",
"resource://gre/modules/devtools/NetworkHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "gActivityDistributor",
"@mozilla.org/network/http-activity-distributor;1",
"nsIHttpActivityDistributor");
loader.lazyGetter(this, "NetworkHelper", () => require("devtools/toolkit/webconsole/network-helper"));
loader.lazyImporter(this, "Services", "resource://gre/modules/Services.jsm");
loader.lazyImporter(this, "ConsoleAPIStorage", "resource://gre/modules/ConsoleAPIStorage.jsm");
loader.lazyImporter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm");
loader.lazyImporter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm");
loader.lazyServiceGetter(this, "gActivityDistributor",
"@mozilla.org/network/http-activity-distributor;1",
"nsIHttpActivityDistributor");
// TODO: Bug 842672 - toolkit/ imports modules from browser/.
// Note that these are only used in JSTermHelpers, see $0 and pprint().
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools",
"resource:///modules/devtools/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "VariablesView",
"resource:///modules/devtools/VariablesView.jsm");
this.EXPORTED_SYMBOLS = ["WebConsoleUtils", "JSPropertyProvider", "JSTermHelpers",
"ConsoleServiceListener", "ConsoleAPIListener",
"NetworkResponseListener", "NetworkMonitor",
"ConsoleProgressListener"];
loader.lazyImporter(this, "gDevTools", "resource:///modules/devtools/gDevTools.jsm");
loader.lazyImporter(this, "devtools", "resource://gre/modules/devtools/Loader.jsm");
loader.lazyImporter(this, "VariablesView", "resource:///modules/devtools/VariablesView.jsm");
// Match the function name from the result of toString() or toSource().
//
@ -57,7 +36,7 @@ const REGEX_MATCH_FUNCTION_NAME = /^\(?function\s+([^(\s]+)\s*\(/;
// Match the function arguments from the result of toString() or toSource().
const REGEX_MATCH_FUNCTION_ARGS = /^\(?function\s*[^\s(]*\s*\((.+?)\)/;
this.WebConsoleUtils = {
let WebConsoleUtils = {
/**
* Convenience function to unwrap a wrapped object.
*
@ -511,6 +490,7 @@ this.WebConsoleUtils = {
return aGrip && typeof(aGrip) == "object" && aGrip.actor;
},
};
exports.Utils = WebConsoleUtils;
//////////////////////////////////////////////////////////////////////////
// Localization
@ -601,7 +581,7 @@ WebConsoleUtils.l10n.prototype = {
// JS Completer
//////////////////////////////////////////////////////////////////////////
this.JSPropertyProvider = (function _JSPP(WCU) {
(function _JSPP(WCU) {
const STATE_NORMAL = 0;
const STATE_QUOTE = 2;
const STATE_DQUOTE = 3;
@ -906,7 +886,7 @@ function getMatchedProps(aObj, aOptions = {matchProp: ""})
}
return JSPropertyProvider;
exports.JSPropertyProvider = JSPropertyProvider;
})(WebConsoleUtils);
///////////////////////////////////////////////////////////////////////////////
@ -923,14 +903,15 @@ return JSPropertyProvider;
* for filtering out messages that belong to other windows.
* @param object aListener
* The listener object must have one method:
* - onConsoleServiceMessage(). This method is invoked with one argument, the
* nsIConsoleMessage, whenever a relevant message is received.
* - onConsoleServiceMessage(). This method is invoked with one argument,
* the nsIConsoleMessage, whenever a relevant message is received.
*/
this.ConsoleServiceListener = function ConsoleServiceListener(aWindow, aListener)
function ConsoleServiceListener(aWindow, aListener)
{
this.window = aWindow;
this.listener = aListener;
}
exports.ConsoleServiceListener = ConsoleServiceListener;
ConsoleServiceListener.prototype =
{
@ -1096,11 +1077,12 @@ ConsoleServiceListener.prototype =
* Console API message that comes from the observer service, whenever
* a relevant console API call is received.
*/
this.ConsoleAPIListener = function ConsoleAPIListener(aWindow, aOwner)
function ConsoleAPIListener(aWindow, aOwner)
{
this.window = aWindow;
this.owner = aOwner;
}
exports.ConsoleAPIListener = ConsoleAPIListener;
ConsoleAPIListener.prototype =
{
@ -1214,7 +1196,7 @@ ConsoleAPIListener.prototype =
* @param object aOwner
* The owning object.
*/
this.JSTermHelpers = function JSTermHelpers(aOwner)
function JSTermHelpers(aOwner)
{
/**
* Find a node by ID.
@ -1433,10 +1415,10 @@ this.JSTermHelpers = function JSTermHelpers(aOwner)
aOwner.helperResult = { rawOutput: true };
return String(aString);
};
};
}
exports.JSTermHelpers = JSTermHelpers;
(function(_global, WCU) {
(function(WCU) {
///////////////////////////////////////////////////////////////////////////////
// Network logging
///////////////////////////////////////////////////////////////////////////////
@ -2346,9 +2328,9 @@ NetworkMonitor.prototype = {
},
};
_global.NetworkMonitor = NetworkMonitor;
_global.NetworkResponseListener = NetworkResponseListener;
})(this, WebConsoleUtils);
exports.NetworkMonitor = NetworkMonitor;
exports.NetworkResponseListener = NetworkResponseListener;
})(WebConsoleUtils);
/**
* A WebProgressListener that listens for location changes.
@ -2364,12 +2346,12 @@ _global.NetworkResponseListener = NetworkResponseListener;
* - onFileActivity(aFileURI)
* - onLocationChange(aState, aTabURI, aPageTitle)
*/
this.ConsoleProgressListener =
function ConsoleProgressListener(aWindow, aOwner)
function ConsoleProgressListener(aWindow, aOwner)
{
this.window = aWindow;
this.owner = aOwner;
}
exports.ConsoleProgressListener = ConsoleProgressListener;
ConsoleProgressListener.prototype = {
/**