mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 673148 - (async-webconsole) Part 2 - Make script and style errors async; r=rcampbell,felipc
This commit is contained in:
parent
f8c9aaddb1
commit
664943ceef
@ -7,31 +7,25 @@
|
||||
"use strict";
|
||||
|
||||
// This code is appended to the browser content script.
|
||||
(function(_global) {
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
(function _HUDServiceContent() {
|
||||
let Cc = Components.classes;
|
||||
let Ci = Components.interfaces;
|
||||
let Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
let tempScope = {};
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm", tempScope);
|
||||
Cu.import("resource://gre/modules/Services.jsm", tempScope);
|
||||
Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm", tempScope);
|
||||
Cu.import("resource:///modules/WebConsoleUtils.jsm", tempScope);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(_global, "gConsoleStorage", function () {
|
||||
let obj = {};
|
||||
Cu.import("resource://gre/modules/ConsoleAPIStorage.jsm", obj);
|
||||
return obj.ConsoleAPIStorage;
|
||||
});
|
||||
let XPCOMUtils = tempScope.XPCOMUtils;
|
||||
let Services = tempScope.Services;
|
||||
let gConsoleStorage = tempScope.ConsoleAPIStorage;
|
||||
let WebConsoleUtils = tempScope.WebConsoleUtils;
|
||||
let l10n = WebConsoleUtils.l10n;
|
||||
tempScope = null;
|
||||
|
||||
XPCOMUtils.defineLazyGetter(_global, "WebConsoleUtils", function () {
|
||||
let obj = {};
|
||||
Cu.import("resource:///modules/WebConsoleUtils.jsm", obj);
|
||||
return obj.WebConsoleUtils;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(_global, "l10n", function () {
|
||||
return WebConsoleUtils.l10n;
|
||||
});
|
||||
|
||||
_global = null;
|
||||
let _alive = true; // Track if this content script should still be alive.
|
||||
|
||||
/**
|
||||
* The Web Console content instance manager.
|
||||
@ -63,6 +57,26 @@ let Manager = {
|
||||
this._messageListeners.forEach(function(aName) {
|
||||
addMessageListener(aName, this);
|
||||
}, this);
|
||||
|
||||
// Need to track the owner XUL window to listen to the unload and TabClose
|
||||
// events, to avoid memory leaks.
|
||||
let xulWindow = this.window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell)
|
||||
.chromeEventHandler.ownerDocument.defaultView;
|
||||
|
||||
xulWindow.addEventListener("unload", this._onXULWindowClose, false);
|
||||
|
||||
let tabContainer = xulWindow.gBrowser.tabContainer;
|
||||
tabContainer.addEventListener("TabClose", this._onTabClose, false);
|
||||
|
||||
// Need to track private browsing change and quit application notifications,
|
||||
// again to avoid memory leaks. The Web Console main process cannot notify
|
||||
// this content script when the XUL window close, tab close, private
|
||||
// browsing change and quit application events happen, so we must call
|
||||
// Manager.destroy() on our own.
|
||||
Services.obs.addObserver(this, "private-browsing-change-granted", false);
|
||||
Services.obs.addObserver(this, "quit-application-granted", false);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -71,6 +85,10 @@ let Manager = {
|
||||
*/
|
||||
receiveMessage: function Manager_receiveMessage(aMessage)
|
||||
{
|
||||
if (!_alive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aMessage.json || (aMessage.name != "WebConsole:Init" &&
|
||||
aMessage.json.hudId != this.hudId)) {
|
||||
Cu.reportError("Web Console content script: received message " +
|
||||
@ -99,6 +117,22 @@ let Manager = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Observe notifications from the nsIObserverService.
|
||||
*
|
||||
* @param mixed aSubject
|
||||
* @param string aTopic
|
||||
* @param mixed aData
|
||||
*/
|
||||
observe: function Manager_observe(aSubject, aTopic, aData)
|
||||
{
|
||||
if (_alive && (aTopic == "quit-application-granted" ||
|
||||
(aTopic == "private-browsing-change-granted" &&
|
||||
(aData == "enter" || aData == "exit")))) {
|
||||
this.destroy();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The manager initialization code. This method is called when the Web Console
|
||||
* remote process initializes the content process (this code!).
|
||||
@ -110,9 +144,11 @@ let Manager = {
|
||||
* - features - (optional) array of features you want to enable from
|
||||
* the start. For each feature you enable you can pass feature-specific
|
||||
* options in a property on the JSON object you send with the same name
|
||||
* as the feature.
|
||||
* as the feature. See this.enableFeature() for the list of available
|
||||
* features.
|
||||
* - cachedMessages - (optional) an array of cached messages you want
|
||||
* to receive: only "ConsoleAPI" is available for now.
|
||||
* to receive. See this._sendCachedMessages() for the list of available
|
||||
* message types.
|
||||
*
|
||||
* Example message:
|
||||
* {
|
||||
@ -203,6 +239,8 @@ let Manager = {
|
||||
* - JSTerm - a JavaScript "terminal" which allows code execution.
|
||||
* - ConsoleAPI - support for routing the window.console API to the remote
|
||||
* process.
|
||||
* - PageError - route all the nsIScriptErrors from the nsIConsoleService
|
||||
* to the remote process.
|
||||
*
|
||||
* @param string aFeature
|
||||
* One of the supported features: JSTerm, ConsoleAPI.
|
||||
@ -223,6 +261,9 @@ let Manager = {
|
||||
case "ConsoleAPI":
|
||||
ConsoleAPIObserver.init(aMessage);
|
||||
break;
|
||||
case "PageError":
|
||||
ConsoleListener.init(aMessage);
|
||||
break;
|
||||
default:
|
||||
Cu.reportError("Web Console content: unknown feature " + aFeature);
|
||||
break;
|
||||
@ -236,7 +277,8 @@ let Manager = {
|
||||
*
|
||||
* @see this.enableFeature
|
||||
* @param string aFeature
|
||||
* One of the supported features: JSTerm, ConsoleAPI.
|
||||
* One of the supported features - see this.enableFeature() for the
|
||||
* list of supported features.
|
||||
*/
|
||||
disableFeature: function Manager_disableFeature(aFeature)
|
||||
{
|
||||
@ -253,6 +295,9 @@ let Manager = {
|
||||
case "ConsoleAPI":
|
||||
ConsoleAPIObserver.destroy();
|
||||
break;
|
||||
case "PageError":
|
||||
ConsoleListener.destroy();
|
||||
break;
|
||||
default:
|
||||
Cu.reportError("Web Console content: unknown feature " + aFeature);
|
||||
break;
|
||||
@ -264,17 +309,22 @@ let Manager = {
|
||||
*
|
||||
* @private
|
||||
* @param array aMessageTypes
|
||||
* An array that lists which kinds of messages you want. Currently only
|
||||
* "ConsoleAPI" messages are supported.
|
||||
* An array that lists which kinds of messages you want. Supported
|
||||
* message types: "ConsoleAPI" and "PageError".
|
||||
*/
|
||||
_sendCachedMessages: function Manager__sendCachedMessages(aMessageTypes)
|
||||
{
|
||||
let messages = [];
|
||||
|
||||
switch (aMessageTypes.shift()) {
|
||||
case "ConsoleAPI":
|
||||
messages.push.apply(messages, ConsoleAPIObserver.getCachedMessages());
|
||||
break;
|
||||
while (aMessageTypes.length > 0) {
|
||||
switch (aMessageTypes.shift()) {
|
||||
case "ConsoleAPI":
|
||||
messages.push.apply(messages, ConsoleAPIObserver.getCachedMessages());
|
||||
break;
|
||||
case "PageError":
|
||||
messages.push.apply(messages, ConsoleListener.getCachedMessages());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
messages.sort(function(a, b) { return a.timeStamp - b.timeStamp; });
|
||||
@ -282,11 +332,49 @@ let Manager = {
|
||||
this.sendMessage("WebConsole:CachedMessages", {messages: messages});
|
||||
},
|
||||
|
||||
/**
|
||||
* The XUL window "unload" event handler which destroys this content script
|
||||
* instance.
|
||||
* @private
|
||||
*/
|
||||
_onXULWindowClose: function Manager__onXULWindowClose()
|
||||
{
|
||||
if (_alive) {
|
||||
Manager.destroy();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The "TabClose" event handler which destroys this content script
|
||||
* instance, if needed.
|
||||
* @private
|
||||
*/
|
||||
_onTabClose: function Manager__onTabClose(aEvent)
|
||||
{
|
||||
let tab = aEvent.target;
|
||||
if (_alive && tab.linkedBrowser.contentWindow === Manager.window) {
|
||||
Manager.destroy();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the Web Console content script instance.
|
||||
*/
|
||||
destroy: function Manager_destroy()
|
||||
{
|
||||
Services.obs.removeObserver(this, "private-browsing-change-granted");
|
||||
Services.obs.removeObserver(this, "quit-application-granted");
|
||||
|
||||
_alive = false;
|
||||
let xulWindow = this.window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell)
|
||||
.chromeEventHandler.ownerDocument.defaultView;
|
||||
|
||||
xulWindow.removeEventListener("unload", this._onXULWindowClose, false);
|
||||
let tabContainer = xulWindow.gBrowser.tabContainer;
|
||||
tabContainer.removeEventListener("TabClose", this._onTabClose, false);
|
||||
|
||||
this._messageListeners.forEach(function(aName) {
|
||||
removeMessageListener(aName, this);
|
||||
}, this);
|
||||
@ -295,7 +383,9 @@ let Manager = {
|
||||
|
||||
this.hudId = null;
|
||||
this._messageHandlers = null;
|
||||
Manager = ConsoleAPIObserver = JSTerm = null;
|
||||
Manager = ConsoleAPIObserver = JSTerm = ConsoleListener = null;
|
||||
Cc = Ci = Cu = XPCOMUtils = Services = gConsoleStorage =
|
||||
WebConsoleUtils = l10n = null;
|
||||
},
|
||||
};
|
||||
|
||||
@ -447,7 +537,7 @@ let ConsoleAPIObserver = {
|
||||
*/
|
||||
observe: function CAO_observe(aMessage, aTopic)
|
||||
{
|
||||
if (!aMessage || aTopic != "console-api-log-event") {
|
||||
if (!_alive || !aMessage || aTopic != "console-api-log-event") {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -578,11 +668,7 @@ let ConsoleAPIObserver = {
|
||||
let messages = gConsoleStorage.getEvents(innerWindowId);
|
||||
|
||||
let result = messages.map(function(aMessage) {
|
||||
let remoteMessage = {
|
||||
hudId: Manager.hudId,
|
||||
id: Manager.sequenceId,
|
||||
type: "ConsoleAPI",
|
||||
};
|
||||
let remoteMessage = { _type: "ConsoleAPI" };
|
||||
this._prepareApiMessageForRemote(aMessage.wrappedJSObject, remoteMessage);
|
||||
return remoteMessage;
|
||||
}, this);
|
||||
@ -609,5 +695,96 @@ let ConsoleAPIObserver = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The nsIConsoleService listener. This is used to send all the page errors
|
||||
* (JavaScript, CSS and more) to the remote Web Console instance.
|
||||
*/
|
||||
let ConsoleListener = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIConsoleListener]),
|
||||
|
||||
/**
|
||||
* Initialize the nsIConsoleService listener.
|
||||
*/
|
||||
init: function CL_init()
|
||||
{
|
||||
Services.console.registerListener(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* The nsIConsoleService observer. This method takes all the script error
|
||||
* messages belonging to the current window and sends them to the remote Web
|
||||
* Console instance.
|
||||
*
|
||||
* @param nsIScriptError aScriptError
|
||||
* The script error object coming from the nsIConsoleService.
|
||||
*/
|
||||
observe: function CL_observe(aScriptError)
|
||||
{
|
||||
if (!_alive || !(aScriptError instanceof Ci.nsIScriptError) ||
|
||||
!aScriptError.outerWindowID) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aScriptError.category) {
|
||||
// We ignore chrome-originating errors as we only care about content.
|
||||
case "XPConnect JavaScript":
|
||||
case "component javascript":
|
||||
case "chrome javascript":
|
||||
case "chrome registration":
|
||||
case "XBL":
|
||||
case "XBL Prototype Handler":
|
||||
case "XBL Content Sink":
|
||||
case "xbl javascript":
|
||||
return;
|
||||
}
|
||||
|
||||
let errorWindow =
|
||||
WebConsoleUtils.getWindowByOuterId(aScriptError.outerWindowID,
|
||||
Manager.window);
|
||||
if (!errorWindow || errorWindow.top != Manager.window) {
|
||||
return;
|
||||
}
|
||||
|
||||
Manager.sendMessage("WebConsole:PageError", { pageError: aScriptError });
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the cached page errors for the current inner window.
|
||||
*
|
||||
* @return array
|
||||
* The array of cached messages. Each element is an nsIScriptError
|
||||
* with an added _type property so the remote Web Console instance can
|
||||
* tell the difference between various types of cached messages.
|
||||
*/
|
||||
getCachedMessages: function CL_getCachedMessages()
|
||||
{
|
||||
let innerWindowId = WebConsoleUtils.getInnerWindowId(Manager.window);
|
||||
let result = [];
|
||||
let errors = {};
|
||||
Services.console.getMessageArray(errors, {});
|
||||
|
||||
(errors.value || []).forEach(function(aError) {
|
||||
if (!(aError instanceof Ci.nsIScriptError) ||
|
||||
aError.innerWindowID != innerWindowId) {
|
||||
return;
|
||||
}
|
||||
|
||||
let remoteMessage = WebConsoleUtils.cloneObject(aError);
|
||||
remoteMessage._type = "PageError";
|
||||
result.push(remoteMessage);
|
||||
});
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove the nsIConsoleService listener.
|
||||
*/
|
||||
destroy: function CL_destroy()
|
||||
{
|
||||
Services.console.unregisterListener(this);
|
||||
},
|
||||
};
|
||||
|
||||
Manager.init();
|
||||
})(this);
|
||||
})();
|
||||
|
@ -1503,8 +1503,9 @@ HUD_SERVICE.prototype =
|
||||
let nBox = chromeDocument.defaultView.getNotificationBox(window);
|
||||
let hudId = "hud_" + nBox.id;
|
||||
let displayNode = chromeDocument.getElementById(hudId);
|
||||
let hudFound = (hudId in this.hudReferences) && displayNode;
|
||||
|
||||
if (hudId in this.hudReferences && displayNode) {
|
||||
if (hudFound) {
|
||||
if (!aAnimated) {
|
||||
this.storeHeight(hudId);
|
||||
}
|
||||
@ -1533,8 +1534,10 @@ HUD_SERVICE.prototype =
|
||||
}
|
||||
}
|
||||
|
||||
let id = WebConsoleUtils.supportsString(hudId);
|
||||
Services.obs.notifyObservers(id, "web-console-destroyed", null);
|
||||
if (hudFound) {
|
||||
let id = WebConsoleUtils.supportsString(hudId);
|
||||
Services.obs.notifyObservers(id, "web-console-destroyed", null);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1854,8 +1857,6 @@ HUD_SERVICE.prototype =
|
||||
this.startHTTPObservation();
|
||||
|
||||
HUDWindowObserver.init();
|
||||
HUDConsoleObserver.init();
|
||||
ConsoleAPIObserver.init();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1880,8 +1881,6 @@ HUD_SERVICE.prototype =
|
||||
delete this.lastFinishedRequestCallback;
|
||||
|
||||
HUDWindowObserver.uninit();
|
||||
HUDConsoleObserver.uninit();
|
||||
ConsoleAPIObserver.shutdown();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1987,73 +1986,6 @@ HUD_SERVICE.prototype =
|
||||
ConsoleUtils.outputMessageNode(node, aHUDId);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reports an error in the page source, either JavaScript or CSS.
|
||||
*
|
||||
* @param nsIScriptError aScriptError
|
||||
* The error message to report.
|
||||
* @return void
|
||||
*/
|
||||
reportPageError: function HS_reportPageError(aScriptError)
|
||||
{
|
||||
if (!aScriptError.outerWindowID) {
|
||||
return;
|
||||
}
|
||||
|
||||
let category;
|
||||
|
||||
switch (aScriptError.category) {
|
||||
// We ignore chrome-originating errors as we only care about content.
|
||||
case "XPConnect JavaScript":
|
||||
case "component javascript":
|
||||
case "chrome javascript":
|
||||
case "chrome registration":
|
||||
case "XBL":
|
||||
case "XBL Prototype Handler":
|
||||
case "XBL Content Sink":
|
||||
case "xbl javascript":
|
||||
return;
|
||||
|
||||
case "CSS Parser":
|
||||
case "CSS Loader":
|
||||
category = CATEGORY_CSS;
|
||||
break;
|
||||
|
||||
default:
|
||||
category = CATEGORY_JS;
|
||||
break;
|
||||
}
|
||||
|
||||
// Warnings and legacy strict errors become warnings; other types become
|
||||
// errors.
|
||||
let severity = SEVERITY_ERROR;
|
||||
if ((aScriptError.flags & aScriptError.warningFlag) ||
|
||||
(aScriptError.flags & aScriptError.strictFlag)) {
|
||||
severity = SEVERITY_WARNING;
|
||||
}
|
||||
|
||||
let window = WebConsoleUtils.getWindowByOuterId(aScriptError.outerWindowID);
|
||||
if (window) {
|
||||
let hudId = HUDService.getHudIdByWindow(window.top);
|
||||
if (hudId) {
|
||||
let outputNode = this.hudReferences[hudId].outputNode;
|
||||
let chromeDocument = outputNode.ownerDocument;
|
||||
|
||||
let node = ConsoleUtils.createMessageNode(chromeDocument,
|
||||
category,
|
||||
severity,
|
||||
aScriptError.errorMessage,
|
||||
hudId,
|
||||
aScriptError.sourceName,
|
||||
aScriptError.lineNumber,
|
||||
null, null,
|
||||
aScriptError.timeStamp);
|
||||
|
||||
ConsoleUtils.outputMessageNode(node, hudId);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Register a Gecko app's specialized ApplicationHooks object
|
||||
*
|
||||
@ -3030,7 +2962,7 @@ HeadsUpDisplay.prototype = {
|
||||
* @type array
|
||||
*/
|
||||
_messageListeners: ["JSTerm:EvalObject", "WebConsole:ConsoleAPI",
|
||||
"WebConsole:CachedMessages"],
|
||||
"WebConsole:CachedMessages", "WebConsole:PageError"],
|
||||
|
||||
consolePanel: null,
|
||||
|
||||
@ -3374,42 +3306,30 @@ HeadsUpDisplay.prototype = {
|
||||
* Display cached messages that may have been collected before the UI is
|
||||
* displayed.
|
||||
*
|
||||
* @private
|
||||
* @param array aRemoteMessages
|
||||
* Array of cached messages coming from the remote Web Console
|
||||
* content instance.
|
||||
*/
|
||||
displayCachedConsoleMessages:
|
||||
function HUD_displayCachedConsoleMessages(aRemoteMessages)
|
||||
_displayCachedConsoleMessages:
|
||||
function HUD__displayCachedConsoleMessages(aRemoteMessages)
|
||||
{
|
||||
let innerWindowId = WebConsoleUtils.getInnerWindowId(this.contentWindow);
|
||||
|
||||
let messages = aRemoteMessages;
|
||||
|
||||
let errors = {};
|
||||
Services.console.getMessageArray(errors, {});
|
||||
|
||||
// Filter the errors to find only those we should display.
|
||||
let filteredErrors = (errors.value || []).filter(function(aError) {
|
||||
return aError instanceof Ci.nsIScriptError &&
|
||||
aError.innerWindowID == innerWindowId;
|
||||
}, this);
|
||||
|
||||
messages.push.apply(messages, filteredErrors);
|
||||
messages.sort(function(a, b) { return a.timeStamp - b.timeStamp; });
|
||||
if (!aRemoteMessages.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Turn off scrolling for the moment.
|
||||
ConsoleUtils.scroll = false;
|
||||
this.outputNode.hidden = true;
|
||||
|
||||
// Display all messages.
|
||||
messages.forEach(function(aMessage) {
|
||||
if (aMessage instanceof Ci.nsIScriptError) {
|
||||
HUDService.reportPageError(aMessage);
|
||||
}
|
||||
else {
|
||||
// In this case the cached message is a console message generated
|
||||
// by the ConsoleAPI, not an nsIScriptError
|
||||
this.logConsoleAPIMessage(aMessage);
|
||||
aRemoteMessages.forEach(function(aMessage) {
|
||||
switch (aMessage._type) {
|
||||
case "PageError":
|
||||
this.reportPageError(aMessage);
|
||||
break;
|
||||
case "ConsoleAPI":
|
||||
this.logConsoleAPIMessage(aMessage);
|
||||
break;
|
||||
}
|
||||
}, this);
|
||||
|
||||
@ -4073,6 +3993,64 @@ HeadsUpDisplay.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Reports an error in the page source, either JavaScript or CSS.
|
||||
*
|
||||
* @param nsIScriptError aScriptError
|
||||
* The error message to report.
|
||||
*/
|
||||
reportPageError: function HUD_reportPageError(aScriptError)
|
||||
{
|
||||
if (!aScriptError.outerWindowID) {
|
||||
return;
|
||||
}
|
||||
|
||||
let category;
|
||||
|
||||
switch (aScriptError.category) {
|
||||
// We ignore chrome-originating errors as we only care about content.
|
||||
case "XPConnect JavaScript":
|
||||
case "component javascript":
|
||||
case "chrome javascript":
|
||||
case "chrome registration":
|
||||
case "XBL":
|
||||
case "XBL Prototype Handler":
|
||||
case "XBL Content Sink":
|
||||
case "xbl javascript":
|
||||
return;
|
||||
|
||||
case "CSS Parser":
|
||||
case "CSS Loader":
|
||||
category = CATEGORY_CSS;
|
||||
break;
|
||||
|
||||
default:
|
||||
category = CATEGORY_JS;
|
||||
break;
|
||||
}
|
||||
|
||||
// Warnings and legacy strict errors become warnings; other types become
|
||||
// errors.
|
||||
let severity = SEVERITY_ERROR;
|
||||
if ((aScriptError.flags & aScriptError.warningFlag) ||
|
||||
(aScriptError.flags & aScriptError.strictFlag)) {
|
||||
severity = SEVERITY_WARNING;
|
||||
}
|
||||
|
||||
let node = ConsoleUtils.createMessageNode(this.chromeDocument,
|
||||
category,
|
||||
severity,
|
||||
aScriptError.errorMessage,
|
||||
this.hudId,
|
||||
aScriptError.sourceName,
|
||||
aScriptError.lineNumber,
|
||||
null,
|
||||
null,
|
||||
aScriptError.timeStamp);
|
||||
|
||||
ConsoleUtils.outputMessageNode(node, this.hudId);
|
||||
},
|
||||
|
||||
ERRORS: {
|
||||
HUD_BOX_DOES_NOT_EXIST: "Heads Up Display does not exist",
|
||||
TAB_ID_REQUIRED: "Tab DOM ID is required",
|
||||
@ -4096,8 +4074,8 @@ HeadsUpDisplay.prototype = {
|
||||
|
||||
let message = {
|
||||
hudId: this.hudId,
|
||||
features: ["ConsoleAPI", "JSTerm"],
|
||||
cachedMessages: ["ConsoleAPI"],
|
||||
features: ["ConsoleAPI", "JSTerm", "PageError"],
|
||||
cachedMessages: ["ConsoleAPI", "PageError"],
|
||||
};
|
||||
this.sendMessageToContent("WebConsole:Init", message);
|
||||
},
|
||||
@ -4124,8 +4102,11 @@ HeadsUpDisplay.prototype = {
|
||||
case "WebConsole:ConsoleAPI":
|
||||
this.logConsoleAPIMessage(aMessage.json);
|
||||
break;
|
||||
case "WebConsole:PageError":
|
||||
this.reportPageError(aMessage.json.pageError);
|
||||
break;
|
||||
case "WebConsole:CachedMessages":
|
||||
this.displayCachedConsoleMessages(aMessage.json.messages);
|
||||
this._displayCachedConsoleMessages(aMessage.json.messages);
|
||||
this._onInitComplete();
|
||||
break;
|
||||
}
|
||||
@ -4277,33 +4258,6 @@ HeadsUpDisplay.prototype = {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// ConsoleAPIObserver
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
let ConsoleAPIObserver = {
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||
|
||||
init: function CAO_init()
|
||||
{
|
||||
Services.obs.addObserver(this, "quit-application-granted", false);
|
||||
},
|
||||
|
||||
observe: function CAO_observe(aMessage, aTopic, aData)
|
||||
{
|
||||
if (aTopic == "quit-application-granted") {
|
||||
HUDService.shutdown();
|
||||
}
|
||||
},
|
||||
|
||||
shutdown: function CAO_shutdown()
|
||||
{
|
||||
Services.obs.removeObserver(this, "quit-application-granted");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a DOM Node factory for XUL nodes - as well as textNodes
|
||||
* @param aFactoryType "xul" or "text"
|
||||
@ -4853,6 +4807,7 @@ function JSTerm(aContext, aParentNode, aMixin, aConsole)
|
||||
}
|
||||
this.hudId = node.getAttribute("id");
|
||||
|
||||
this.history = [];
|
||||
this.historyIndex = 0;
|
||||
this.historyPlaceHolder = 0; // this.history.length;
|
||||
this.log = LogFactory("*** JSTerm:");
|
||||
@ -5474,7 +5429,7 @@ JSTerm.prototype = {
|
||||
node.selectionStart == 0 && !multiline;
|
||||
},
|
||||
|
||||
history: [],
|
||||
history: null,
|
||||
|
||||
// Stores the data for the last completion.
|
||||
lastCompletion: null,
|
||||
@ -6485,14 +6440,12 @@ ConsoleEntry.prototype = {
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HUDWindowObserver = {
|
||||
QueryInterface: XPCOMUtils.generateQI(
|
||||
[Ci.nsIObserver,]
|
||||
),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||
|
||||
init: function HWO_init()
|
||||
{
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
Services.obs.addObserver(this, "content-document-global-created", false);
|
||||
Services.obs.addObserver(this, "quit-application-granted", false);
|
||||
},
|
||||
|
||||
observe: function HWO_observe(aSubject, aTopic, aData)
|
||||
@ -6500,16 +6453,15 @@ HUDWindowObserver = {
|
||||
if (aTopic == "content-document-global-created") {
|
||||
HUDService.windowInitializer(aSubject);
|
||||
}
|
||||
else if (aTopic == "xpcom-shutdown") {
|
||||
this.uninit();
|
||||
else if (aTopic == "quit-application-granted") {
|
||||
HUDService.shutdown();
|
||||
}
|
||||
},
|
||||
|
||||
uninit: function HWO_uninit()
|
||||
{
|
||||
Services.obs.removeObserver(this, "content-document-global-created");
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
this.initialConsoleCreated = false;
|
||||
Services.obs.removeObserver(this, "quit-application-granted");
|
||||
},
|
||||
|
||||
};
|
||||
@ -6604,44 +6556,6 @@ CommandController.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// HUDConsoleObserver
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* HUDConsoleObserver: Observes nsIConsoleService for global consoleMessages,
|
||||
* if a message originates inside a contentWindow we are tracking,
|
||||
* then route that message to the HUDService for logging.
|
||||
*/
|
||||
|
||||
HUDConsoleObserver = {
|
||||
QueryInterface: XPCOMUtils.generateQI(
|
||||
[Ci.nsIObserver]
|
||||
),
|
||||
|
||||
init: function HCO_init()
|
||||
{
|
||||
Services.console.registerListener(this);
|
||||
Services.obs.addObserver(this, "quit-application-granted", false);
|
||||
},
|
||||
|
||||
uninit: function HCO_uninit()
|
||||
{
|
||||
Services.console.unregisterListener(this);
|
||||
Services.obs.removeObserver(this, "quit-application-granted");
|
||||
},
|
||||
|
||||
observe: function HCO_observe(aSubject, aTopic, aData)
|
||||
{
|
||||
if (aTopic == "quit-application-granted") {
|
||||
this.uninit();
|
||||
}
|
||||
else if (aSubject instanceof Ci.nsIScriptError) {
|
||||
HUDService.reportPageError(aSubject);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A WebProgressListener that listens for location changes, to update HUDService
|
||||
* state information on page navigation.
|
||||
|
@ -56,7 +56,7 @@ function testOpenUI(aTestReopen)
|
||||
// test to see if the messages are
|
||||
// displayed when the console UI is opened
|
||||
|
||||
openConsole(function(hud) {
|
||||
openConsole(null, function(hud) {
|
||||
testLogEntry(hud.outputNode, "log Bazzle",
|
||||
"Find a console log entry from before console UI is opened",
|
||||
false, null);
|
||||
|
@ -51,33 +51,26 @@ function test() {
|
||||
// see bug 580030: the error handler fails silently after page reload.
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=580030
|
||||
function onLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
browser.removeEventListener(aEvent.type, onLoad, true);
|
||||
|
||||
openConsole();
|
||||
|
||||
browser.addEventListener("load", testErrorsAfterPageReload, true);
|
||||
executeSoon(function() {
|
||||
openConsole(null, function(hud) {
|
||||
hud.jsterm.clearOutput();
|
||||
browser.addEventListener("load", testErrorsAfterPageReload, true);
|
||||
content.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function testErrorsAfterPageReload(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
browser.removeEventListener(aEvent.type, testErrorsAfterPageReload, true);
|
||||
|
||||
// dispatch a click event to the button in the test page and listen for
|
||||
// errors.
|
||||
|
||||
Services.console.registerListener(consoleObserver);
|
||||
|
||||
var button = content.document.querySelector("button").wrappedJSObject;
|
||||
var clickEvent = content.document.createEvent("MouseEvents");
|
||||
clickEvent.initMouseEvent("click", true, true,
|
||||
content, 0, 0, 0, 0, 0, false, false,
|
||||
false, false, 0, null);
|
||||
|
||||
executeSoon(function() {
|
||||
button.dispatchEvent(clickEvent);
|
||||
});
|
||||
let button = content.document.querySelector("button").wrappedJSObject;
|
||||
ok(button, "button found");
|
||||
EventUtils.sendMouseEvent({type: "click"}, button, content);
|
||||
}
|
||||
|
||||
var consoleObserver = {
|
||||
@ -95,10 +88,14 @@ var consoleObserver = {
|
||||
|
||||
let outputNode = HUDService.getHudByWindow(content).outputNode;
|
||||
|
||||
executeSoon(function() {
|
||||
let msg = "Found the error message after page reload";
|
||||
testLogEntry(outputNode, "fooBazBaz", msg);
|
||||
finishTest();
|
||||
waitForSuccess({
|
||||
name: "error message after page reload",
|
||||
validatorFn: function()
|
||||
{
|
||||
return outputNode.textContent.indexOf("fooBazBaz") > -1;
|
||||
},
|
||||
successFn: finishTest,
|
||||
failureFn: finishTest,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -52,7 +52,7 @@ function test() {
|
||||
function testDuplicateErrors() {
|
||||
browser.removeEventListener("DOMContentLoaded", testDuplicateErrors,
|
||||
false);
|
||||
openConsole(function(hud) {
|
||||
openConsole(null, function(hud) {
|
||||
hud.jsterm.clearOutput();
|
||||
|
||||
Services.console.registerListener(consoleObserver);
|
||||
@ -77,18 +77,27 @@ var consoleObserver = {
|
||||
|
||||
outputNode = HUDService.getHudByWindow(content).outputNode;
|
||||
|
||||
executeSoon(function () {
|
||||
var text = outputNode.textContent;
|
||||
var error1pos = text.indexOf("fooDuplicateError1");
|
||||
ok(error1pos > -1, "found fooDuplicateError1");
|
||||
if (error1pos > -1) {
|
||||
ok(text.indexOf("fooDuplicateError1", error1pos + 1) == -1,
|
||||
"no duplicate for fooDuplicateError1");
|
||||
}
|
||||
waitForSuccess({
|
||||
name: "fooDuplicateError1 error displayed",
|
||||
validatorFn: function()
|
||||
{
|
||||
return outputNode.textContent.indexOf("fooDuplicateError1") > -1;
|
||||
},
|
||||
successFn: function()
|
||||
{
|
||||
let text = outputNode.textContent;
|
||||
let error1pos = text.indexOf("fooDuplicateError1");
|
||||
ok(error1pos > -1, "found fooDuplicateError1");
|
||||
if (error1pos > -1) {
|
||||
ok(text.indexOf("fooDuplicateError1", error1pos + 1) == -1,
|
||||
"no duplicate for fooDuplicateError1");
|
||||
}
|
||||
|
||||
findLogEntry("test-duplicate-error.html");
|
||||
findLogEntry("test-duplicate-error.html");
|
||||
|
||||
finishTest();
|
||||
finishTest();
|
||||
},
|
||||
failureFn: finishTest,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(function(aHud) {
|
||||
openConsole(null, function(aHud) {
|
||||
hud = aHud;
|
||||
testDriver = testGen();
|
||||
testNext();
|
||||
|
@ -46,7 +46,7 @@ function test() {
|
||||
function tabLoaded() {
|
||||
browser.removeEventListener("load", tabLoaded, true);
|
||||
|
||||
openConsole(function() {
|
||||
openConsole(null, function() {
|
||||
browser.addEventListener("load", tabReloaded, true);
|
||||
content.location.reload();
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(consoleOpened);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(testTextNodeInsertion);
|
||||
openConsole(null, testTextNodeInsertion);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -50,45 +50,27 @@ function test() {
|
||||
browser.addEventListener("load", tab1Loaded, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a log entry exists in the HUD output node.
|
||||
*
|
||||
* @param {Element} aOutputNode the HUD output node.
|
||||
* @param {string} aMatchString the string you want to check if it exists in the
|
||||
* output node.
|
||||
* @param {boolean} [aOnlyVisible=false] find only messages that are visible,
|
||||
* not hidden by the filter.
|
||||
* @param {boolean} [aFailIfFound=false] fail the test if the string is found in
|
||||
* the output node.
|
||||
*/
|
||||
|
||||
function tab1Loaded(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
browser.contentWindow.wrappedJSObject.console.log("FOO");
|
||||
try {
|
||||
openConsole();
|
||||
}
|
||||
catch (ex) {
|
||||
log(ex);
|
||||
log(ex.stack);
|
||||
}
|
||||
|
||||
tab2 = gBrowser.addTab(TEST_DUMMY_URI);
|
||||
gBrowser.selectedTab = tab2;
|
||||
gBrowser.selectedBrowser.addEventListener("load", tab2Loaded, true);
|
||||
browser.removeEventListener(aEvent.type, tab1Loaded, true);
|
||||
content.console.log("FOO");
|
||||
openConsole(null, function() {
|
||||
tab2 = gBrowser.addTab(TEST_DUMMY_URI);
|
||||
gBrowser.selectedTab = tab2;
|
||||
gBrowser.selectedBrowser.addEventListener("load", tab2Loaded, true);
|
||||
});
|
||||
}
|
||||
|
||||
function tab2Loaded(aEvent) {
|
||||
tab2.linkedBrowser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
tab2.linkedBrowser.removeEventListener(aEvent.type, tab2Loaded, true);
|
||||
|
||||
HUDService.activateHUDForContext(gBrowser.selectedTab);
|
||||
|
||||
tab1.linkedBrowser.addEventListener("load", tab1Reloaded, true);
|
||||
tab1.linkedBrowser.contentWindow.location.reload();
|
||||
openConsole(gBrowser.selectedTab, function() {
|
||||
tab1.linkedBrowser.addEventListener("load", tab1Reloaded, true);
|
||||
tab1.linkedBrowser.contentWindow.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function tab1Reloaded(aEvent) {
|
||||
tab1.linkedBrowser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
tab1.linkedBrowser.removeEventListener(aEvent.type, tab1Reloaded, true);
|
||||
|
||||
let hud1 = HUDService.getHudByWindow(tab1.linkedBrowser.contentWindow);
|
||||
let outputNode1 = hud1.outputNode;
|
||||
@ -105,8 +87,9 @@ function tab1Reloaded(aEvent) {
|
||||
msg = "Didn't find the iframe network request in tab2";
|
||||
testLogEntry(outputNode2, TEST_IFRAME_URI, msg, true, true);
|
||||
|
||||
HUDService.deactivateHUDForContext(tab2);
|
||||
gBrowser.removeTab(tab2);
|
||||
|
||||
finishTest();
|
||||
closeConsole(tab2, function() {
|
||||
gBrowser.removeTab(tab2);
|
||||
tab1 = tab2 = null;
|
||||
executeSoon(finishTest);
|
||||
});
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ function test() {
|
||||
}
|
||||
|
||||
function onWindowLoad(aEvent) {
|
||||
win2.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
win2.removeEventListener(aEvent.type, onWindowLoad, true);
|
||||
|
||||
// Add two tabs in the new window.
|
||||
addTabs(win2);
|
||||
@ -39,48 +39,71 @@ function addTabs(aWindow) {
|
||||
let tab = aWindow.gBrowser.addTab(TEST_URI);
|
||||
openTabs.push(tab);
|
||||
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
tab.linkedBrowser.removeEventListener(aEvent.type, arguments.callee,
|
||||
true);
|
||||
tab.linkedBrowser.addEventListener("load", function onLoad(aEvent) {
|
||||
tab.linkedBrowser.removeEventListener(aEvent.type, onLoad, true);
|
||||
|
||||
loadedTabCount++;
|
||||
if (loadedTabCount >= 4) {
|
||||
executeSoon(performTest);
|
||||
executeSoon(openConsoles);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
function performTest() {
|
||||
function openConsoles() {
|
||||
// open the Web Console for each of the four tabs and log a message.
|
||||
let consolesOpen = 0;
|
||||
for (let i = 0; i < openTabs.length; i++) {
|
||||
let tab = openTabs[i];
|
||||
HUDService.activateHUDForContext(tab);
|
||||
let hudId = HUDService.getHudIdByWindow(tab.linkedBrowser.contentWindow);
|
||||
ok(hudId, "HUD is open for tab " + i);
|
||||
let HUD = HUDService.hudReferences[hudId];
|
||||
HUD.console.log("message for tab " + i);
|
||||
openConsole(tab, function(index, hud) {
|
||||
ok(hud, "HUD is open for tab " + index);
|
||||
hud.console.log("message for tab " + index);
|
||||
consolesOpen++;
|
||||
}.bind(null, i));
|
||||
}
|
||||
|
||||
let displays = Object.keys(HUDService.hudReferences);
|
||||
is(displays.length, 4, "four displays found");
|
||||
|
||||
win2.close();
|
||||
|
||||
executeSoon(function() {
|
||||
win1.gBrowser.removeTab(openTabs[0]);
|
||||
win1.gBrowser.removeTab(openTabs[1]);
|
||||
|
||||
executeSoon(function() {
|
||||
displays = Object.keys(HUDService.hudReferences);
|
||||
is(displays.length, 0, "no displays found");
|
||||
ok(!HUDService.storage, "no storage found");
|
||||
ok(!HUDService.httpObserver, "no httpObserver found");
|
||||
|
||||
displays = openTabs = win1 = win2 = null;
|
||||
|
||||
finishTest();
|
||||
});
|
||||
waitForSuccess({
|
||||
name: "4 web consoles opened",
|
||||
validatorFn: function()
|
||||
{
|
||||
return consolesOpen == 4;
|
||||
},
|
||||
successFn: closeConsoles,
|
||||
failureFn: closeConsoles,
|
||||
});
|
||||
}
|
||||
|
||||
function closeConsoles() {
|
||||
let consolesClosed = 0;
|
||||
|
||||
function onWebConsoleClose(aSubject, aTopic) {
|
||||
if (aTopic == "web-console-destroyed") {
|
||||
consolesClosed++;
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.addObserver(onWebConsoleClose, "web-console-destroyed", false);
|
||||
|
||||
win2.close();
|
||||
|
||||
win1.gBrowser.removeTab(openTabs[0]);
|
||||
win1.gBrowser.removeTab(openTabs[1]);
|
||||
|
||||
openTabs = win1 = win2 = null;
|
||||
|
||||
function onTimeout() {
|
||||
Services.obs.removeObserver(onWebConsoleClose, "web-console-destroyed");
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
|
||||
waitForSuccess({
|
||||
name: "4 web consoles closed",
|
||||
validatorFn: function()
|
||||
{
|
||||
return consolesClosed == 4;
|
||||
},
|
||||
successFn: onTimeout,
|
||||
failureFn: onTimeout,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -89,12 +89,12 @@ const TESTS = [
|
||||
category: "Image",
|
||||
matchString: "corrupt",
|
||||
},
|
||||
/* Disabled until bug 675221 lands.
|
||||
{ // #7
|
||||
{ // #15
|
||||
file: "test-bug-595934-workers.html",
|
||||
category: "Web Worker",
|
||||
matchString: "fooBarWorker",
|
||||
},*/
|
||||
expectError: true,
|
||||
},
|
||||
];
|
||||
|
||||
let pos = -1;
|
||||
@ -103,13 +103,14 @@ let foundCategory = false;
|
||||
let foundText = false;
|
||||
let output = null;
|
||||
let jsterm = null;
|
||||
let testEnded = false;
|
||||
|
||||
let TestObserver = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||
|
||||
observe: function test_observe(aSubject)
|
||||
{
|
||||
if (!(aSubject instanceof Ci.nsIScriptError)) {
|
||||
if (testEnded || !(aSubject instanceof Ci.nsIScriptError)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -125,24 +126,21 @@ let TestObserver = {
|
||||
else {
|
||||
ok(false, aSubject.sourceName + ':' + aSubject.lineNumber + '; ' +
|
||||
aSubject.errorMessage);
|
||||
executeSoon(finish);
|
||||
testEnded = true;
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
openConsole();
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let hud = HUDService.hudReferences[hudId];
|
||||
function consoleOpened(hud) {
|
||||
output = hud.outputNode;
|
||||
output.addEventListener("DOMNodeInserted", onDOMNodeInserted, false);
|
||||
jsterm = hud.jsterm;
|
||||
|
||||
Services.console.registerListener(TestObserver);
|
||||
|
||||
registerCleanupFunction(testEnd);
|
||||
|
||||
executeSoon(testNext);
|
||||
}
|
||||
|
||||
@ -156,26 +154,30 @@ function testNext() {
|
||||
let test = TESTS[pos];
|
||||
let testLocation = TESTS_PATH + test.file;
|
||||
if (test.onload) {
|
||||
browser.addEventListener("load", function(aEvent) {
|
||||
browser.addEventListener("load", function onLoad(aEvent) {
|
||||
if (content.location.href == testLocation) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
browser.removeEventListener(aEvent.type, onLoad, true);
|
||||
test.onload(aEvent);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
if (test.expectError) {
|
||||
expectUncaughtException();
|
||||
}
|
||||
|
||||
content.location = testLocation;
|
||||
}
|
||||
else {
|
||||
executeSoon(finish);
|
||||
testEnded = true;
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
}
|
||||
|
||||
function testEnd() {
|
||||
Services.console.unregisterListener(TestObserver);
|
||||
output.removeEventListener("DOMNodeInserted", onDOMNodeInserted, false);
|
||||
output = jsterm = null;
|
||||
finishTest();
|
||||
TestObserver = output = jsterm = null;
|
||||
}
|
||||
|
||||
function onDOMNodeInserted(aEvent) {
|
||||
@ -191,9 +193,10 @@ function onDOMNodeInserted(aEvent) {
|
||||
}
|
||||
|
||||
function test() {
|
||||
registerCleanupFunction(testEnd);
|
||||
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 595934 - message categories coverage.");
|
||||
browser.addEventListener("load", tabLoad, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -21,25 +21,19 @@ function tabLoaded(aEvent) {
|
||||
browser.removeEventListener("load", tabLoaded, true);
|
||||
openConsole();
|
||||
|
||||
browser.addEventListener("load", contentLoaded, true);
|
||||
content.location.reload();
|
||||
}
|
||||
|
||||
function contentLoaded(aEvent) {
|
||||
browser.removeEventListener("load", contentLoaded, true);
|
||||
|
||||
let button = content.document.querySelector("button");
|
||||
expectUncaughtException();
|
||||
EventUtils.sendMouseEvent({ type: "click" }, button, content);
|
||||
executeSoon(buttonClicked);
|
||||
}
|
||||
|
||||
function buttonClicked() {
|
||||
let outputNode = HUDService.getHudByWindow(content).outputNode;
|
||||
|
||||
let msg = "the error from the external script was logged";
|
||||
testLogEntry(outputNode, "bogus", msg);
|
||||
expectUncaughtException();
|
||||
EventUtils.sendMouseEvent({ type: "click" }, button, content);
|
||||
|
||||
finishTest();
|
||||
waitForSuccess({
|
||||
name: "external script error message",
|
||||
validatorFn: function()
|
||||
{
|
||||
return outputNode.textContent.indexOf("bogus is not defined") > -1;
|
||||
},
|
||||
successFn: finishTest,
|
||||
failureFn: finishTest,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -13,17 +13,17 @@ const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/te
|
||||
let newTabIsOpen = false;
|
||||
|
||||
function tabLoaded(aEvent) {
|
||||
gBrowser.selectedBrowser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
gBrowser.selectedBrowser.removeEventListener(aEvent.type, tabLoaded, true);
|
||||
|
||||
HUDService.activateHUDForContext(gBrowser.selectedTab);
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", tabReloaded, true);
|
||||
expectUncaughtException();
|
||||
content.location.reload();
|
||||
openConsole(gBrowser.selectedTab, function() {
|
||||
gBrowser.selectedBrowser.addEventListener("load", tabReloaded, true);
|
||||
expectUncaughtException();
|
||||
content.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function tabReloaded(aEvent) {
|
||||
gBrowser.selectedBrowser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
gBrowser.selectedBrowser.removeEventListener(aEvent.type, tabReloaded, true);
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let HUD = HUDService.hudReferences[hudId];
|
||||
@ -34,26 +34,24 @@ function tabReloaded(aEvent) {
|
||||
|
||||
executeSoon(function() {
|
||||
if (newTabIsOpen) {
|
||||
testEnd();
|
||||
executeSoon(finishTest);
|
||||
return;
|
||||
}
|
||||
|
||||
let newTab = gBrowser.addTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
gBrowser.selectedTab = newTab;
|
||||
closeConsole(gBrowser.selectedTab, function() {
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
newTabIsOpen = true;
|
||||
gBrowser.selectedBrowser.addEventListener("load", tabLoaded, true);
|
||||
expectUncaughtException();
|
||||
content.location = TEST_URI;
|
||||
let newTab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = newTab;
|
||||
|
||||
newTabIsOpen = true;
|
||||
gBrowser.selectedBrowser.addEventListener("load", tabLoaded, true);
|
||||
expectUncaughtException();
|
||||
content.location = TEST_URI;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testEnd() {
|
||||
gBrowser.removeCurrentTab();
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
|
||||
function test() {
|
||||
expectUncaughtException();
|
||||
addTab(TEST_URI);
|
||||
|
@ -98,7 +98,7 @@ function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, tabLoad, true);
|
||||
|
||||
waitForFocus(function () {
|
||||
openConsole(function(aHud) {
|
||||
openConsole(null, function(aHud) {
|
||||
HUD = aHud;
|
||||
testNext();
|
||||
});
|
||||
|
@ -66,7 +66,7 @@ function test() {
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 601352");
|
||||
browser.addEventListener("load", function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, tabLoad, true);
|
||||
openConsole(consoleOpened);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -16,21 +16,20 @@ function test()
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 602572: log bodies checkbox. tab 1");
|
||||
tabs.push(tab);
|
||||
|
||||
browser.addEventListener("load", function(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
browser.addEventListener("load", function onLoad1(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, onLoad1, true);
|
||||
|
||||
openConsole();
|
||||
openConsole(null, function() {
|
||||
// open tab 2
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 602572: log bodies checkbox. tab 2");
|
||||
tabs.push(tab);
|
||||
|
||||
// open tab 2
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 602572: log bodies checkbox. tab 2");
|
||||
tabs.push(tab);
|
||||
browser.addEventListener("load", function onLoad2(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, onLoad2, true);
|
||||
|
||||
browser.addEventListener("load", function(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
openConsole();
|
||||
executeSoon(startTest);
|
||||
}, true);
|
||||
openConsole(null, startTest);
|
||||
}, true);
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
|
||||
@ -52,7 +51,7 @@ function startTest()
|
||||
|
||||
function onpopupshown2(aEvent)
|
||||
{
|
||||
menupopups[1].removeEventListener(aEvent.type, arguments.callee, false);
|
||||
menupopups[1].removeEventListener(aEvent.type, onpopupshown2, false);
|
||||
|
||||
// By default bodies are not logged.
|
||||
isnot(menuitems[1].getAttribute("checked"), "true",
|
||||
@ -63,8 +62,8 @@ function onpopupshown2(aEvent)
|
||||
// Enable body logging.
|
||||
HUDService.saveRequestAndResponseBodies = true;
|
||||
|
||||
menupopups[1].addEventListener("popuphidden", function(aEvent) {
|
||||
menupopups[1].removeEventListener(aEvent.type, arguments.callee, false);
|
||||
menupopups[1].addEventListener("popuphidden", function _onhidden(aEvent) {
|
||||
menupopups[1].removeEventListener(aEvent.type, _onhidden, false);
|
||||
|
||||
// Reopen the context menu.
|
||||
menupopups[1].addEventListener("popupshown", onpopupshown2b, false);
|
||||
@ -75,11 +74,11 @@ function onpopupshown2(aEvent)
|
||||
|
||||
function onpopupshown2b(aEvent)
|
||||
{
|
||||
menupopups[1].removeEventListener(aEvent.type, arguments.callee, false);
|
||||
menupopups[1].removeEventListener(aEvent.type, onpopupshown2b, false);
|
||||
is(menuitems[1].getAttribute("checked"), "true", "menuitems[1] is checked");
|
||||
|
||||
menupopups[1].addEventListener("popuphidden", function(aEvent) {
|
||||
menupopups[1].removeEventListener(aEvent.type, arguments.callee, false);
|
||||
menupopups[1].addEventListener("popuphidden", function _onhidden(aEvent) {
|
||||
menupopups[1].removeEventListener(aEvent.type, _onhidden, false);
|
||||
|
||||
// Switch to tab 1 and open the Web Console context menu from there.
|
||||
gBrowser.selectedTab = tabs[0];
|
||||
@ -102,7 +101,7 @@ function onpopupshown2b(aEvent)
|
||||
|
||||
function onpopupshown1(aEvent)
|
||||
{
|
||||
menupopups[0].removeEventListener(aEvent.type, arguments.callee, false);
|
||||
menupopups[0].removeEventListener(aEvent.type, onpopupshown1, false);
|
||||
|
||||
// The menuitem checkbox must be in sync with the other tabs.
|
||||
is(menuitems[0].getAttribute("checked"), "true", "menuitems[0] is checked");
|
||||
@ -111,8 +110,8 @@ function onpopupshown1(aEvent)
|
||||
HUDService.saveRequestAndResponseBodies = false;
|
||||
|
||||
// Close the menu, and switch back to tab 2.
|
||||
menupopups[0].addEventListener("popuphidden", function(aEvent) {
|
||||
menupopups[0].removeEventListener(aEvent.type, arguments.callee, false);
|
||||
menupopups[0].addEventListener("popuphidden", function _onhidden(aEvent) {
|
||||
menupopups[0].removeEventListener(aEvent.type, _onhidden, false);
|
||||
|
||||
gBrowser.selectedTab = tabs[1];
|
||||
waitForFocus(function() {
|
||||
@ -126,19 +125,20 @@ function onpopupshown1(aEvent)
|
||||
|
||||
function onpopupshown2c(aEvent)
|
||||
{
|
||||
menupopups[1].removeEventListener(aEvent.type, arguments.callee, false);
|
||||
menupopups[1].removeEventListener(aEvent.type, onpopupshown2c, false);
|
||||
|
||||
isnot(menuitems[1].getAttribute("checked"), "true",
|
||||
"menuitems[1] is not checked");
|
||||
|
||||
menupopups[1].addEventListener("popuphidden", function(aEvent) {
|
||||
menupopups[1].removeEventListener(aEvent.type, arguments.callee, false);
|
||||
menupopups[1].addEventListener("popuphidden", function _onhidden(aEvent) {
|
||||
menupopups[1].removeEventListener(aEvent.type, _onhidden, false);
|
||||
|
||||
// Done!
|
||||
huds = menuitems = menupopups = tabs = null;
|
||||
HUDService.deactivateHUDForContext(gBrowser.selectedTab);
|
||||
gBrowser.removeCurrentTab();
|
||||
executeSoon(finishTest);
|
||||
closeConsole(gBrowser.selectedTab, function() {
|
||||
gBrowser.removeCurrentTab();
|
||||
executeSoon(finishTest);
|
||||
});
|
||||
}, false);
|
||||
menupopups[1].hidePopup();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ let TestObserver = {
|
||||
};
|
||||
|
||||
function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
browser.removeEventListener(aEvent.type, tabLoad, true);
|
||||
|
||||
openConsole();
|
||||
|
||||
@ -52,15 +52,20 @@ function tabLoad(aEvent) {
|
||||
}
|
||||
|
||||
function performTest() {
|
||||
let textContent = hud.outputNode.textContent;
|
||||
isnot(textContent.indexOf("ws://0.0.0.0:81"), -1,
|
||||
"first error message found");
|
||||
isnot(textContent.indexOf("ws://0.0.0.0:82"), -1,
|
||||
"second error message found");
|
||||
|
||||
Services.console.unregisterListener(TestObserver);
|
||||
Services.prefs.setBoolPref(pref_ws, oldPref_ws);
|
||||
finishTest();
|
||||
|
||||
waitForSuccess({
|
||||
name: "websocket error messages displayed",
|
||||
validatorFn: function()
|
||||
{
|
||||
let textContent = hud.outputNode.textContent;
|
||||
return textContent.indexOf("ws://0.0.0.0:81") > -1 &&
|
||||
textContent.indexOf("ws://0.0.0.0:82") > -1;
|
||||
},
|
||||
successFn: finishTest,
|
||||
failureFn: finishTest,
|
||||
});
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
@ -7,17 +7,39 @@ const TEST_URI = 'data:text/html;charset=utf-8,<div style="-moz-opacity:0;">test
|
||||
|
||||
function onContentLoaded()
|
||||
{
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
browser.removeEventListener("load", onContentLoaded, true);
|
||||
|
||||
let HUD = HUDService.getHudByWindow(content);
|
||||
let jsterm = HUD.jsterm;
|
||||
let outputNode = HUD.outputNode;
|
||||
|
||||
let msg = "The unknown CSS property warning is displayed only once";
|
||||
let node = outputNode.firstChild;
|
||||
let cssWarning = "Unknown property '-moz-opacity'. Declaration dropped.";
|
||||
|
||||
is(node.childNodes[2].textContent, "Unknown property '-moz-opacity'. Declaration dropped.", "correct node")
|
||||
is(node.childNodes[3].firstChild.getAttribute("value"), 2, msg);
|
||||
waitForSuccess({
|
||||
name: "2 repeated CSS warnings",
|
||||
validatorFn: function()
|
||||
{
|
||||
return outputNode.textContent.indexOf(cssWarning) > -1;
|
||||
},
|
||||
successFn: function()
|
||||
{
|
||||
let msg = "The unknown CSS property warning is displayed only once";
|
||||
let node = outputNode.firstChild;
|
||||
|
||||
is(node.childNodes[2].textContent, cssWarning, "correct node");
|
||||
is(node.childNodes[3].firstChild.getAttribute("value"), 2, msg);
|
||||
|
||||
testConsoleLogRepeats();
|
||||
},
|
||||
failureFn: finishTest,
|
||||
});
|
||||
}
|
||||
|
||||
function testConsoleLogRepeats()
|
||||
{
|
||||
let HUD = HUDService.getHudByWindow(content);
|
||||
let jsterm = HUD.jsterm;
|
||||
let outputNode = HUD.outputNode;
|
||||
|
||||
jsterm.clearOutput();
|
||||
|
||||
@ -45,7 +67,7 @@ function test()
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(function(aHud) {
|
||||
openConsole(null, function(aHud) {
|
||||
// Clear cached messages that are shown once the Web Console opens.
|
||||
aHud.jsterm.clearOutput(true);
|
||||
browser.addEventListener("load", onContentLoaded, true);
|
||||
|
@ -95,7 +95,7 @@ function test() {
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 613642: remember scroll location");
|
||||
browser.addEventListener("load", function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, tabLoad, true);
|
||||
openConsole(function(aHud) {
|
||||
openConsole(null, function(aHud) {
|
||||
hud = aHud;
|
||||
testDriver = testGen();
|
||||
testDriver.next();
|
||||
|
@ -92,7 +92,7 @@ function test() {
|
||||
browser.addEventListener("load", function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, tabLoad, true);
|
||||
|
||||
openConsole(function(aHud) {
|
||||
openConsole(null, function(aHud) {
|
||||
hud = aHud;
|
||||
testDriver = testGen();
|
||||
testDriver.next();
|
||||
|
@ -47,7 +47,7 @@ function test() {
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 614793: jsterm result scroll");
|
||||
browser.addEventListener("load", function onLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, onLoad, true);
|
||||
openConsole(consoleOpened);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -53,57 +53,50 @@ let TestObserver = {
|
||||
|
||||
is(aSubject.category, "content javascript", "error category");
|
||||
|
||||
testEnded = true;
|
||||
if (aSubject.category == "content javascript") {
|
||||
executeSoon(checkOutput);
|
||||
}
|
||||
else {
|
||||
testEnd();
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function checkOutput()
|
||||
{
|
||||
if (testEnded) {
|
||||
return;
|
||||
}
|
||||
|
||||
let textContent = hud.outputNode.textContent;
|
||||
isnot(textContent.indexOf("bug618078exception"), -1,
|
||||
"exception message");
|
||||
|
||||
testEnd();
|
||||
waitForSuccess({
|
||||
name: "exception message",
|
||||
validatorFn: function()
|
||||
{
|
||||
return hud.outputNode.textContent.indexOf("bug618078exception") > -1;
|
||||
},
|
||||
successFn: finishTest,
|
||||
failureFn: finishTest,
|
||||
});
|
||||
}
|
||||
|
||||
function testEnd()
|
||||
{
|
||||
if (testEnded) {
|
||||
return;
|
||||
}
|
||||
|
||||
testEnded = true;
|
||||
Services.console.unregisterListener(TestObserver);
|
||||
finishTest();
|
||||
}
|
||||
|
||||
function test()
|
||||
{
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 618078");
|
||||
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
|
||||
openConsole();
|
||||
openConsole(null, function(aHud) {
|
||||
hud = aHud;
|
||||
Services.console.registerListener(TestObserver);
|
||||
registerCleanupFunction(testEnd);
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
hud = HUDService.hudReferences[hudId];
|
||||
|
||||
Services.console.registerListener(TestObserver);
|
||||
registerCleanupFunction(testEnd);
|
||||
|
||||
executeSoon(function() {
|
||||
expectUncaughtException();
|
||||
content.location = TEST_URI;
|
||||
executeSoon(function() {
|
||||
expectUncaughtException();
|
||||
content.location = TEST_URI;
|
||||
});
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
function test() {
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 618311 (private browsing)");
|
||||
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
@ -57,9 +57,10 @@ function test() {
|
||||
togglePBAndThen(function() {
|
||||
ok(pb.privateBrowsingEnabled, "private browsing is enabled");
|
||||
|
||||
HUDService.activateHUDForContext(gBrowser.selectedTab);
|
||||
content.location = TEST_URI;
|
||||
gBrowser.selectedBrowser.addEventListener("load", tabLoaded, true);
|
||||
openConsole(gBrowser.selectedTab, function() {
|
||||
content.location = TEST_URI;
|
||||
gBrowser.selectedBrowser.addEventListener("load", tabLoaded, true);
|
||||
});
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
@ -128,6 +129,7 @@ function tabLoaded() {
|
||||
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is not enabled");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
executeSoon(finishTest);
|
||||
});
|
||||
}
|
||||
|
@ -10,14 +10,9 @@
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-bug-621644-jsterm-dollar.html";
|
||||
|
||||
function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
waitForFocus(function () {
|
||||
openConsole();
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let HUD = HUDService.hudReferences[hudId];
|
||||
browser.removeEventListener(aEvent.type, tabLoad, true);
|
||||
|
||||
openConsole(null, function(HUD) {
|
||||
HUD.jsterm.clearOutput();
|
||||
|
||||
HUD.jsterm.setInputValue("$(document.body)");
|
||||
@ -39,7 +34,7 @@ function tabLoad(aEvent) {
|
||||
"jsterm output is correct for $$()");
|
||||
|
||||
executeSoon(finishTest);
|
||||
}, content);
|
||||
});
|
||||
}
|
||||
|
||||
function test() {
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
let itemsSet, HUD;
|
||||
let itemsSet, HUD, outputNode;
|
||||
|
||||
function test() {
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 626484");
|
||||
browser.addEventListener("load", function tabLoaded(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, tabLoaded, true);
|
||||
openConsole(consoleOpened);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ function consoleOpened(aHud) {
|
||||
return outputNode.querySelectorAll(".hud-log").length == 3;
|
||||
},
|
||||
successFn: nextTest,
|
||||
failureFn: finish,
|
||||
failureFn: finishTest,
|
||||
});
|
||||
}
|
||||
|
||||
@ -38,8 +38,8 @@ function nextTest() {
|
||||
if (itemsSet.length === 0) {
|
||||
outputNode.clearSelection();
|
||||
HUD.jsterm.clearOutput();
|
||||
HUD = null;
|
||||
finish();
|
||||
HUD = outputNode = null;
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
else {
|
||||
outputNode.clearSelection();
|
||||
|
@ -10,7 +10,7 @@
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/" +
|
||||
"webconsole/test/test-bug-644419-log-limits.html";
|
||||
|
||||
var gOldPref, gHudId;
|
||||
var gOldPref;
|
||||
|
||||
function test() {
|
||||
addTab("data:text/html;charset=utf-8,Web Console test for bug 644419: Console should " +
|
||||
@ -19,11 +19,12 @@ function test() {
|
||||
}
|
||||
|
||||
function onLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
browser.removeEventListener(aEvent.type, onLoad, true);
|
||||
|
||||
openConsole(function(aHud) {
|
||||
gHudId = aHud.hudId;
|
||||
openConsole(null, function(aHud) {
|
||||
aHud.jsterm.clearOutput();
|
||||
hud = aHud;
|
||||
outputNode = aHud.outputNode;
|
||||
|
||||
browser.addEventListener("load", testWebDevLimits, true);
|
||||
expectUncaughtException();
|
||||
@ -36,12 +37,19 @@ function testWebDevLimits(aEvent) {
|
||||
gOldPref = Services.prefs.getIntPref("devtools.hud.loglimit.console");
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.console", 10);
|
||||
|
||||
let hud = HUDService.hudReferences[gHudId];
|
||||
outputNode = hud.outputNode;
|
||||
|
||||
// Find the sentinel entry.
|
||||
findLogEntry("bar is not defined");
|
||||
waitForSuccess({
|
||||
name: "bar is not defined",
|
||||
validatorFn: function()
|
||||
{
|
||||
return outputNode.textContent.indexOf("bar is not defined") > -1;
|
||||
},
|
||||
successFn: testWebDevLimits2,
|
||||
failureFn: testWebDevLimits2,
|
||||
});
|
||||
}
|
||||
|
||||
function testWebDevLimits2() {
|
||||
// Fill the log with Web Developer errors.
|
||||
for (let i = 0; i < 11; i++) {
|
||||
hud.console.log("test message " + i);
|
||||
@ -71,9 +79,7 @@ function testJsLimits() {
|
||||
gOldPref = Services.prefs.getIntPref("devtools.hud.loglimit.exception");
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.exception", 10);
|
||||
|
||||
let hud = HUDService.hudReferences[gHudId];
|
||||
hud.jsterm.clearOutput();
|
||||
outputNode = hud.outputNode;
|
||||
hud.console.log("testing JS limits");
|
||||
|
||||
// Find the sentinel entry.
|
||||
@ -98,14 +104,23 @@ function testJsLimits2() {
|
||||
head.insertBefore(script, head.firstChild);
|
||||
}
|
||||
|
||||
executeSoon(function() {
|
||||
testLogEntry(outputNode, "fubar0 is not defined", "first message is pruned", false, true);
|
||||
findLogEntry("fubar1 is not defined");
|
||||
// Check if the sentinel entry is still there.
|
||||
findLogEntry("testing JS limits");
|
||||
waitForSuccess({
|
||||
name: "10 JS errors shown",
|
||||
validatorFn: function()
|
||||
{
|
||||
return outputNode.textContent.indexOf("fubar10 is not defined") > -1;
|
||||
},
|
||||
successFn: function()
|
||||
{
|
||||
testLogEntry(outputNode, "fubar0 is not defined", "first message is pruned", false, true);
|
||||
findLogEntry("fubar1 is not defined");
|
||||
// Check if the sentinel entry is still there.
|
||||
findLogEntry("testing JS limits");
|
||||
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.exception", gOldPref);
|
||||
testNetLimits();
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.exception", gOldPref);
|
||||
testNetLimits();
|
||||
},
|
||||
failureFn: testNetLimits,
|
||||
});
|
||||
}
|
||||
|
||||
@ -115,9 +130,7 @@ function testNetLimits() {
|
||||
gOldPref = Services.prefs.getIntPref("devtools.hud.loglimit.network");
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.network", 10);
|
||||
|
||||
let hud = HUDService.hudReferences[gHudId];
|
||||
hud.jsterm.clearOutput();
|
||||
outputNode = hud.outputNode;
|
||||
hud.console.log("testing Net limits");
|
||||
|
||||
// Find the sentinel entry.
|
||||
@ -162,9 +175,7 @@ function testCssLimits() {
|
||||
gOldPref = Services.prefs.getIntPref("devtools.hud.loglimit.cssparser");
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", 10);
|
||||
|
||||
let hud = HUDService.hudReferences[gHudId];
|
||||
hud.jsterm.clearOutput();
|
||||
outputNode = hud.outputNode;
|
||||
hud.console.log("testing CSS limits");
|
||||
|
||||
// Find the sentinel entry.
|
||||
@ -187,13 +198,24 @@ function testCssLimits2() {
|
||||
div.setAttribute("style", "-moz-foobar" + i + ": 42;");
|
||||
body.insertBefore(div, body.firstChild);
|
||||
}
|
||||
executeSoon(function() {
|
||||
testLogEntry(outputNode, "Unknown property '-moz-foobar0'", "first message is pruned", false, true);
|
||||
findLogEntry("Unknown property '-moz-foobar1'");
|
||||
// Check if the sentinel entry is still there.
|
||||
findLogEntry("testing CSS limits");
|
||||
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", gOldPref);
|
||||
finishTest();
|
||||
waitForSuccess({
|
||||
name: "10 CSS errors shown",
|
||||
validatorFn: function()
|
||||
{
|
||||
return outputNode.textContent.indexOf("-moz-foobar10") > -1;
|
||||
},
|
||||
successFn: function()
|
||||
{
|
||||
testLogEntry(outputNode, "Unknown property '-moz-foobar0'",
|
||||
"first message is pruned", false, true);
|
||||
findLogEntry("Unknown property '-moz-foobar1'");
|
||||
// Check if the sentinel entry is still there.
|
||||
findLogEntry("testing CSS limits");
|
||||
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", gOldPref);
|
||||
finishTest();
|
||||
},
|
||||
failureFn: finishTest,
|
||||
});
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ function runSelectionTests()
|
||||
});
|
||||
}
|
||||
|
||||
function performTestComparisons(evt)
|
||||
function performTestComparisons()
|
||||
{
|
||||
InspectorUI.highlighter.removeListener("nodeselected", performTestComparisons);
|
||||
|
||||
@ -105,9 +105,11 @@ function performTestComparisons(evt)
|
||||
is(InspectorUI.highlighter.node, h1, "node selected");
|
||||
is(InspectorUI.selection, h1, "selection matches node");
|
||||
|
||||
HUDService.activateHUDForContext(gBrowser.selectedTab);
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let hud = HUDService.hudReferences[hudId];
|
||||
openConsole(gBrowser.selectedTab, performWebConsoleTests);
|
||||
}
|
||||
|
||||
function performWebConsoleTests(hud)
|
||||
{
|
||||
let jsterm = hud.jsterm;
|
||||
outputNode = hud.outputNode;
|
||||
|
||||
@ -127,8 +129,7 @@ function performTestComparisons(evt)
|
||||
|
||||
function finishUp() {
|
||||
InspectorUI.closeInspectorUI();
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
finishTest();
|
||||
}
|
||||
|
||||
function test()
|
||||
|
@ -9,15 +9,13 @@
|
||||
function test() {
|
||||
addTab("http://example.com/browser/browser/devtools/webconsole/" +
|
||||
"test/test-bug-658368-time-methods.html");
|
||||
openConsole();
|
||||
browser.addEventListener("load", onLoad, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function onLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, onLoad, true);
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let hud = HUDService.hudReferences[hudId];
|
||||
function consoleOpened(hud) {
|
||||
outputNode = hud.outputNode;
|
||||
|
||||
executeSoon(function() {
|
||||
@ -28,16 +26,14 @@ function onLoad(aEvent) {
|
||||
// tabs, do not contain the same value.
|
||||
addTab("data:text/html;charset=utf-8,<script type='text/javascript'>" +
|
||||
"console.timeEnd('bTimer');</script>");
|
||||
openConsole();
|
||||
browser.addEventListener("load", testTimerIndependenceInTabs, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testTimerIndependenceInTabs);
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
function testTimerIndependenceInTabs(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, testTimerIndependenceInTabs, true);
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let hud = HUDService.hudReferences[hudId];
|
||||
function testTimerIndependenceInTabs(hud) {
|
||||
outputNode = hud.outputNode;
|
||||
|
||||
executeSoon(function() {
|
||||
@ -46,15 +42,16 @@ function testTimerIndependenceInTabs(aEvent) {
|
||||
|
||||
// The next test makes sure that timers with the same name but in separate
|
||||
// pages, do not contain the same value.
|
||||
browser.addEventListener("load", testTimerIndependenceInSameTab, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
executeSoon(testTimerIndependenceInSameTab);
|
||||
}, true);
|
||||
content.location = "data:text/html;charset=utf-8,<script type='text/javascript'>" +
|
||||
"console.time('bTimer');</script>";
|
||||
});
|
||||
}
|
||||
|
||||
function testTimerIndependenceInSameTab(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, testTimerIndependenceInSameTab, true);
|
||||
|
||||
function testTimerIndependenceInSameTab() {
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let hud = HUDService.hudReferences[hudId];
|
||||
outputNode = hud.outputNode;
|
||||
@ -65,15 +62,16 @@ function testTimerIndependenceInSameTab(aEvent) {
|
||||
|
||||
// Now the following console.timeEnd() call shouldn't display anything,
|
||||
// if the timers in different pages are not related.
|
||||
browser.addEventListener("load", testTimerIndependenceInSameTabAgain, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
executeSoon(testTimerIndependenceInSameTabAgain);
|
||||
}, true);
|
||||
content.location = "data:text/html;charset=utf-8,<script type='text/javascript'>" +
|
||||
"console.timeEnd('bTimer');</script>";
|
||||
});
|
||||
}
|
||||
|
||||
function testTimerIndependenceInSameTabAgain(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, testTimerIndependenceInSameTabAgain, true);
|
||||
|
||||
function testTimerIndependenceInSameTabAgain(hud) {
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let hud = HUDService.hudReferences[hudId];
|
||||
outputNode = hud.outputNode;
|
||||
@ -82,6 +80,9 @@ function testTimerIndependenceInSameTabAgain(aEvent) {
|
||||
testLogEntry(outputNode, "bTimer: timer started", "bTimer was not started",
|
||||
false, true);
|
||||
|
||||
finishTest();
|
||||
closeConsole(gBrowser.selectedTab, function() {
|
||||
gBrowser.removeCurrentTab();
|
||||
executeSoon(finishTest);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ function test() {
|
||||
"object with a dir method");
|
||||
browser.addEventListener("load", function onLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, onLoad, true);
|
||||
openConsole(consoleOpened);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ function test() {
|
||||
"object with group methods");
|
||||
browser.addEventListener("load", function onLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, onLoad, true);
|
||||
openConsole(function(aHud) {
|
||||
openConsole(null, function(aHud) {
|
||||
hud = aHud;
|
||||
testDriver = testGen();
|
||||
testNext();
|
||||
|
@ -42,15 +42,14 @@
|
||||
|
||||
function test() {
|
||||
addTab(getBrowserURL());
|
||||
browser.addEventListener("DOMContentLoaded", testChrome, false);
|
||||
browser.addEventListener("DOMContentLoaded", function onLoad() {
|
||||
browser.removeEventListener("DOMContentLoaded", onLoad, true);
|
||||
openConsole();
|
||||
testChrome(HUDService.getHudByWindow(content));
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testChrome() {
|
||||
browser.removeEventListener("DOMContentLoaded", testChrome, false);
|
||||
|
||||
openConsole();
|
||||
|
||||
let hud = HUDService.getHudByWindow(content);
|
||||
function testChrome(hud) {
|
||||
ok(hud, "we have a console");
|
||||
|
||||
ok(hud.HUDBox, "we have the console display");
|
||||
@ -67,6 +66,7 @@ function testChrome() {
|
||||
jsterm.complete(jsterm.COMPLETE_HINT_ONLY);
|
||||
is(jsterm.completeNode.value, " ment", "'docu' completion");
|
||||
|
||||
finish();
|
||||
gBrowser.removeCurrentTab();
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(consoleOpened);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ function test() {
|
||||
function onLoad() {
|
||||
browser.removeEventListener("DOMContentLoaded", onLoad, false);
|
||||
|
||||
openConsole(function(aHud) {
|
||||
openConsole(null, function(aHud) {
|
||||
hud = aHud;
|
||||
hudId = hud.hudId;
|
||||
outputNode = hud.outputNode;
|
||||
|
@ -20,7 +20,7 @@ function test()
|
||||
|
||||
function onLoad() {
|
||||
browser.removeEventListener("DOMContentLoaded", onLoad, false);
|
||||
openConsole(testNewlines);
|
||||
openConsole(null, testNewlines);
|
||||
}
|
||||
|
||||
function testNewlines(aHud) {
|
||||
|
@ -44,16 +44,14 @@ const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/te
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testExecutionScope, false);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testExecutionScope);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testExecutionScope() {
|
||||
browser.removeEventListener("DOMContentLoaded", testExecutionScope,
|
||||
false);
|
||||
|
||||
openConsole();
|
||||
|
||||
let jsterm = HUDService.getHudByWindow(content).jsterm;
|
||||
function testExecutionScope(hud) {
|
||||
let jsterm = hud.jsterm;
|
||||
|
||||
jsterm.clearOutput();
|
||||
jsterm.execute("location;");
|
||||
@ -67,9 +65,6 @@ function testExecutionScope() {
|
||||
ok(nodes[0].textContent.indexOf(TEST_URI),
|
||||
"command was executed in the window scope");
|
||||
|
||||
jsterm.clearOutput();
|
||||
jsterm.history.splice(0, jsterm.history.length); // workaround for bug 592552
|
||||
|
||||
finishTest();
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
|
||||
|
@ -48,15 +48,14 @@ const HISTORY_FORWARD = 1;
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testHistory, false);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testHistory);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testHistory() {
|
||||
browser.removeEventListener("DOMContentLoaded", testHistory, false);
|
||||
|
||||
openConsole();
|
||||
|
||||
let jsterm = HUDService.getHudByWindow(content).jsterm;
|
||||
function testHistory(hud) {
|
||||
let jsterm = hud.jsterm;
|
||||
let input = jsterm.inputNode;
|
||||
|
||||
let executeList = ["document", "window", "window.location"];
|
||||
@ -77,7 +76,6 @@ function testHistory() {
|
||||
jsterm.historyPeruse(HISTORY_BACK);
|
||||
is (input.value, executeList[0], "test that item is still still index 0");
|
||||
|
||||
|
||||
for (var i = 1; i < executeList.length; i++) {
|
||||
jsterm.historyPeruse(HISTORY_FORWARD);
|
||||
is (input.value, executeList[i], "check history next idx:" + i);
|
||||
@ -98,9 +96,6 @@ function testHistory() {
|
||||
jsterm.historyPeruse(HISTORY_BACK);
|
||||
is (input.value, executeList[idxLast], "check history next idx:" + idxLast);
|
||||
|
||||
jsterm.clearOutput();
|
||||
jsterm.history.splice(0, jsterm.history.length); // workaround for bug 592552
|
||||
|
||||
finishTest();
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,10 @@ let jsterm;
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testJSTerm, false);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testJSTerm);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function checkResult(msg, desc, lines) {
|
||||
@ -55,13 +58,9 @@ function checkResult(msg, desc, lines) {
|
||||
desc);
|
||||
}
|
||||
|
||||
function testJSTerm()
|
||||
function testJSTerm(hud)
|
||||
{
|
||||
browser.removeEventListener("DOMContentLoaded", testJSTerm, false);
|
||||
|
||||
openConsole();
|
||||
|
||||
jsterm = HUDService.getHudByWindow(content).jsterm;
|
||||
jsterm = hud.jsterm;
|
||||
|
||||
jsterm.clearOutput();
|
||||
jsterm.execute("'id=' + $('header').getAttribute('id')");
|
||||
@ -155,5 +154,5 @@ function testJSTerm()
|
||||
checkResult("null", "null is null", 1);
|
||||
|
||||
jsterm = null;
|
||||
finishTest();
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(consoleOpened);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(consoleOpened);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(consoleOpened);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ function test() {
|
||||
|
||||
function onLoad() {
|
||||
browser.removeEventListener("DOMContentLoaded", onLoad, false);
|
||||
openConsole(function(hud) {
|
||||
openConsole(null, function(hud) {
|
||||
content.console.log("a log message");
|
||||
|
||||
waitForSuccess({
|
||||
|
@ -49,14 +49,13 @@ let testDriver;
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testNetworkPanel, false);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testNetworkPanel);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testNetworkPanel() {
|
||||
browser.removeEventListener("DOMContentLoaded", testNetworkPanel,
|
||||
false);
|
||||
openConsole();
|
||||
|
||||
testDriver = testGen();
|
||||
testDriver.next();
|
||||
}
|
||||
@ -100,11 +99,10 @@ function checkNodeKeyValue(aPanel, aId, aKey, aValue) {
|
||||
function testGen() {
|
||||
let filterBox = HUDService.getHudByWindow(content).filterBox;
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "l10n", function () {
|
||||
let obj = {};
|
||||
Cu.import("resource:///modules/WebConsoleUtils.jsm", obj);
|
||||
return obj.WebConsoleUtils.l10n;
|
||||
});
|
||||
let tempScope = {};
|
||||
Cu.import("resource:///modules/WebConsoleUtils.jsm", tempScope);
|
||||
let l10n = tempScope.WebConsoleUtils.l10n;
|
||||
tempScope = null;
|
||||
|
||||
var httpActivity = {
|
||||
url: "http://www.testpage.com",
|
||||
@ -489,5 +487,6 @@ function testGen() {
|
||||
networkPanel.panel.hidePopup(); */
|
||||
|
||||
// All done!
|
||||
finish();
|
||||
testDriver = null;
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
|
@ -45,17 +45,14 @@ const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/te
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testNullAndUndefinedOutput,
|
||||
false);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testNullAndUndefinedOutput);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testNullAndUndefinedOutput() {
|
||||
browser.removeEventListener("DOMContentLoaded",
|
||||
testNullAndUndefinedOutput, false);
|
||||
|
||||
openConsole();
|
||||
|
||||
let jsterm = HUDService.getHudByWindow(content).jsterm;
|
||||
function testNullAndUndefinedOutput(hud) {
|
||||
let jsterm = hud.jsterm;
|
||||
let outputNode = jsterm.outputNode;
|
||||
|
||||
jsterm.clearOutput();
|
||||
@ -72,9 +69,6 @@ function testNullAndUndefinedOutput() {
|
||||
is(nodes.length, 2, "2 nodes in output");
|
||||
ok(nodes[1].textContent.indexOf("undefined") > -1, "'undefined' printed to output");
|
||||
|
||||
jsterm.clearOutput();
|
||||
jsterm.history.splice(0, jsterm.history.length); // workaround for bug 592552
|
||||
|
||||
finishTest();
|
||||
executeSoon(finishTest);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(testOutputOrder);
|
||||
openConsole(null, testOutputOrder);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -7,27 +7,37 @@
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-error.html";
|
||||
|
||||
function test() {
|
||||
expectUncaughtException();
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testViewSource, false);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testViewSource);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testViewSource() {
|
||||
browser.removeEventListener("DOMContentLoaded", testViewSource, false);
|
||||
|
||||
openConsole();
|
||||
|
||||
function testViewSource(hud) {
|
||||
let button = content.document.querySelector("button");
|
||||
button = XPCNativeWrapper.unwrap(button);
|
||||
ok(button, "we have the button on the page");
|
||||
|
||||
button.addEventListener("click", buttonClicked, false);
|
||||
expectUncaughtException();
|
||||
EventUtils.sendMouseEvent({ type: "click" }, button, content);
|
||||
}
|
||||
|
||||
function buttonClicked(aEvent) {
|
||||
aEvent.target.removeEventListener("click", buttonClicked, false);
|
||||
executeSoon(findLocationNode);
|
||||
waitForSuccess({
|
||||
name: "find the location node",
|
||||
validatorFn: function()
|
||||
{
|
||||
return hud.outputNode.querySelector(".webconsole-location");
|
||||
},
|
||||
successFn: function()
|
||||
{
|
||||
let locationNode = hud.outputNode.querySelector(".webconsole-location");
|
||||
|
||||
Services.ww.registerNotification(observer);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, locationNode);
|
||||
},
|
||||
failureFn: finishTest,
|
||||
});
|
||||
}
|
||||
|
||||
let observer = {
|
||||
@ -39,8 +49,6 @@ let observer = {
|
||||
ok(true, "the view source window was opened in response to clicking " +
|
||||
"the location node");
|
||||
|
||||
Services.ww.unregisterNotification(this);
|
||||
|
||||
// executeSoon() is necessary to avoid crashing Firefox. See bug 611543.
|
||||
executeSoon(function() {
|
||||
aSubject.close();
|
||||
@ -49,14 +57,6 @@ let observer = {
|
||||
}
|
||||
};
|
||||
|
||||
function findLocationNode() {
|
||||
outputNode = HUDService.getHudByWindow(content).outputNode;
|
||||
|
||||
let locationNode = outputNode.querySelector(".webconsole-location");
|
||||
ok(locationNode, "we have the location node");
|
||||
|
||||
Services.ww.registerNotification(observer);
|
||||
|
||||
EventUtils.sendMouseEvent({ type: "click" }, locationNode);
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.ww.unregisterNotification(observer);
|
||||
});
|
||||
|
@ -8,7 +8,10 @@ const POSITION_PREF = "devtools.webconsole.position";
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", onLoad, false);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
registerCleanupFunction(testEnd);
|
||||
}
|
||||
|
||||
@ -16,13 +19,7 @@ function testEnd() {
|
||||
Services.prefs.clearUserPref(POSITION_PREF);
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
browser.removeEventListener("DOMContentLoaded", onLoad, false);
|
||||
|
||||
openConsole();
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let hudRef = HUDService.hudReferences[hudId];
|
||||
function consoleOpened(hudRef) {
|
||||
let hudBox = hudRef.HUDBox;
|
||||
|
||||
// listen for the panel popupshown event.
|
||||
@ -33,7 +30,7 @@ function onLoad() {
|
||||
|
||||
document.addEventListener("popuphidden", function popupHidden() {
|
||||
document.removeEventListener("popuphidden", popupHidden, false);
|
||||
finishTest();
|
||||
executeSoon(finishTest);
|
||||
}, false);
|
||||
|
||||
// Close the window console via the menu item
|
||||
|
@ -156,13 +156,16 @@ function findLogEntry(aString)
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the Web Console for the current tab.
|
||||
* Open the Web Console for the given tab.
|
||||
*
|
||||
* @param nsIDOMElement [aTab]
|
||||
* Optional tab element for which you want open the Web Console. The
|
||||
* default tab is taken from the global variable |tab|.
|
||||
* @param function [aCallback]
|
||||
* Optional function to invoke after the Web Console completes
|
||||
* initialization.
|
||||
* initialization (web-console-created).
|
||||
*/
|
||||
function openConsole(aCallback)
|
||||
function openConsole(aTab, aCallback)
|
||||
{
|
||||
function onWebConsoleOpen(aSubject, aTopic)
|
||||
{
|
||||
@ -178,35 +181,51 @@ function openConsole(aCallback)
|
||||
Services.obs.addObserver(onWebConsoleOpen, "web-console-created", false);
|
||||
}
|
||||
|
||||
HUDService.activateHUDForContext(tab);
|
||||
HUDService.activateHUDForContext(aTab || tab);
|
||||
}
|
||||
|
||||
function closeConsole()
|
||||
/**
|
||||
* Close the Web Console for the given tab.
|
||||
*
|
||||
* @param nsIDOMElement [aTab]
|
||||
* Optional tab element for which you want close the Web Console. The
|
||||
* default tab is taken from the global variable |tab|.
|
||||
* @param function [aCallback]
|
||||
* Optional function to invoke after the Web Console completes
|
||||
* closing (web-console-destroyed).
|
||||
*/
|
||||
function closeConsole(aTab, aCallback)
|
||||
{
|
||||
HUDService.deactivateHUDForContext(tab);
|
||||
function onWebConsoleClose(aSubject, aTopic)
|
||||
{
|
||||
if (aTopic == "web-console-destroyed") {
|
||||
Services.obs.removeObserver(onWebConsoleClose, "web-console-destroyed");
|
||||
aSubject.QueryInterface(Ci.nsISupportsString);
|
||||
let hudId = aSubject.data;
|
||||
executeSoon(aCallback.bind(null, hudId));
|
||||
}
|
||||
}
|
||||
|
||||
if (aCallback) {
|
||||
Services.obs.addObserver(onWebConsoleClose, "web-console-destroyed", false);
|
||||
}
|
||||
|
||||
HUDService.deactivateHUDForContext(aTab || tab);
|
||||
}
|
||||
|
||||
function finishTest()
|
||||
{
|
||||
browser = hudId = hud = filterBox = outputNode = cs = null;
|
||||
|
||||
function onWebConsoleClose(aSubject, aTopic)
|
||||
{
|
||||
if (aTopic == "web-console-destroyed") {
|
||||
Services.obs.removeObserver(onWebConsoleClose, "web-console-destroyed");
|
||||
executeSoon(finish);
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.addObserver(onWebConsoleClose, "web-console-destroyed", false);
|
||||
|
||||
let hud = HUDService.getHudByWindow(content);
|
||||
if (!hud) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
hud.jsterm.clearOutput(true);
|
||||
HUDService.deactivateHUDForContext(hud.tab);
|
||||
|
||||
closeConsole(hud.tab, finish);
|
||||
|
||||
hud = null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user