mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 587757 - (global-console) Implement Browser Console; r=past,jwalker,Mossop
This commit is contained in:
parent
f74bb51834
commit
194c70be1c
@ -149,6 +149,8 @@
|
||||
observes="devtoolsMenuBroadcaster_DevToolbar"/>
|
||||
<menuitem id="appmenu_chromeDebugger"
|
||||
observes="devtoolsMenuBroadcaster_ChromeDebugger"/>
|
||||
<menuitem id="appmenu_browserConsole"
|
||||
observes="devtoolsMenuBroadcaster_BrowserConsole"/>
|
||||
<menuitem id="appmenu_responsiveUI"
|
||||
observes="devtoolsMenuBroadcaster_ResponsiveUI"/>
|
||||
<menuitem id="appmenu_scratchpad"
|
||||
|
@ -576,6 +576,8 @@
|
||||
accesskey="&devToolbarMenu.accesskey;"/>
|
||||
<menuitem id="menu_chromeDebugger"
|
||||
observes="devtoolsMenuBroadcaster_ChromeDebugger"/>
|
||||
<menuitem id="menu_browserConsole"
|
||||
observes="devtoolsMenuBroadcaster_BrowserConsole"/>
|
||||
<menuitem id="menu_responsiveUI"
|
||||
observes="devtoolsMenuBroadcaster_ResponsiveUI"
|
||||
accesskey="&responsiveDesignTool.accesskey;"/>
|
||||
|
@ -96,6 +96,7 @@
|
||||
<command id="Tools:DevToolbar" oncommand="DeveloperToolbar.toggle();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:DevToolbarFocus" oncommand="DeveloperToolbar.focusToggle();" disabled="true"/>
|
||||
<command id="Tools:ChromeDebugger" oncommand="DebuggerUI.toggleChromeDebugger();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:BrowserConsole" oncommand="HUDConsoleUI.toggleBrowserConsole();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:Scratchpad" oncommand="Scratchpad.openScratchpad();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:ResponsiveUI" oncommand="ResponsiveUI.toggle();" disabled="true" hidden="true"/>
|
||||
<command id="Tools:Addons" oncommand="BrowserOpenAddonsMgr();"/>
|
||||
@ -184,6 +185,9 @@
|
||||
<broadcaster id="devtoolsMenuBroadcaster_ChromeDebugger"
|
||||
label="&chromeDebuggerMenu.label;"
|
||||
command="Tools:ChromeDebugger"/>
|
||||
<broadcaster id="devtoolsMenuBroadcaster_BrowserConsole"
|
||||
label="&browserConsoleCmd.label;"
|
||||
command="Tools:BrowserConsole"/>
|
||||
<broadcaster id="devtoolsMenuBroadcaster_Scratchpad"
|
||||
label="&scratchpad.label;"
|
||||
command="Tools:Scratchpad"
|
||||
|
@ -1571,19 +1571,27 @@ var gBrowserInit = {
|
||||
}
|
||||
|
||||
// Enable Chrome Debugger?
|
||||
let enabled = gPrefService.getBoolPref("devtools.chrome.enabled") &&
|
||||
gPrefService.getBoolPref("devtools.debugger.chrome-enabled") &&
|
||||
gPrefService.getBoolPref("devtools.debugger.remote-enabled");
|
||||
if (enabled) {
|
||||
let chromeEnabled = gPrefService.getBoolPref("devtools.chrome.enabled");
|
||||
let remoteEnabled = chromeEnabled &&
|
||||
gPrefService.getBoolPref("devtools.debugger.chrome-enabled") &&
|
||||
gPrefService.getBoolPref("devtools.debugger.remote-enabled");
|
||||
if (remoteEnabled) {
|
||||
let cmd = document.getElementById("Tools:ChromeDebugger");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
// Enable the Browser Console?
|
||||
if (chromeEnabled) {
|
||||
let cmd = document.getElementById("Tools:BrowserConsole");
|
||||
cmd.removeAttribute("disabled");
|
||||
cmd.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
// Enable Error Console?
|
||||
// Temporarily enabled. See bug 798925.
|
||||
let consoleEnabled = true || gPrefService.getBoolPref("devtools.errorconsole.enabled") ||
|
||||
gPrefService.getBoolPref("devtools.chrome.enabled");
|
||||
chromeEnabled;
|
||||
if (consoleEnabled) {
|
||||
let cmd = document.getElementById("Tools:ErrorConsole");
|
||||
cmd.removeAttribute("disabled");
|
||||
|
@ -10,7 +10,6 @@ const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
const CONSOLEAPI_CLASS_ID = "{b49c18f8-3379-4fc0-8c90-d7772c1a9ff3}";
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
@ -23,15 +22,29 @@ XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
|
||||
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, "webConsoleDefinition",
|
||||
"resource:///modules/devtools/ToolDefinitions.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||
"resource://gre/modules/commonjs/sdk/core/promise.js");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ViewHelpers",
|
||||
"resource:///modules/devtools/ViewHelpers.jsm");
|
||||
|
||||
const STRINGS_URI = "chrome://browser/locale/devtools/webconsole.properties";
|
||||
let l10n = new WebConsoleUtils.l10n(STRINGS_URI);
|
||||
|
||||
const BROWSER_CONSOLE_WINDOW_FEATURES = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["HUDService"];
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -75,14 +88,39 @@ HUD_SERVICE.prototype =
|
||||
*
|
||||
* @param object aTarget
|
||||
* The target that the web console will connect to.
|
||||
* @param nsIDOMElement aIframe
|
||||
* The iframe element into which to place the web console.
|
||||
* @param nsIDOMWindow aIframeWindow
|
||||
* The window where the web console UI is already loaded.
|
||||
* @param nsIDOMWindow aChromeWindow
|
||||
* The window of the web console owner.
|
||||
* @return object
|
||||
* A Promise object for the opening of the new WebConsole instance.
|
||||
*/
|
||||
openWebConsole: function HS_openWebConsole(aTarget, aIframe)
|
||||
openWebConsole:
|
||||
function HS_openWebConsole(aTarget, aIframeWindow, aChromeWindow)
|
||||
{
|
||||
let hud = new WebConsole(aTarget, aIframe);
|
||||
let hud = new WebConsole(aTarget, aIframeWindow, aChromeWindow);
|
||||
this.hudReferences[hud.hudId] = hud;
|
||||
return hud.init();
|
||||
},
|
||||
|
||||
/**
|
||||
* Open a Browser Console for the given target.
|
||||
*
|
||||
* @see devtools/framework/Target.jsm for details about targets.
|
||||
*
|
||||
* @param object aTarget
|
||||
* The target that the browser console will connect to.
|
||||
* @param nsIDOMWindow aIframeWindow
|
||||
* The window where the browser console UI is already loaded.
|
||||
* @param nsIDOMWindow aChromeWindow
|
||||
* The window of the browser console owner.
|
||||
* @return object
|
||||
* A Promise object for the opening of the new BrowserConsole instance.
|
||||
*/
|
||||
openBrowserConsole:
|
||||
function HS_openBrowserConsole(aTarget, aIframeWindow, aChromeWindow)
|
||||
{
|
||||
let hud = new BrowserConsole(aTarget, aIframeWindow, aChromeWindow);
|
||||
this.hudReferences[hud.hudId] = hud;
|
||||
return hud.init();
|
||||
},
|
||||
@ -144,24 +182,27 @@ HUD_SERVICE.prototype =
|
||||
* that displays console log data as well as provides an interactive terminal to
|
||||
* manipulate the target's document content.
|
||||
*
|
||||
* This object only wraps the iframe that holds the Web Console UI.
|
||||
* This object only wraps the iframe that holds the Web Console UI. This is
|
||||
* meant to be an integration point between the Firefox UI and the Web Console
|
||||
* UI and features.
|
||||
*
|
||||
* @constructor
|
||||
* @param object aTarget
|
||||
* The target that the web console will connect to.
|
||||
* @param nsIDOMElement aIframe
|
||||
* iframe into which we should create the WebConsole UI.
|
||||
* @param nsIDOMWindow aIframeWindow
|
||||
* The window where the web console UI is already loaded.
|
||||
* @param nsIDOMWindow aChromeWindow
|
||||
* The window of the web console owner.
|
||||
*/
|
||||
function WebConsole(aTarget, aIframe)
|
||||
function WebConsole(aTarget, aIframeWindow, aChromeWindow)
|
||||
{
|
||||
this.iframe = aIframe;
|
||||
this.iframe.className = "web-console-frame";
|
||||
this.chromeDocument = this.iframe.ownerDocument;
|
||||
this.chromeWindow = this.chromeDocument.defaultView;
|
||||
this.iframeWindow = aIframeWindow;
|
||||
this.chromeWindow = aChromeWindow;
|
||||
this.hudId = "hud_" + Date.now();
|
||||
this.target = aTarget;
|
||||
|
||||
this.browserWindow = this.chromeWindow.top;
|
||||
|
||||
let element = this.browserWindow.document.documentElement;
|
||||
if (element.getAttribute("windowtype") != "navigator:browser") {
|
||||
this.browserWindow = HUDService.currentContext();
|
||||
@ -169,11 +210,12 @@ function WebConsole(aTarget, aIframe)
|
||||
}
|
||||
|
||||
WebConsole.prototype = {
|
||||
iframeWindow: null,
|
||||
chromeWindow: null,
|
||||
chromeDocument: null,
|
||||
browserWindow: null,
|
||||
hudId: null,
|
||||
target: null,
|
||||
iframe: null,
|
||||
_browserConsole: false,
|
||||
_destroyer: null,
|
||||
|
||||
/**
|
||||
@ -212,37 +254,8 @@ WebConsole.prototype = {
|
||||
*/
|
||||
init: function WC_init()
|
||||
{
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let onIframeLoad = function() {
|
||||
this.iframe.removeEventListener("load", onIframeLoad, true);
|
||||
initUI();
|
||||
}.bind(this);
|
||||
|
||||
let initUI = function() {
|
||||
this.iframeWindow = this.iframe.contentWindow.wrappedJSObject;
|
||||
this.ui = new this.iframeWindow.WebConsoleFrame(this);
|
||||
this.ui.init().then(onSuccess, onFailure);
|
||||
}.bind(this);
|
||||
|
||||
let onSuccess = function() {
|
||||
deferred.resolve(this);
|
||||
}.bind(this);
|
||||
|
||||
let onFailure = function(aReason) {
|
||||
deferred.reject(aReason);
|
||||
};
|
||||
|
||||
let win, doc;
|
||||
if ((win = this.iframe.contentWindow) &&
|
||||
(doc = win.document) &&
|
||||
doc.readyState == "complete") {
|
||||
initUI();
|
||||
}
|
||||
else {
|
||||
this.iframe.addEventListener("load", onIframeLoad, true);
|
||||
}
|
||||
return deferred.promise;
|
||||
this.ui = new this.iframeWindow.WebConsoleFrame(this);
|
||||
return this.ui.init().then(() => this);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -360,6 +373,10 @@ WebConsole.prototype = {
|
||||
let panelWin = null;
|
||||
let debuggerWasOpen = true;
|
||||
let toolbox = gDevTools.getToolbox(this.target);
|
||||
if (!toolbox) {
|
||||
self.viewSource(aSourceURL, aSourceLine);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!toolbox.getPanel("jsdebugger")) {
|
||||
debuggerWasOpen = false;
|
||||
@ -486,11 +503,102 @@ WebConsole.prototype = {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A BrowserConsole instance is an interactive console initialized *per target*
|
||||
* that displays console log data as well as provides an interactive terminal to
|
||||
* manipulate the target's document content.
|
||||
*
|
||||
* This object only wraps the iframe that holds the Browser Console UI. This is
|
||||
* meant to be an integration point between the Firefox UI and the Browser Console
|
||||
* UI and features.
|
||||
*
|
||||
* @constructor
|
||||
* @param object aTarget
|
||||
* The target that the browser console will connect to.
|
||||
* @param nsIDOMWindow aIframeWindow
|
||||
* The window where the browser console UI is already loaded.
|
||||
* @param nsIDOMWindow aChromeWindow
|
||||
* The window of the browser console owner.
|
||||
*/
|
||||
function BrowserConsole()
|
||||
{
|
||||
WebConsole.apply(this, arguments);
|
||||
}
|
||||
|
||||
ViewHelpers.create({ constructor: BrowserConsole, proto: WebConsole.prototype },
|
||||
{
|
||||
_browserConsole: true,
|
||||
_bc_init: null,
|
||||
_bc_destroyer: null,
|
||||
|
||||
$init: WebConsole.prototype.init,
|
||||
|
||||
/**
|
||||
* Initialize the Browser Console instance.
|
||||
*
|
||||
* @return object
|
||||
* A Promise for the initialization.
|
||||
*/
|
||||
init: function BC_init()
|
||||
{
|
||||
if (this._bc_init) {
|
||||
return this._bc_init;
|
||||
}
|
||||
|
||||
let window = this.iframeWindow;
|
||||
let onClose = () => {
|
||||
window.removeEventListener("unload", onClose);
|
||||
this.destroy();
|
||||
};
|
||||
window.addEventListener("unload", onClose);
|
||||
|
||||
this._bc_init = this.$init().then((aReason) => {
|
||||
let title = this.ui.rootElement.getAttribute("browserConsoleTitle");
|
||||
this.ui.rootElement.setAttribute("title", title);
|
||||
return aReason;
|
||||
});
|
||||
|
||||
return this._bc_init;
|
||||
},
|
||||
|
||||
$destroy: WebConsole.prototype.destroy,
|
||||
|
||||
/**
|
||||
* Destroy the object.
|
||||
*
|
||||
* @return object
|
||||
* A Promise object that is resolved once the Browser Console is closed.
|
||||
*/
|
||||
destroy: function BC_destroy()
|
||||
{
|
||||
if (this._bc_destroyer) {
|
||||
return this._bc_destroyer.promise;
|
||||
}
|
||||
|
||||
this._bc_destroyer = Promise.defer();
|
||||
|
||||
let chromeWindow = this.chromeWindow;
|
||||
this.$destroy().then(() =>
|
||||
this.target.client.close(() => {
|
||||
HeadsUpDisplayUICommands._browserConsoleID = null;
|
||||
chromeWindow.close();
|
||||
this._bc_destroyer.resolve(null);
|
||||
}));
|
||||
|
||||
return this._bc_destroyer.promise;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// HeadsUpDisplayUICommands
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var HeadsUpDisplayUICommands = {
|
||||
_browserConsoleID: null,
|
||||
_browserConsoleDefer: null,
|
||||
|
||||
/**
|
||||
* Toggle the Web Console for the current tab.
|
||||
*
|
||||
@ -527,6 +635,83 @@ var HeadsUpDisplayUICommands = {
|
||||
let panel = toolbox ? toolbox.getPanel("webconsole") : null;
|
||||
return panel ? panel.hud : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle the Browser Console.
|
||||
*/
|
||||
toggleBrowserConsole: function UIC_toggleBrowserConsole()
|
||||
{
|
||||
if (this._browserConsoleID) {
|
||||
let hud = HUDService.getHudReferenceById(this._browserConsoleID);
|
||||
return hud.destroy();
|
||||
}
|
||||
|
||||
if (this._browserConsoleDefer) {
|
||||
return this._browserConsoleDefer.promise;
|
||||
}
|
||||
|
||||
this._browserConsoleDefer = Promise.defer();
|
||||
|
||||
function connect()
|
||||
{
|
||||
let deferred = Promise.defer();
|
||||
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.addBrowserActors();
|
||||
}
|
||||
|
||||
let client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
client.connect(() =>
|
||||
client.listTabs((aResponse) =>
|
||||
deferred.resolve({ form: aResponse, client: client })
|
||||
));
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
let target;
|
||||
function getTarget(aConnection)
|
||||
{
|
||||
let options = {
|
||||
form: aConnection.form,
|
||||
client: aConnection.client,
|
||||
chrome: true,
|
||||
};
|
||||
|
||||
return TargetFactory.forRemoteTab(options);
|
||||
}
|
||||
|
||||
function openWindow(aTarget)
|
||||
{
|
||||
target = aTarget;
|
||||
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let win = Services.ww.openWindow(null, webConsoleDefinition.url, "_blank",
|
||||
BROWSER_CONSOLE_WINDOW_FEATURES, null);
|
||||
win.addEventListener("load", function onLoad() {
|
||||
win.removeEventListener("load", onLoad);
|
||||
deferred.resolve(win);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
connect().then(getTarget).then(openWindow).then((aWindow) =>
|
||||
HUDService.openBrowserConsole(target, aWindow, aWindow)
|
||||
.then((aBrowserConsole) => {
|
||||
this._browserConsoleID = aBrowserConsole.hudId;
|
||||
this._browserConsoleDefer.resolve(aBrowserConsole);
|
||||
this._browserConsoleDefer = null;
|
||||
}));
|
||||
|
||||
return this._browserConsoleDefer.promise;
|
||||
},
|
||||
|
||||
get browserConsole() {
|
||||
return HUDService.getHudReferenceById(this._browserConsoleID);
|
||||
},
|
||||
};
|
||||
|
||||
const HUDService = new HUD_SERVICE();
|
||||
|
@ -41,26 +41,52 @@ WebConsolePanel.prototype = {
|
||||
{
|
||||
let parentDoc = this._toolbox.doc;
|
||||
let iframe = parentDoc.getElementById("toolbox-panel-iframe-webconsole");
|
||||
let promise;
|
||||
iframe.className = "web-console-frame";
|
||||
|
||||
// Local debugging needs to make the target remote.
|
||||
if (!this.target.isRemote) {
|
||||
promise = this.target.makeRemote();
|
||||
} else {
|
||||
promise = Promise.resolve(this.target);
|
||||
// Make sure the iframe content window is ready.
|
||||
let deferredIframe = Promise.defer();
|
||||
let win, doc;
|
||||
if ((win = iframe.contentWindow) &&
|
||||
(doc = win.document) &&
|
||||
doc.readyState == "complete") {
|
||||
deferredIframe.resolve(null);
|
||||
}
|
||||
else {
|
||||
iframe.addEventListener("load", function onIframeLoad() {
|
||||
iframe.removeEventListener("load", onIframeLoad, true);
|
||||
deferredIframe.resolve(null);
|
||||
}, true);
|
||||
}
|
||||
|
||||
return promise
|
||||
.then(function(aTarget) {
|
||||
// Local debugging needs to make the target remote.
|
||||
let promiseTarget;
|
||||
if (!this.target.isRemote) {
|
||||
promiseTarget = this.target.makeRemote();
|
||||
}
|
||||
else {
|
||||
promiseTarget = Promise.resolve(this.target);
|
||||
}
|
||||
|
||||
// 1. Wait for the iframe to load.
|
||||
// 2. Wait for the remote target.
|
||||
// 3. Open the Web Console.
|
||||
return deferredIframe.promise
|
||||
.then(() => promiseTarget)
|
||||
.then((aTarget) => {
|
||||
this._frameWindow._remoteTarget = aTarget;
|
||||
return HUDService.openWebConsole(this.target, iframe);
|
||||
}.bind(this))
|
||||
.then(function onSuccess(aWebConsole) {
|
||||
|
||||
let webConsoleUIWindow = iframe.contentWindow.wrappedJSObject;
|
||||
let chromeWindow = iframe.ownerDocument.defaultView;
|
||||
|
||||
return HUDService.openWebConsole(this.target, webConsoleUIWindow,
|
||||
chromeWindow);
|
||||
})
|
||||
.then((aWebConsole) => {
|
||||
this.hud = aWebConsole;
|
||||
this._isReady = true;
|
||||
this.emit("ready");
|
||||
return this;
|
||||
}.bind(this), function onError(aReason) {
|
||||
}, (aReason) => {
|
||||
let msg = "WebConsolePanel open failed. " +
|
||||
aReason.error + ": " + aReason.message;
|
||||
dump(msg + "\n");
|
||||
@ -80,9 +106,7 @@ WebConsolePanel.prototype = {
|
||||
}
|
||||
|
||||
this._destroyer = this.hud.destroy();
|
||||
this._destroyer.then(function() {
|
||||
this.emit("destroyed");
|
||||
}.bind(this));
|
||||
this._destroyer.then(() => this.emit("destroyed"));
|
||||
|
||||
return this._destroyer;
|
||||
},
|
||||
|
@ -119,6 +119,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_eval_in_debugger_stackframe.js \
|
||||
browser_console_variables_view.js \
|
||||
browser_console_variables_view_while_debugging.js \
|
||||
browser_console.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
93
browser/devtools/webconsole/test/browser_console.js
Normal file
93
browser/devtools/webconsole/test/browser_console.js
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Test the basic features of the Browser Console, bug 587757.
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-eval-in-stackframe.html";
|
||||
|
||||
function test()
|
||||
{
|
||||
HUDConsoleUI.toggleBrowserConsole().then(consoleOpened);
|
||||
}
|
||||
|
||||
function consoleOpened(hud)
|
||||
{
|
||||
hud.jsterm.clearOutput(true);
|
||||
|
||||
expectUncaughtException();
|
||||
executeSoon(() => {
|
||||
foobarExceptionBug587757();
|
||||
});
|
||||
|
||||
// Add a message from a chrome window.
|
||||
hud.iframeWindow.console.log("bug587757a");
|
||||
|
||||
// Add a message from a content window.
|
||||
content.console.log("bug587757b");
|
||||
|
||||
// Test eval.
|
||||
hud.jsterm.execute("document.location.href");
|
||||
|
||||
// Check for network requests.
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.onload = () => info("xhr loaded, status is: " + xhr.status);
|
||||
xhr.open("get", TEST_URI, true);
|
||||
xhr.send();
|
||||
|
||||
let chromeConsole = -1;
|
||||
let contentConsole = -1;
|
||||
let execValue = -1;
|
||||
let exception = -1;
|
||||
let xhrRequest = false;
|
||||
|
||||
let output = hud.outputNode;
|
||||
function performChecks()
|
||||
{
|
||||
let text = output.textContent;
|
||||
chromeConsole = text.indexOf("bug587757a");
|
||||
contentConsole = text.indexOf("bug587757b");
|
||||
execValue = text.indexOf("browser.xul");
|
||||
exception = text.indexOf("foobarExceptionBug587757");
|
||||
|
||||
xhrRequest = false;
|
||||
let urls = output.querySelectorAll(".webconsole-msg-url");
|
||||
for (let url of urls) {
|
||||
if (url.value.indexOf(TEST_URI) > -1) {
|
||||
xhrRequest = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showResults()
|
||||
{
|
||||
isnot(chromeConsole, -1, "chrome window console.log() is displayed");
|
||||
isnot(contentConsole, -1, "content window console.log() is displayed");
|
||||
isnot(execValue, -1, "jsterm eval result is displayed");
|
||||
isnot(exception, -1, "exception is displayed");
|
||||
ok(xhrRequest, "xhr request is displayed");
|
||||
}
|
||||
|
||||
waitForSuccess({
|
||||
name: "messages displayed",
|
||||
validatorFn: () => {
|
||||
performChecks();
|
||||
return chromeConsole > -1 &&
|
||||
contentConsole > -1 &&
|
||||
execValue > -1 &&
|
||||
exception > -1 &&
|
||||
xhrRequest;
|
||||
},
|
||||
successFn: () => {
|
||||
showResults();
|
||||
executeSoon(finishTest);
|
||||
},
|
||||
failureFn: () => {
|
||||
showResults();
|
||||
info("output: " + output.textContent);
|
||||
executeSoon(finishTest);
|
||||
},
|
||||
});
|
||||
}
|
@ -20,7 +20,6 @@ function test()
|
||||
browser.removeEventListener(aEvent.type, onLoad1, true);
|
||||
|
||||
openConsole(null, function(aHud) {
|
||||
info("iframe1 height " + aHud.iframe.clientHeight);
|
||||
info("iframe1 root height " + aHud.ui.rootElement.clientHeight);
|
||||
|
||||
// open tab 2
|
||||
@ -31,7 +30,6 @@ function test()
|
||||
browser.removeEventListener(aEvent.type, onLoad2, true);
|
||||
|
||||
openConsole(null, function(aHud) {
|
||||
info("iframe2 height " + aHud.iframe.clientHeight);
|
||||
info("iframe2 root height " + aHud.ui.rootElement.clientHeight);
|
||||
waitForFocus(startTest, aHud.iframeWindow);
|
||||
});
|
||||
@ -115,7 +113,6 @@ function onpopupshown2b(aEvent)
|
||||
let hudId1 = HUDService.getHudIdByWindow(win1);
|
||||
huds[0] = HUDService.hudReferences[hudId1];
|
||||
|
||||
info("iframe1 height " + huds[0].iframe.clientHeight);
|
||||
info("iframe1 root height " + huds[0].ui.rootElement.clientHeight);
|
||||
|
||||
menuitems[0] = huds[0].ui.rootElement.querySelector("#saveBodies");
|
||||
|
@ -16,7 +16,7 @@ function test() {
|
||||
function testChrome(hud) {
|
||||
ok(hud, "we have a console");
|
||||
|
||||
ok(hud.iframe, "we have the console iframe");
|
||||
ok(hud.iframeWindow, "we have the console UI window");
|
||||
|
||||
let jsterm = hud.jsterm;
|
||||
ok(jsterm, "we have a jsterm");
|
||||
|
@ -234,6 +234,11 @@ function finishTest()
|
||||
{
|
||||
browser = hudId = hud = filterBox = outputNode = cs = null;
|
||||
|
||||
if (HUDConsoleUI.browserConsole) {
|
||||
HUDConsoleUI.toggleBrowserConsole().then(finishTest);
|
||||
return;
|
||||
}
|
||||
|
||||
let hud = HUDService.getHudByWindow(content);
|
||||
if (!hud) {
|
||||
finish();
|
||||
@ -250,6 +255,10 @@ function finishTest()
|
||||
|
||||
function tearDown()
|
||||
{
|
||||
if (HUDConsoleUI.browserConsole) {
|
||||
HUDConsoleUI.toggleBrowserConsole();
|
||||
}
|
||||
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
gDevTools.closeToolbox(target);
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
|
@ -225,6 +225,13 @@ WebConsoleFrame.prototype = {
|
||||
*/
|
||||
get popupset() this.owner.mainPopupSet,
|
||||
|
||||
/**
|
||||
* Holds the initialization Promise object.
|
||||
* @private
|
||||
* @type object
|
||||
*/
|
||||
_initDefer: null,
|
||||
|
||||
/**
|
||||
* Holds the network requests currently displayed by the Web Console. Each key
|
||||
* represents the connection ID and the value is network request information.
|
||||
@ -377,30 +384,27 @@ WebConsoleFrame.prototype = {
|
||||
*/
|
||||
_initConnection: function WCF__initConnection()
|
||||
{
|
||||
let deferred = Promise.defer();
|
||||
if (this._initDefer) {
|
||||
return this._initDefer.promise;
|
||||
}
|
||||
|
||||
this._initDefer = Promise.defer();
|
||||
this.proxy = new WebConsoleConnectionProxy(this, this.owner.target);
|
||||
|
||||
let onSuccess = function() {
|
||||
this.proxy.connect().then(() => { // on success
|
||||
this.saveRequestAndResponseBodies = this._saveRequestAndResponseBodies;
|
||||
deferred.resolve(this);
|
||||
}.bind(this);
|
||||
|
||||
let onFailure = function(aReason) {
|
||||
this._initDefer.resolve(this);
|
||||
}, (aReason) => { // on failure
|
||||
let node = this.createMessageNode(CATEGORY_JS, SEVERITY_ERROR,
|
||||
aReason.error + ": " + aReason.message);
|
||||
this.outputMessage(CATEGORY_JS, node);
|
||||
deferred.reject(aReason);
|
||||
}.bind(this);
|
||||
|
||||
let sendNotification = function() {
|
||||
this._initDefer.reject(aReason);
|
||||
}).then(() => {
|
||||
let id = WebConsoleUtils.supportsString(this.hudId);
|
||||
Services.obs.notifyObservers(id, "web-console-created", null);
|
||||
}.bind(this);
|
||||
});
|
||||
|
||||
this.proxy.connect().then(onSuccess, onFailure).then(sendNotification);
|
||||
|
||||
return deferred.promise;
|
||||
return this._initDefer.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -2682,7 +2686,7 @@ JSTerm.prototype = {
|
||||
*/
|
||||
init: function JST_init()
|
||||
{
|
||||
let chromeDocument = this.hud.owner.chromeDocument;
|
||||
let chromeDocument = this.hud.owner.chromeWindow.document;
|
||||
let autocompleteOptions = {
|
||||
onSelect: this.onAutocompleteSelect.bind(this),
|
||||
onClick: this.acceptProposedCompletion.bind(this),
|
||||
@ -4143,7 +4147,7 @@ JSTerm.prototype = {
|
||||
this.autocompletePopup.destroy();
|
||||
this.autocompletePopup = null;
|
||||
|
||||
let popup = this.hud.owner.chromeDocument
|
||||
let popup = this.hud.owner.chromeWindow.document
|
||||
.getElementById("webConsole_autocompletePopup");
|
||||
if (popup) {
|
||||
popup.parentNode.removeChild(popup);
|
||||
@ -4321,6 +4325,8 @@ CommandController.prototype = {
|
||||
case "cmd_fontSizeReset":
|
||||
case "cmd_selectAll":
|
||||
return true;
|
||||
case "cmd_close":
|
||||
return this.owner.owner._browserConsole;
|
||||
}
|
||||
},
|
||||
|
||||
@ -4348,6 +4354,9 @@ CommandController.prototype = {
|
||||
case "cmd_fontSizeReset":
|
||||
this.owner.changeFontSize("");
|
||||
break;
|
||||
case "cmd_close":
|
||||
this.owner.window.close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -13,8 +13,13 @@
|
||||
type="text/css"?>
|
||||
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
id="devtools-webconsole"
|
||||
macanimationtype="document"
|
||||
fullscreenbutton="true"
|
||||
title="&window.title;"
|
||||
browserConsoleTitle="&browserConsole.title;"
|
||||
windowtype="devtools:webconsole"
|
||||
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"/>
|
||||
@ -32,8 +37,9 @@
|
||||
<command id="cmd_fullZoomEnlarge" oncommand="goDoCommand('cmd_fontSizeEnlarge');"/>
|
||||
<command id="cmd_fullZoomReduce" oncommand="goDoCommand('cmd_fontSizeReduce');"/>
|
||||
<command id="cmd_fullZoomReset" oncommand="goDoCommand('cmd_fontSizeReset');"/>
|
||||
<command id="cmd_close" oncommand="goDoCommand('cmd_close');"/>
|
||||
</commandset>
|
||||
<keyset id="fontSizeChangeSet">
|
||||
<keyset id="consoleKeys">
|
||||
<key id="key_fullZoomReduce" key="&fullZoomReduceCmd.commandkey;" command="cmd_fullZoomReduce" modifiers="accel"/>
|
||||
<key key="&fullZoomReduceCmd.commandkey2;" command="cmd_fullZoomReduce" modifiers="accel"/>
|
||||
<key id="key_fullZoomEnlarge" key="&fullZoomEnlargeCmd.commandkey;" command="cmd_fullZoomEnlarge" modifiers="accel"/>
|
||||
@ -41,6 +47,7 @@
|
||||
<key key="&fullZoomEnlargeCmd.commandkey3;" command="cmd_fullZoomEnlarge" modifiers="accel"/>
|
||||
<key id="key_fullZoomReset" key="&fullZoomResetCmd.commandkey;" command="cmd_fullZoomReset" modifiers="accel"/>
|
||||
<key key="&fullZoomResetCmd.commandkey2;" command="cmd_fullZoomReset" modifiers="accel"/>
|
||||
<key key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
|
||||
</keyset>
|
||||
<keyset id="editMenuKeys"/>
|
||||
|
||||
|
@ -207,6 +207,8 @@ These should match what Safari and other Apple applications use on OS X Lion. --
|
||||
|
||||
<!ENTITY remoteWebConsoleCmd.label "Remote Web Console">
|
||||
|
||||
<!ENTITY browserConsoleCmd.label "Browser Console">
|
||||
|
||||
<!ENTITY inspectContextMenu.label "Inspect Element">
|
||||
<!ENTITY inspectContextMenu.accesskey "Q">
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
- documentation on web development on the web. -->
|
||||
|
||||
<!ENTITY window.title "Web Console">
|
||||
<!ENTITY browserConsole.title "Browser Console">
|
||||
|
||||
<!ENTITY networkPanel.requestURLColon "Request URL:">
|
||||
<!ENTITY networkPanel.requestMethodColon "Request Method:">
|
||||
@ -76,3 +77,5 @@
|
||||
|
||||
<!ENTITY copyURLCmd.label "Copy Link Location">
|
||||
<!ENTITY copyURLCmd.accesskey "a">
|
||||
|
||||
<!ENTITY closeCmd.key "W">
|
||||
|
Loading…
Reference in New Issue
Block a user