mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 673148 - (async-webconsole) Part 5 - HUDService.jsm cleanup; r=rcampbell f=jwalker
This commit is contained in:
parent
68a2ba1d84
commit
cdfb24ae11
@ -261,6 +261,8 @@ let Manager = {
|
||||
* to the remote process.
|
||||
* - NetworkMonitor - log all the network activity and send HAR-like
|
||||
* messages to the remote Web Console process.
|
||||
* - LocationChange - log page location changes. See
|
||||
* ConsoleProgressListener.
|
||||
*
|
||||
* @param string aFeature
|
||||
* One of the supported features.
|
||||
@ -287,6 +289,11 @@ let Manager = {
|
||||
case "NetworkMonitor":
|
||||
NetworkMonitor.init(aMessage);
|
||||
break;
|
||||
case "LocationChange":
|
||||
ConsoleProgressListener.startMonitor(ConsoleProgressListener
|
||||
.MONITOR_LOCATION_CHANGE);
|
||||
ConsoleProgressListener.sendLocation();
|
||||
break;
|
||||
default:
|
||||
Cu.reportError("Web Console content: unknown feature " + aFeature);
|
||||
break;
|
||||
@ -324,6 +331,10 @@ let Manager = {
|
||||
case "NetworkMonitor":
|
||||
NetworkMonitor.destroy();
|
||||
break;
|
||||
case "LocationChange":
|
||||
ConsoleProgressListener.stopMonitor(ConsoleProgressListener
|
||||
.MONITOR_LOCATION_CHANGE);
|
||||
break;
|
||||
default:
|
||||
Cu.reportError("Web Console content: unknown feature " + aFeature);
|
||||
break;
|
||||
@ -738,8 +749,18 @@ let JSTerm = {
|
||||
|
||||
/**
|
||||
* Initialize the JavaScript terminal feature.
|
||||
*
|
||||
* @param object aMessage
|
||||
* Options for JSTerm sent from the remote Web Console instance. This
|
||||
* object holds the following properties:
|
||||
*
|
||||
* - notifyNonNativeConsoleAPI - boolean that tells if you want to be
|
||||
* notified if the window.console API object in the page is not the
|
||||
* native one (if the page overrides it).
|
||||
* A "JSTerm:NonNativeConsoleAPI" message will be sent if this is the
|
||||
* case.
|
||||
*/
|
||||
init: function JST_init()
|
||||
init: function JST_init(aMessage)
|
||||
{
|
||||
this._objectCache = {};
|
||||
this._messageHandlers = {
|
||||
@ -755,6 +776,13 @@ let JSTerm = {
|
||||
}
|
||||
|
||||
this._createSandbox();
|
||||
|
||||
if (aMessage && aMessage.notifyNonNativeConsoleAPI) {
|
||||
let consoleObject = WebConsoleUtils.unwrap(this.window).console;
|
||||
if (!("__mozillaConsole__" in consoleObject)) {
|
||||
Manager.sendMessage("JSTerm:NonNativeConsoleAPI", {});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1697,10 +1725,8 @@ let NetworkMonitor = {
|
||||
|
||||
// Monitor file:// activity as well.
|
||||
if (aMessage && aMessage.monitorFileActivity) {
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIWebProgress);
|
||||
this.progressListener = new ConsoleProgressListener();
|
||||
webProgress.addProgressListener(this.progressListener,
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_ALL);
|
||||
ConsoleProgressListener.startMonitor(ConsoleProgressListener
|
||||
.MONITOR_FILE_ACTIVITY);
|
||||
}
|
||||
},
|
||||
|
||||
@ -2240,11 +2266,8 @@ let NetworkMonitor = {
|
||||
|
||||
activityDistributor.removeObserver(this);
|
||||
|
||||
if (this.progressListener) {
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIWebProgress);
|
||||
webProgress.removeProgressListener(this.progressListener);
|
||||
delete this.progressListener;
|
||||
}
|
||||
ConsoleProgressListener.stopMonitor(ConsoleProgressListener
|
||||
.MONITOR_FILE_ACTIVITY);
|
||||
|
||||
delete this.openRequests;
|
||||
delete this.openResponses;
|
||||
@ -2252,23 +2275,149 @@ let NetworkMonitor = {
|
||||
};
|
||||
|
||||
/**
|
||||
* A WebProgressListener that listens for location changes. This progress
|
||||
* listener is used to track file loads. When a file:// URI is loaded
|
||||
* a "WebConsole:FileActivity" message is sent to the remote Web Console
|
||||
* instance. The message JSON holds only one property: uri (the file URI).
|
||||
* A WebProgressListener that listens for location changes.
|
||||
*
|
||||
* @constructor
|
||||
* This progress listener is used to track file loads and other kinds of
|
||||
* location changes.
|
||||
*
|
||||
* When a file:// URI is loaded a "WebConsole:FileActivity" message is sent to
|
||||
* the remote Web Console instance. The message JSON holds only one property:
|
||||
* uri (the file URI).
|
||||
*
|
||||
* When the current page location changes a "WebConsole:LocationChange" message
|
||||
* is sent. See ConsoleProgressListener.sendLocation() for details.
|
||||
*/
|
||||
function ConsoleProgressListener() { }
|
||||
let ConsoleProgressListener = {
|
||||
/**
|
||||
* Constant used for startMonitor()/stopMonitor() that tells you want to
|
||||
* monitor file loads.
|
||||
*/
|
||||
MONITOR_FILE_ACTIVITY: 1,
|
||||
|
||||
/**
|
||||
* Constant used for startMonitor()/stopMonitor() that tells you want to
|
||||
* monitor page location changes.
|
||||
*/
|
||||
MONITOR_LOCATION_CHANGE: 2,
|
||||
|
||||
/**
|
||||
* Tells if you want to monitor file activity.
|
||||
* @private
|
||||
* @type boolean
|
||||
*/
|
||||
_fileActivity: false,
|
||||
|
||||
/**
|
||||
* Tells if you want to monitor location changes.
|
||||
* @private
|
||||
* @type boolean
|
||||
*/
|
||||
_locationChange: false,
|
||||
|
||||
/**
|
||||
* Tells if the console progress listener is initialized or not.
|
||||
* @private
|
||||
* @type boolean
|
||||
*/
|
||||
_initialized: false,
|
||||
|
||||
ConsoleProgressListener.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
|
||||
onStateChange: function CPL_onStateChange(aProgress, aRequest, aState,
|
||||
aStatus)
|
||||
/**
|
||||
* Initialize the ConsoleProgressListener.
|
||||
* @private
|
||||
*/
|
||||
_init: function CPL__init()
|
||||
{
|
||||
if (!_alive || !(aState & Ci.nsIWebProgressListener.STATE_START)) {
|
||||
if (this._initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._initialized = true;
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIWebProgress);
|
||||
webProgress.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_ALL);
|
||||
},
|
||||
|
||||
/**
|
||||
* Start a monitor/tracker related to the current nsIWebProgressListener
|
||||
* instance.
|
||||
*
|
||||
* @param number aMonitor
|
||||
* Tells what you want to track. Available constants:
|
||||
* - this.MONITOR_FILE_ACTIVITY
|
||||
* Track file loads.
|
||||
* - this.MONITOR_LOCATION_CHANGE
|
||||
* Track location changes for the top window.
|
||||
*/
|
||||
startMonitor: function CPL_startMonitor(aMonitor)
|
||||
{
|
||||
switch (aMonitor) {
|
||||
case this.MONITOR_FILE_ACTIVITY:
|
||||
this._fileActivity = true;
|
||||
break;
|
||||
case this.MONITOR_LOCATION_CHANGE:
|
||||
this._locationChange = true;
|
||||
break;
|
||||
default:
|
||||
throw new Error("HUDService-content: unknown monitor type " +
|
||||
aMonitor + " for the ConsoleProgressListener!");
|
||||
}
|
||||
this._init();
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop a monitor.
|
||||
*
|
||||
* @param number aMonitor
|
||||
* Tells what you want to stop tracking. See this.startMonitor() for
|
||||
* the list of constants.
|
||||
*/
|
||||
stopMonitor: function CPL_stopMonitor(aMonitor)
|
||||
{
|
||||
switch (aMonitor) {
|
||||
case this.MONITOR_FILE_ACTIVITY:
|
||||
this._fileActivity = false;
|
||||
break;
|
||||
case this.MONITOR_LOCATION_CHANGE:
|
||||
this._locationChange = false;
|
||||
break;
|
||||
default:
|
||||
throw new Error("HUDService-content: unknown monitor type " +
|
||||
aMonitor + " for the ConsoleProgressListener!");
|
||||
}
|
||||
|
||||
if (!this._fileActivity && !this._locationChange) {
|
||||
this.destroy();
|
||||
}
|
||||
},
|
||||
|
||||
onStateChange:
|
||||
function CPL_onStateChange(aProgress, aRequest, aState, aStatus)
|
||||
{
|
||||
if (!_alive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._fileActivity) {
|
||||
this._checkFileActivity(aProgress, aRequest, aState, aStatus);
|
||||
}
|
||||
|
||||
if (this._locationChange) {
|
||||
this._checkLocationChange(aProgress, aRequest, aState, aStatus);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if there is any file load, given the arguments of
|
||||
* nsIWebProgressListener.onStateChange. If the state change tells that a file
|
||||
* URI has been loaded, then the remote Web Console instance is notified.
|
||||
* @private
|
||||
*/
|
||||
_checkFileActivity:
|
||||
function CPL__checkFileActivity(aProgress, aRequest, aState, aStatus)
|
||||
{
|
||||
if (!(aState & Ci.nsIWebProgressListener.STATE_START)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2289,10 +2438,62 @@ ConsoleProgressListener.prototype = {
|
||||
Manager.sendMessage("WebConsole:FileActivity", {uri: uri.spec});
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if the current window.top location is changing, given the arguments
|
||||
* of nsIWebProgressListener.onStateChange. If that is the case, the remote
|
||||
* Web Console instance is notified.
|
||||
* @private
|
||||
*/
|
||||
_checkLocationChange:
|
||||
function CPL__checkLocationChange(aProgress, aRequest, aState, aStatus)
|
||||
{
|
||||
let isStop = aState & Ci.nsIWebProgressListener.STATE_STOP;
|
||||
let isNetwork = aState & Ci.nsIWebProgressListener.STATE_IS_NETWORK;
|
||||
let isWindow = aState & Ci.nsIWebProgressListener.STATE_IS_WINDOW;
|
||||
|
||||
// Skip non-interesting states.
|
||||
if (!isStop || !isNetwork || !isWindow ||
|
||||
aProgress.DOMWindow != Manager.window) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendLocation();
|
||||
},
|
||||
|
||||
onLocationChange: function() {},
|
||||
onStatusChange: function() {},
|
||||
onProgressChange: function() {},
|
||||
onSecurityChange: function() {},
|
||||
|
||||
/**
|
||||
* Send the location of the current top window to the remote Web Console.
|
||||
* A "WebConsole:LocationChange" message is sent. The JSON object holds two
|
||||
* properties: location and title.
|
||||
*/
|
||||
sendLocation: function CPL_sendLocation()
|
||||
{
|
||||
let message = {
|
||||
"location": Manager.window.location.href,
|
||||
"title": Manager.window.document.title,
|
||||
};
|
||||
Manager.sendMessage("WebConsole:LocationChange", message);
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the ConsoleProgressListener.
|
||||
*/
|
||||
destroy: function CPL_destroy()
|
||||
{
|
||||
if (!this._initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._initialized = false;
|
||||
this._fileActivity = false;
|
||||
this._locationChange = false;
|
||||
let webProgress = docShell.QueryInterface(Ci.nsIWebProgress);
|
||||
webProgress.removeProgressListener(this);
|
||||
},
|
||||
};
|
||||
|
||||
Manager.init();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,12 +25,10 @@ _BROWSER_TEST_FILES = \
|
||||
browser_webconsole_bug_597136_network_requests_from_chrome.js \
|
||||
browser_webconsole_completion.js \
|
||||
browser_webconsole_console_logging_api.js \
|
||||
browser_webconsole_consoleonpage.js \
|
||||
browser_webconsole_chrome.js \
|
||||
browser_webconsole_execution_scope.js \
|
||||
browser_webconsole_for_of.js \
|
||||
browser_webconsole_history.js \
|
||||
browser_webconsole_hud_getters.js \
|
||||
browser_webconsole_js_input_and_output_styling.js \
|
||||
browser_webconsole_js_input_expansion.js \
|
||||
browser_webconsole_live_filtering_of_message_types.js \
|
||||
@ -46,7 +44,6 @@ _BROWSER_TEST_FILES = \
|
||||
browser_webconsole_output_order.js \
|
||||
browser_webconsole_property_panel.js \
|
||||
browser_webconsole_property_provider.js \
|
||||
browser_webconsole_registries.js \
|
||||
browser_webconsole_bug_587617_output_copy.js \
|
||||
browser_webconsole_bug_585237_line_limit.js \
|
||||
browser_webconsole_bug_581231_close_button.js \
|
||||
@ -105,7 +102,6 @@ _BROWSER_TEST_FILES = \
|
||||
browser_webconsole_bug_651501_document_body_autocomplete.js \
|
||||
browser_webconsole_bug_653531_highlighter_console_helper.js \
|
||||
browser_webconsole_bug_659907_console_dir.js \
|
||||
browser_webconsole_bug_678816.js \
|
||||
browser_webconsole_bug_664131_console_group.js \
|
||||
browser_webconsole_bug_704295.js \
|
||||
browser_webconsole_bug_658368_time_methods.js \
|
||||
@ -180,7 +176,6 @@ _BROWSER_TEST_PAGES = \
|
||||
test-bug-644419-log-limits.html \
|
||||
test-bug-632275-getters.html \
|
||||
test-bug-646025-console-file-location.html \
|
||||
test-bug-678816-content.js \
|
||||
test-file-location.js \
|
||||
test-bug-658368-time-methods.html \
|
||||
test-webconsole-error-observer.html \
|
||||
|
@ -10,29 +10,39 @@ function test() {
|
||||
|
||||
// First test that the warning does not appear on a normal page (about:blank)
|
||||
addTab("about:blank");
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
testOpenWebConsole(false);
|
||||
executeSoon(testWarningPresent);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testWarningPresent() {
|
||||
// Then test that the warning does appear on a page that replaces the API
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
testOpenWebConsole(true);
|
||||
finishTest();
|
||||
}, true);
|
||||
browser.contentWindow.location = TEST_REPLACED_API_URI;
|
||||
}
|
||||
|
||||
function testOpenWebConsole(shouldWarn) {
|
||||
openConsole();
|
||||
|
||||
hud = HUDService.getHudByWindow(content);
|
||||
ok(hud, "WebConsole was opened");
|
||||
|
||||
let msg = (shouldWarn ? "found" : "didn't find") + " API replacement warning";
|
||||
testLogEntry(hud.outputNode, "disabled", msg, false, !shouldWarn);
|
||||
openConsole(null, function(hud) {
|
||||
waitForSuccess({
|
||||
name: (shouldWarn ? "no " : "") + "API replacement warning",
|
||||
validatorFn: function()
|
||||
{
|
||||
let pos = hud.outputNode.textContent.indexOf("disabled by");
|
||||
return shouldWarn ? pos > -1 : pos == -1;
|
||||
},
|
||||
successFn: function() {
|
||||
if (shouldWarn) {
|
||||
finishTest();
|
||||
}
|
||||
else {
|
||||
closeConsole(null, testWarningPresent);
|
||||
}
|
||||
},
|
||||
failureFn: finishTest,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -9,17 +9,15 @@ const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/te
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testGroups, false);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testGroups);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testGroups() {
|
||||
browser.removeEventListener("DOMContentLoaded", testGroups, false);
|
||||
|
||||
openConsole();
|
||||
|
||||
let HUD = HUDService.getHudByWindow(content);
|
||||
function testGroups(HUD) {
|
||||
let jsterm = HUD.jsterm;
|
||||
let outputNode = jsterm.outputNode;
|
||||
let outputNode = HUD.outputNode;
|
||||
|
||||
// We test for one group by testing for zero "new" groups. The
|
||||
// "webconsole-new-group" class creates a divider. Thus one group is
|
||||
@ -46,9 +44,6 @@ function testGroups() {
|
||||
is(outputNode.querySelectorAll(".webconsole-new-group").length, 1,
|
||||
"one group divider exists after the third console message");
|
||||
|
||||
jsterm.clearOutput();
|
||||
jsterm.history.splice(0, jsterm.history.length); // workaround for bug 592552
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
||||
|
@ -12,16 +12,14 @@ const TEST_URI = "http://example.com/";
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded",
|
||||
testSelectionWhenMovingBetweenBoxes, false);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testSelectionWhenMovingBetweenBoxes);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testSelectionWhenMovingBetweenBoxes() {
|
||||
browser.removeEventListener("DOMContentLoaded",
|
||||
testSelectionWhenMovingBetweenBoxes, false);
|
||||
openConsole();
|
||||
|
||||
let jsterm = HUDService.getHudByWindow(content).jsterm;
|
||||
function testSelectionWhenMovingBetweenBoxes(hud) {
|
||||
let jsterm = hud.jsterm;
|
||||
|
||||
// Fill the console with some output.
|
||||
jsterm.clearOutput();
|
||||
@ -29,7 +27,7 @@ function testSelectionWhenMovingBetweenBoxes() {
|
||||
jsterm.execute("3 + 4");
|
||||
jsterm.execute("5 + 6");
|
||||
|
||||
outputNode = jsterm.outputNode;
|
||||
let outputNode = hud.outputNode;
|
||||
|
||||
ok(outputNode.childNodes.length >= 3, "the output node has children after " +
|
||||
"executing some JavaScript");
|
||||
|
@ -57,7 +57,7 @@ function openConsoles() {
|
||||
let tab = openTabs[i];
|
||||
openConsole(tab, function(index, hud) {
|
||||
ok(hud, "HUD is open for tab " + index);
|
||||
hud.console.log("message for tab " + index);
|
||||
hud.browser.contentWindow.console.log("message for tab " + index);
|
||||
consolesOpen++;
|
||||
}.bind(null, i));
|
||||
}
|
||||
|
@ -10,20 +10,15 @@
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-network.html";
|
||||
|
||||
function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
openConsole();
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
hud = HUDService.hudReferences[hudId];
|
||||
function consoleOpened(aHud) {
|
||||
hud = aHud;
|
||||
|
||||
for (let i = 0; i < 200; i++) {
|
||||
hud.console.log("test message " + i);
|
||||
content.console.log("test message " + i);
|
||||
}
|
||||
|
||||
HUDService.setFilterState(hudId, "network", false);
|
||||
HUDService.setFilterState(hudId, "networkinfo", false);
|
||||
HUDService.setFilterState(hud.hudId, "network", false);
|
||||
HUDService.setFilterState(hud.hudId, "networkinfo", false);
|
||||
|
||||
hud.filterBox.value = "test message";
|
||||
HUDService.updateFilterText(hud.filterBox);
|
||||
@ -36,7 +31,7 @@ function tabLoad(aEvent) {
|
||||
}
|
||||
|
||||
function tabReload(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
browser.removeEventListener(aEvent.type, tabReload, true);
|
||||
|
||||
let msgNode = hud.outputNode.querySelector(".webconsole-msg-network");
|
||||
ok(msgNode, "found network message");
|
||||
@ -62,6 +57,9 @@ function tabReload(aEvent) {
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", tabLoad, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ function testGen() {
|
||||
|
||||
// Ugly but it does the job.
|
||||
with (content) {
|
||||
eval("HUD.console.log(" + consoleTest + ")");
|
||||
eval("content.console.log(" + consoleTest + ")");
|
||||
}
|
||||
|
||||
waitForSuccess({
|
||||
|
@ -17,13 +17,13 @@ function consoleOpened(HUD) {
|
||||
}
|
||||
|
||||
for (let i = 0; i < 50; i++) {
|
||||
HUD.console.log("test message " + i);
|
||||
content.console.log("test message " + i);
|
||||
}
|
||||
|
||||
HUD.console.log(longMessage);
|
||||
content.console.log(longMessage);
|
||||
|
||||
for (let i = 0; i < 50; i++) {
|
||||
HUD.console.log("test message " + i);
|
||||
content.console.log("test message " + i);
|
||||
}
|
||||
|
||||
HUD.jsterm.execute("1+1");
|
||||
|
@ -19,7 +19,7 @@ function testGen() {
|
||||
let scrollBox = outputNode.scrollBoxObject.element;
|
||||
|
||||
for (let i = 0; i < 150; i++) {
|
||||
hud.console.log("test message " + i);
|
||||
content.console.log("test message " + i);
|
||||
}
|
||||
|
||||
waitForSuccess({
|
||||
@ -46,7 +46,7 @@ function testGen() {
|
||||
isnot(topPosition, oldScrollTop, "scroll location updated (moved to top)");
|
||||
|
||||
// add a message and make sure scroll doesn't change
|
||||
hud.console.log("test message 150");
|
||||
content.console.log("test message 150");
|
||||
|
||||
waitForSuccess({
|
||||
name: "console.log message no. 151 displayed",
|
||||
@ -68,7 +68,7 @@ function testGen() {
|
||||
|
||||
oldScrollTop = outputNode.scrollTop;
|
||||
|
||||
hud.console.log("test message 151");
|
||||
content.console.log("test message 151");
|
||||
|
||||
waitForSuccess({
|
||||
name: "console.log message no. 152 displayed",
|
||||
|
@ -24,7 +24,7 @@ function testGen() {
|
||||
let boxObject = outputNode.scrollBoxObject;
|
||||
|
||||
for (let i = 0; i < 150; i++) {
|
||||
hud.console.log("test message " + i);
|
||||
content.console.log("test message " + i);
|
||||
}
|
||||
|
||||
waitForSuccess({
|
||||
@ -57,7 +57,7 @@ function testGen() {
|
||||
oldScrollTop = scrollBoxElement.scrollTop;
|
||||
|
||||
// add a message
|
||||
hud.console.log("hello world");
|
||||
content.console.log("hello world");
|
||||
|
||||
waitForSuccess({
|
||||
name: "console.log message #151 displayed",
|
||||
|
@ -14,7 +14,7 @@ function consoleOpened(hud) {
|
||||
let boxObject = outputNode.scrollBoxObject.element;
|
||||
|
||||
for (let i = 0; i < 150; i++) {
|
||||
hud.console.log("test message " + i);
|
||||
content.console.log("test message " + i);
|
||||
}
|
||||
|
||||
waitForSuccess({
|
||||
|
@ -52,7 +52,7 @@ function testWebDevLimits(aEvent) {
|
||||
function testWebDevLimits2() {
|
||||
// Fill the log with Web Developer errors.
|
||||
for (let i = 0; i < 11; i++) {
|
||||
hud.console.log("test message " + i);
|
||||
content.console.log("test message " + i);
|
||||
}
|
||||
|
||||
waitForSuccess({
|
||||
@ -80,7 +80,7 @@ function testJsLimits() {
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.exception", 10);
|
||||
|
||||
hud.jsterm.clearOutput();
|
||||
hud.console.log("testing JS limits");
|
||||
content.console.log("testing JS limits");
|
||||
|
||||
// Find the sentinel entry.
|
||||
waitForSuccess({
|
||||
@ -131,7 +131,7 @@ function testNetLimits() {
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.network", 10);
|
||||
|
||||
hud.jsterm.clearOutput();
|
||||
hud.console.log("testing Net limits");
|
||||
content.console.log("testing Net limits");
|
||||
|
||||
// Find the sentinel entry.
|
||||
waitForSuccess({
|
||||
@ -176,7 +176,7 @@ function testCssLimits() {
|
||||
Services.prefs.setIntPref("devtools.hud.loglimit.cssparser", 10);
|
||||
|
||||
hud.jsterm.clearOutput();
|
||||
hud.console.log("testing CSS limits");
|
||||
content.console.log("testing CSS limits");
|
||||
|
||||
// Find the sentinel entry.
|
||||
waitForSuccess({
|
||||
|
@ -5,46 +5,53 @@
|
||||
const TEST_URI = "data:text/html;charset=utf-8,<p>test for bug 663443. test1";
|
||||
|
||||
const POSITION_PREF = "devtools.webconsole.position";
|
||||
const POSITION_ABOVE = "above"; // default
|
||||
const POSITION_WINDOW = "window";
|
||||
|
||||
function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
function consoleOpened() {
|
||||
document.removeEventListener("popupshown", consoleOpened, false);
|
||||
|
||||
Services.prefs.setCharPref(POSITION_PREF, POSITION_WINDOW);
|
||||
let HUD = HUDService.getHudByWindow(content);
|
||||
ok(HUD.consolePanel, "Web Console opened in a panel");
|
||||
|
||||
openConsole();
|
||||
let waitForTitleChange = {
|
||||
name: "panel title change",
|
||||
validatorFn: function() {
|
||||
return HUD.consolePanel.label.indexOf("test2") > -1;
|
||||
},
|
||||
successFn: testEnd,
|
||||
failureFn: testEnd,
|
||||
};
|
||||
|
||||
document.addEventListener("popupshown", function popupShown() {
|
||||
document.removeEventListener("popupshown", popupShown, false);
|
||||
waitForSuccess({
|
||||
name: "initial panel title",
|
||||
validatorFn: function() {
|
||||
return HUD.consolePanel.label.indexOf("test1") > -1;
|
||||
},
|
||||
successFn: function() {
|
||||
content.location = "data:text/html;charset=utf-8,<p>test2 for bug 663443";
|
||||
waitForSuccess(waitForTitleChange);
|
||||
},
|
||||
failureFn: testEnd,
|
||||
});
|
||||
}
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
|
||||
ok(hudId, "Web Console is open");
|
||||
|
||||
let HUD = HUDService.hudReferences[hudId];
|
||||
ok(HUD.consolePanel, "Web Console opened in a panel");
|
||||
|
||||
isnot(HUD.consolePanel.label.indexOf("test1"), -1, "panel title is correct");
|
||||
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
isnot(HUD.consolePanel.label.indexOf("test2"), -1,
|
||||
"panel title is correct after page navigation");
|
||||
|
||||
HUD.positionConsole(POSITION_ABOVE);
|
||||
|
||||
closeConsole();
|
||||
|
||||
executeSoon(finishTest);
|
||||
}, true);
|
||||
|
||||
content.location = "data:text/html;charset=utf-8,<p>test2 for bug 663443";
|
||||
}, false);
|
||||
function testEnd() {
|
||||
closeConsole(null, finishTest);
|
||||
}
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", tabLoad, true);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
|
||||
Services.prefs.setCharPref(POSITION_PREF, POSITION_WINDOW);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref(POSITION_PREF);
|
||||
});
|
||||
|
||||
document.addEventListener("popupshown", consoleOpened, false);
|
||||
|
||||
openConsole();
|
||||
}, true);
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
|
||||
const FRAME_SCRIPT_URI ="chrome://mochitests/content/browser/browser/devtools/webconsole/test/test-bug-678816-content.js";
|
||||
|
||||
let HUD;
|
||||
let outputItem;
|
||||
|
||||
function tabLoad1(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
openConsole();
|
||||
HUD = HUDService.getHudByWindow(content);
|
||||
|
||||
browser.addEventListener("load", tabLoad2, true);
|
||||
|
||||
// Reload so we get some output in the console.
|
||||
browser.contentWindow.location.reload();
|
||||
}
|
||||
|
||||
function tabLoad2(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, tabLoad2, true);
|
||||
|
||||
outputItem = HUD.outputNode.querySelector(".hud-networkinfo .hud-clickable");
|
||||
ok(outputItem, "found a network message");
|
||||
document.addEventListener("popupshown", networkPanelShown, false);
|
||||
|
||||
// Click the network message to open the network panel.
|
||||
EventUtils.synthesizeMouseAtCenter(outputItem, {});
|
||||
}
|
||||
|
||||
function networkPanelShown(aEvent) {
|
||||
document.removeEventListener(aEvent.type, networkPanelShown, false);
|
||||
|
||||
executeSoon(function() {
|
||||
aEvent.target.addEventListener("popuphidden", networkPanelHidden, false);
|
||||
aEvent.target.hidePopup();
|
||||
});
|
||||
}
|
||||
|
||||
function networkPanelHidden(aEvent) {
|
||||
this.removeEventListener(aEvent.type, networkPanelHidden, false);
|
||||
|
||||
is(HUD.contentWindow, browser.contentWindow,
|
||||
"console has not been re-attached to the wrong window");
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
||||
function test() {
|
||||
messageManager.loadFrameScript(FRAME_SCRIPT_URI, true);
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
// There's no way to unload a frameScript so send a kill signal to
|
||||
// unregister the frame script's webProgressListener
|
||||
messageManager.sendAsyncMessage("bug-678816-kill-webProgressListener");
|
||||
});
|
||||
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", tabLoad1, true);
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*
|
||||
* Contributor(s):
|
||||
* Julian Viereck <jviereck@mozilla.com>
|
||||
* Mihai Șucan <mihai.sucan@gmail.com>
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-own-console.html";
|
||||
|
||||
function test()
|
||||
{
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, testOpenWebConsole);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function testOpenWebConsole(aHud)
|
||||
{
|
||||
hud = aHud;
|
||||
ok(hud, "WebConsole was opened");
|
||||
|
||||
testOwnConsole();
|
||||
}
|
||||
|
||||
function testConsoleOnPage(console) {
|
||||
isnot(console, undefined, "Console object defined on page");
|
||||
is(console.foo, "bar", "Custom console is not overwritten");
|
||||
}
|
||||
|
||||
function testOwnConsole()
|
||||
{
|
||||
let console = browser.contentWindow.wrappedJSObject.console;
|
||||
// Test console on the page. There is already one so it shouldn't be
|
||||
// overwritten by the WebConsole's console.
|
||||
testConsoleOnPage(console);
|
||||
|
||||
// Check that the console object is set on the HUD object although there
|
||||
// is no console object added to the page.
|
||||
ok(hud.console, "HUD console is defined");
|
||||
finishTest();
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// Tests that the HUD can be accessed via the HUD references in the HUD
|
||||
// service.
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testHUDGetters, false);
|
||||
}
|
||||
|
||||
function testHUDGetters() {
|
||||
browser.removeEventListener("DOMContentLoaded", testHUDGetters, false);
|
||||
|
||||
openConsole();
|
||||
|
||||
var HUD = HUDService.getHudByWindow(content);
|
||||
var jsterm = HUD.jsterm;
|
||||
var klass = jsterm.inputNode.getAttribute("class");
|
||||
ok(klass == "jsterm-input-node", "We have the input node.");
|
||||
|
||||
var hudconsole = HUD.console;
|
||||
is(typeof hudconsole, "object", "HUD.console is an object");
|
||||
is(typeof hudconsole.log, "function", "HUD.console.log is a function");
|
||||
is(typeof hudconsole.info, "function", "HUD.console.info is a function");
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// Tests that the HUD service keeps an accurate registry of all the Web Console
|
||||
// instances.
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html";
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", testRegistries, false);
|
||||
}
|
||||
|
||||
function testRegistries() {
|
||||
browser.removeEventListener("DOMContentLoaded", testRegistries, false);
|
||||
|
||||
openConsole();
|
||||
|
||||
let hud = HUDService.getHudByWindow(content);
|
||||
ok(hud, "we have a HUD");
|
||||
ok(HUDService.hudReferences[hud.hudId], "we have a HUD in hudReferences");
|
||||
|
||||
let windowID = WebConsoleUtils.getOuterWindowId(content);
|
||||
is(HUDService.windowIds[windowID], hud.hudId, "windowIds are working");
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
@ -28,10 +28,10 @@ function consoleOpened(hudRef) {
|
||||
|
||||
ok(hudRef.consolePanel, "console is in a panel");
|
||||
|
||||
document.addEventListener("popuphidden", function popupHidden() {
|
||||
document.removeEventListener("popuphidden", popupHidden, false);
|
||||
Services.obs.addObserver(function onWebConsoleClose() {
|
||||
Services.obs.removeObserver(onWebConsoleClose, "web-console-destroyed");
|
||||
executeSoon(finishTest);
|
||||
}, false);
|
||||
}, "web-console-destroyed", false);
|
||||
|
||||
// Close the window console via the menu item
|
||||
let menu = document.getElementById("webConsole");
|
||||
|
@ -1,28 +0,0 @@
|
||||
(function () {
|
||||
let ifaceReq = docShell.QueryInterface(Ci.nsIInterfaceRequestor);
|
||||
let webProgress = ifaceReq.getInterface(Ci.nsIWebProgress);
|
||||
|
||||
let WebProgressListener = {
|
||||
onStateChange: function WebProgressListener_onStateChange(
|
||||
webProgress, request, flag, status) {
|
||||
|
||||
if (flag & Ci.nsIWebProgressListener.STATE_START &&
|
||||
flag & Ci.nsIWebProgressListener.STATE_IS_WINDOW) {
|
||||
// ensure the dom window is the top one
|
||||
return (webProgress.DOMWindow.parent == webProgress.DOMWindow);
|
||||
}
|
||||
},
|
||||
|
||||
// ----------
|
||||
// Implements progress listener interface.
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference])
|
||||
};
|
||||
|
||||
// add web progress listener
|
||||
webProgress.addProgressListener(WebProgressListener, Ci.nsIWebProgress.NOTIFY_STATE_ALL);
|
||||
|
||||
addMessageListener("bug-678816-kill-webProgressListener", function () {
|
||||
webProgress.removeProgressListener(WebProgressListener);
|
||||
});
|
||||
})();
|
Loading…
Reference in New Issue
Block a user