зеркало из https://github.com/mozilla/gecko-dev.git
Bug 795691 - b2g fixes for the web console actors; r=past,vingtetun,ttaubert
This commit is contained in:
Родитель
4585798f8e
Коммит
2d87b85b5d
|
@ -117,7 +117,7 @@ DeviceTabActor.prototype.grip = function DTA_grip() {
|
|||
|
||||
// Walk over tab actors added by extensions and add them to a new ActorPool.
|
||||
let actorPool = new ActorPool(this.conn);
|
||||
this._createExtraActors(DebuggerServer.globalActorFactories, actorPool);
|
||||
this._createExtraActors(DebuggerServer.tabActorFactories, actorPool);
|
||||
if (!actorPool.isEmpty()) {
|
||||
this._tabActorPool = actorPool;
|
||||
this.conn.addActorPool(this._tabActorPool);
|
||||
|
|
|
@ -152,6 +152,7 @@
|
|||
<menupopup id="appmenu_webDeveloper_popup">
|
||||
<menuitem id="appmenu_devToolbar" observes="devtoolsMenuBroadcaster_DevToolbar"/>
|
||||
<menuitem id="appmenu_webConsole" observes="devtoolsMenuBroadcaster_WebConsole"/>
|
||||
<menuitem id="appmenu_remoteWebConsole" observes="devtoolsMenuBroadcaster_RemoteWebConsole"/>
|
||||
<menuitem id="appmenu_pageinspect" observes="devtoolsMenuBroadcaster_Inspect"/>
|
||||
<menuitem id="appmenu_responsiveUI" observes="devtoolsMenuBroadcaster_ResponsiveUI"/>
|
||||
<menuitem id="appmenu_debugger" observes="devtoolsMenuBroadcaster_Debugger"/>
|
||||
|
|
|
@ -534,6 +534,7 @@
|
|||
<menupopup id="menuWebDeveloperPopup">
|
||||
<menuitem id="menu_devToolbar" observes="devtoolsMenuBroadcaster_DevToolbar" accesskey="&devToolbarMenu.accesskey;"/>
|
||||
<menuitem id="webConsole" observes="devtoolsMenuBroadcaster_WebConsole" accesskey="&webConsoleCmd.accesskey;"/>
|
||||
<menuitem id="menu_remoteWebConsole" observes="devtoolsMenuBroadcaster_RemoteWebConsole"/>
|
||||
<menuitem id="menu_pageinspect" observes="devtoolsMenuBroadcaster_Inspect" accesskey="&inspectMenu.accesskey;"/>
|
||||
<menuitem id="menu_responsiveUI" observes="devtoolsMenuBroadcaster_ResponsiveUI" accesskey="&responsiveDesignTool.accesskey;"/>
|
||||
<menuitem id="menu_debugger" observes="devtoolsMenuBroadcaster_Debugger" accesskey="&debuggerMenu.accesskey;"/>
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
<command id="Tools:DevToolbar" oncommand="DeveloperToolbar.toggle();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:DevToolbarFocus" oncommand="DeveloperToolbar.focusToggle();" disabled="true"/>
|
||||
<command id="Tools:WebConsole" oncommand="HUDConsoleUI.toggleHUD();"/>
|
||||
<command id="Tools:RemoteWebConsole" oncommand="HUDConsoleUI.toggleRemoteHUD();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:Inspect" oncommand="InspectorUI.toggleInspectorUI();"/>
|
||||
<command id="Tools:Debugger" oncommand="DebuggerUI.toggleDebugger();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:RemoteDebugger" oncommand="DebuggerUI.toggleRemoteDebugger();" disabled="true" hidden="true"/>
|
||||
|
@ -203,6 +204,10 @@
|
|||
type="checkbox" autocheck="false"
|
||||
key="key_webConsole"
|
||||
command="Tools:WebConsole"/>
|
||||
<broadcaster id="devtoolsMenuBroadcaster_RemoteWebConsole"
|
||||
label="&remoteWebConsoleCmd.label;"
|
||||
type="checkbox" autocheck="false"
|
||||
command="Tools:RemoteWebConsole"/>
|
||||
<broadcaster id="devtoolsMenuBroadcaster_Inspect"
|
||||
label="&inspectMenu.label;"
|
||||
type="checkbox" autocheck="false"
|
||||
|
|
|
@ -1446,6 +1446,10 @@ var gBrowserInit = {
|
|||
let cmd = document.getElementById("Tools:RemoteDebugger");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
|
||||
cmd = document.getElementById("Tools:RemoteWebConsole");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
// Enable Chrome Debugger?
|
||||
|
|
|
@ -113,10 +113,17 @@ HUD_SERVICE.prototype =
|
|||
* The xul:tab element.
|
||||
* @param boolean aAnimated
|
||||
* True if you want to animate the opening of the Web console.
|
||||
* @param object aOptions
|
||||
* Options for the Web Console:
|
||||
* - host
|
||||
* Server to connect to.
|
||||
* - port
|
||||
* Port to connect to.
|
||||
* @return object
|
||||
* The new HeadsUpDisplay instance.
|
||||
*/
|
||||
activateHUDForContext: function HS_activateHUDForContext(aTab, aAnimated)
|
||||
activateHUDForContext:
|
||||
function HS_activateHUDForContext(aTab, aAnimated, aOptions)
|
||||
{
|
||||
let hudId = "hud_" + aTab.linkedPanel;
|
||||
if (hudId in this.hudReferences) {
|
||||
|
@ -132,7 +139,7 @@ HUD_SERVICE.prototype =
|
|||
gBrowser.tabContainer.addEventListener("TabSelect", this.onTabSelect, false);
|
||||
window.addEventListener("unload", this.onWindowUnload, false);
|
||||
|
||||
let hud = new WebConsole(aTab);
|
||||
let hud = new WebConsole(aTab, aOptions);
|
||||
this.hudReferences[hudId] = hud;
|
||||
|
||||
if (!aAnimated || hud.consolePanel) {
|
||||
|
@ -493,13 +500,19 @@ HUD_SERVICE.prototype =
|
|||
*
|
||||
* @param nsIDOMElement aTab
|
||||
* The xul:tab for which you want the WebConsole object.
|
||||
* @param object aOptions
|
||||
* Web Console options: host and port, for the remote Web console.
|
||||
*/
|
||||
function WebConsole(aTab)
|
||||
function WebConsole(aTab, aOptions = {})
|
||||
{
|
||||
this.tab = aTab;
|
||||
this.chromeDocument = this.tab.ownerDocument;
|
||||
this.chromeWindow = this.chromeDocument.defaultView;
|
||||
this.hudId = "hud_" + this.tab.linkedPanel;
|
||||
|
||||
this.remoteHost = aOptions.host;
|
||||
this.remotePort = aOptions.port;
|
||||
|
||||
this._onIframeLoad = this._onIframeLoad.bind(this);
|
||||
this._initUI();
|
||||
}
|
||||
|
@ -1017,7 +1030,8 @@ var HeadsUpDisplayUICommands = {
|
|||
}
|
||||
},
|
||||
|
||||
toggleHUD: function UIC_toggleHUD() {
|
||||
toggleHUD: function UIC_toggleHUD(aOptions)
|
||||
{
|
||||
var window = HUDService.currentContext();
|
||||
var gBrowser = window.gBrowser;
|
||||
var linkedBrowser = gBrowser.selectedTab.linkedBrowser;
|
||||
|
@ -1046,11 +1060,52 @@ var HeadsUpDisplayUICommands = {
|
|||
}
|
||||
}
|
||||
else {
|
||||
HUDService.activateHUDForContext(gBrowser.selectedTab, true);
|
||||
HUDService.activateHUDForContext(gBrowser.selectedTab, true, aOptions);
|
||||
HUDService.animate(hudId, ANIMATE_IN);
|
||||
}
|
||||
},
|
||||
|
||||
toggleRemoteHUD: function UIC_toggleRemoteHUD()
|
||||
{
|
||||
if (this.getOpenHUD()) {
|
||||
this.toggleHUD();
|
||||
return;
|
||||
}
|
||||
|
||||
let host = Services.prefs.getCharPref("devtools.debugger.remote-host");
|
||||
let port = Services.prefs.getIntPref("devtools.debugger.remote-port");
|
||||
|
||||
let check = { value: false };
|
||||
let input = { value: host + ":" + port };
|
||||
|
||||
let result = Services.prompt.prompt(null,
|
||||
l10n.getStr("remoteWebConsolePromptTitle"),
|
||||
l10n.getStr("remoteWebConsolePromptMessage"),
|
||||
input, null, check);
|
||||
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
let parts = input.value.split(":");
|
||||
if (parts.length != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
[host, port] = parts;
|
||||
if (!host.length || !port.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
Services.prefs.setCharPref("devtools.debugger.remote-host", host);
|
||||
Services.prefs.setIntPref("devtools.debugger.remote-port", port);
|
||||
|
||||
this.toggleHUD({
|
||||
host: host,
|
||||
port: port,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the hudId for the active chrome window.
|
||||
* @return string|null
|
||||
|
|
|
@ -21,6 +21,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer",
|
|||
XPCOMUtils.defineLazyModuleGetter(this, "DebuggerClient",
|
||||
"resource://gre/modules/devtools/dbg-client.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "debuggerSocketConnect",
|
||||
"resource://gre/modules/devtools/dbg-client.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "clipboardHelper",
|
||||
"@mozilla.org/widget/clipboardhelper;1",
|
||||
"nsIClipboardHelper");
|
||||
|
@ -360,8 +363,11 @@ WebConsoleFrame.prototype = {
|
|||
*/
|
||||
_initConnection: function WCF__initConnection()
|
||||
{
|
||||
this.proxy = new WebConsoleConnectionProxy(this);
|
||||
this.proxy.initServer();
|
||||
this.proxy = new WebConsoleConnectionProxy(this, {
|
||||
host: this.owner.remoteHost,
|
||||
port: this.owner.remotePort,
|
||||
});
|
||||
|
||||
this.proxy.connect(function() {
|
||||
this.saveRequestAndResponseBodies = this._saveRequestAndResponseBodies;
|
||||
this._onInitComplete();
|
||||
|
@ -3859,10 +3865,14 @@ CommandController.prototype = {
|
|||
* @constructor
|
||||
* @param object aWebConsole
|
||||
* The Web Console instance that owns this connection proxy.
|
||||
* @param object aOptions
|
||||
* Connection options: host and port.
|
||||
*/
|
||||
function WebConsoleConnectionProxy(aWebConsole)
|
||||
function WebConsoleConnectionProxy(aWebConsole, aOptions = {})
|
||||
{
|
||||
this.owner = aWebConsole;
|
||||
this.remoteHost = aOptions.host;
|
||||
this.remotePort = aOptions.port;
|
||||
|
||||
this._onPageError = this._onPageError.bind(this);
|
||||
this._onConsoleAPICall = this._onConsoleAPICall.bind(this);
|
||||
|
@ -3938,7 +3948,15 @@ WebConsoleConnectionProxy.prototype = {
|
|||
*/
|
||||
connect: function WCCP_connect(aCallback)
|
||||
{
|
||||
let transport = DebuggerServer.connectPipe();
|
||||
let transport;
|
||||
if (this.remoteHost) {
|
||||
transport = debuggerSocketConnect(this.remoteHost, this.remotePort);
|
||||
}
|
||||
else {
|
||||
this.initServer();
|
||||
transport = DebuggerServer.connectPipe();
|
||||
}
|
||||
|
||||
let client = this.client = new DebuggerClient(transport);
|
||||
|
||||
client.addListener("pageError", this._onPageError);
|
||||
|
@ -3948,18 +3966,58 @@ WebConsoleConnectionProxy.prototype = {
|
|||
client.addListener("fileActivity", this._onFileActivity);
|
||||
client.addListener("locationChange", this._onLocationChange);
|
||||
|
||||
client.connect(function(aType, aTraits) {
|
||||
client.listTabs(this._onListTabs.bind(this, aCallback));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* The "listTabs" response handler.
|
||||
*
|
||||
* @private
|
||||
* @param function [aCallback]
|
||||
* Optional function to invoke once the connection is established.
|
||||
* @param object aResponse
|
||||
* The JSON response object received from the server.
|
||||
*/
|
||||
_onListTabs: function WCCP__onListTabs(aCallback, aResponse)
|
||||
{
|
||||
let selectedTab;
|
||||
|
||||
if (this.remoteHost) {
|
||||
let tabs = [];
|
||||
for (let tab of aResponse.tabs) {
|
||||
tabs.push(tab.title);
|
||||
}
|
||||
|
||||
tabs.push(l10n.getStr("listTabs.globalConsoleActor"));
|
||||
|
||||
let selected = {};
|
||||
let result = Services.prompt.select(null,
|
||||
l10n.getStr("remoteWebConsoleSelectTabTitle"),
|
||||
l10n.getStr("remoteWebConsoleSelectTabMessage"),
|
||||
tabs.length, tabs, selected);
|
||||
|
||||
if (result && selected.value < aResponse.tabs.length) {
|
||||
selectedTab = aResponse.tabs[selected.value];
|
||||
}
|
||||
}
|
||||
else {
|
||||
selectedTab = aResponse.tabs[aResponse.selected];
|
||||
}
|
||||
|
||||
if (selectedTab) {
|
||||
this._consoleActor = selectedTab.consoleActor;
|
||||
this.owner.onLocationChange(selectedTab.url, selectedTab.title);
|
||||
}
|
||||
else {
|
||||
this._consoleActor = aResponse.consoleActor;
|
||||
}
|
||||
|
||||
let listeners = ["PageError", "ConsoleAPI", "NetworkActivity",
|
||||
"FileActivity", "LocationChange"];
|
||||
|
||||
client.connect(function(aType, aTraits) {
|
||||
client.listTabs(function(aResponse) {
|
||||
let tab = aResponse.tabs[aResponse.selected];
|
||||
this._consoleActor = tab.consoleActor;
|
||||
this.owner.onLocationChange(tab.url, tab.title);
|
||||
client.attachConsole(tab.consoleActor, listeners,
|
||||
this._onAttachConsole.bind(this, aCallback));
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
this.client.attachConsole(this._consoleActor, listeners,
|
||||
this._onAttachConsole.bind(this, aCallback));
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -207,6 +207,7 @@ These should match what Safari and other Apple applications use on OS X Lion. --
|
|||
<!ENTITY webConsoleCmd.label "Web Console">
|
||||
<!ENTITY webConsoleCmd.accesskey "W">
|
||||
<!ENTITY webConsoleCmd.commandkey "k">
|
||||
<!ENTITY remoteWebConsoleCmd.label "Remote Web Console">
|
||||
|
||||
<!ENTITY inspectMenu.label "Inspect">
|
||||
<!ENTITY inspectMenu.accesskey "I">
|
||||
|
|
|
@ -145,3 +145,23 @@ maxTimersExceeded=The maximum allowed number of timers in this page was exceeded
|
|||
# Console and tries the Update button, but the new result no longer returns an
|
||||
# object that can be inspected.
|
||||
JSTerm.updateNotInspectable=After your input has been re-evaluated the result is no longer inspectable.
|
||||
|
||||
# LOCALIZATION NOTE (remoteWebConsolePromptTitle): The title displayed on the
|
||||
# Web Console prompt asking for the remote host and port to connect to.
|
||||
remoteWebConsolePromptTitle=Remote Connection
|
||||
|
||||
# LOCALIZATION NOTE (remoteWebConsolePromptMessage): The message displayed on the
|
||||
# Web Console prompt asking for the remote host and port to connect to.
|
||||
remoteWebConsolePromptMessage=Enter hostname and port number (host:port)
|
||||
|
||||
# LOCALIZATION NOTE (remoteWebConsoleSelectTabTitle): The title displayed on the
|
||||
# Web Console prompt asking the user to pick a tab to attach to.
|
||||
remoteWebConsoleSelectTabTitle=Tab list - Remote Connection
|
||||
|
||||
# LOCALIZATION NOTE (remoteWebConsoleSelectTabMessage): The message displayed on the
|
||||
# Web Console prompt asking the user to pick a tab to attach to.
|
||||
remoteWebConsoleSelectTabMessage=Select one of the tabs you want to attach to, or select the global console.
|
||||
|
||||
# LOCALIZATION NOTE (listTabs.globalConsoleActor): The string displayed for the
|
||||
# global console in the tabs selection.
|
||||
listTabs.globalConsoleActor=*Global Console*
|
||||
|
|
|
@ -355,6 +355,8 @@ WebConsoleActor.prototype =
|
|||
}
|
||||
this.consoleProgressListener.startMonitor(this.consoleProgressListener.
|
||||
MONITOR_LOCATION_CHANGE);
|
||||
startedListeners.push(listener);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
|
Загрузка…
Ссылка в новой задаче