Merge mozilla-central and fx-team

This commit is contained in:
Ed Morley 2013-11-12 15:12:05 +00:00
commit c3bf3239c0
9 changed files with 225 additions and 17 deletions

View File

@ -1210,6 +1210,11 @@ pref("devtools.webconsole.fontSize", 0);
// be cleared each time page navigation happens.
pref("devtools.webconsole.persistlog", false);
// Web Console timestamp: |true| if you want the logs and instructions
// in the Web Console to display a timestamp, or |false| to not display
// any timestamps.
pref("devtools.webconsole.timestampMessages", false);
// The number of lines that are displayed in the web console for the Net,
// CSS, JS and Web Developer categories.
pref("devtools.hud.loglimit.network", 200);

View File

@ -54,6 +54,10 @@
<checkbox label="&options.enablePersistentLogging.label;"
tooltiptext="&options.enablePersistentLogging.tooltip;"
data-pref="devtools.webconsole.persistlog"/>
<checkbox id="webconsole-timestamp-messages"
label="&options.timestampMessages.label;"
tooltiptext="&options.timestampMessages.tooltip;"
data-pref="devtools.webconsole.timestampMessages"/>
</vbox>
<label value="&options.profiler.label;"/>
<vbox id="profiler-options" class="options-groupbox">

View File

@ -239,3 +239,4 @@ skip-if = os == "linux"
[browser_webconsole_view_source.js]
[browser_webconsole_reflow.js]
[browser_webconsole_log_file_filter.js]
[browser_webconsole_expandable_timestamps.js]

View File

@ -22,6 +22,13 @@ function testFilterButtons(aHud) {
testMenuFilterButton("css");
testMenuFilterButton("js");
testMenuFilterButton("logging");
testMenuFilterButton("security");
testIsolateFilterButton("net");
testIsolateFilterButton("css");
testIsolateFilterButton("js");
testIsolateFilterButton("logging");
testIsolateFilterButton("security");
finishTest();
}
@ -72,15 +79,7 @@ function testMenuFilterButton(aCategory) {
"checked after turning off its first menu item");
// Turn all the filters off by clicking the main part of the button.
let anonymousNodes = hud.ui.document.getAnonymousNodes(button);
let subbutton;
for (let i = 0; i < anonymousNodes.length; i++) {
let node = anonymousNodes[i];
if (node.classList.contains("toolbarbutton-menubutton-button")) {
subbutton = node;
break;
}
}
let subbutton = getMainButton(button);
ok(subbutton, "we have the subbutton for category " + aCategory);
clickButton(subbutton);
@ -129,10 +128,81 @@ function testMenuFilterButton(aCategory) {
clickButton(subbutton);
}
function testIsolateFilterButton(aCategory) {
let selector = ".webconsole-filter-button[category=\"" + aCategory + "\"]";
let targetButton = hudBox.querySelector(selector);
ok(targetButton, "we have the \"" + aCategory + "\" button");
// Get the main part of the filter button.
let subbutton = getMainButton(targetButton);
ok(subbutton, "we have the subbutton for category " + aCategory);
// Turn on all the filters by alt clicking the main part of the button.
altClickButton(subbutton);
ok(isChecked(targetButton), "the button for category " + aCategory +
" is checked after isolating for filter");
// Check if all the filters for the target button are on.
let menuItems = targetButton.querySelectorAll("menuitem");
Array.forEach(menuItems, (item) => {
let prefKey = item.getAttribute("prefKey");
ok(isChecked(item), "menu item " + prefKey + " for category " +
aCategory + " is checked after isolating for " + aCategory);
ok(hud.ui.filterPrefs[prefKey], prefKey + " messages are " +
"turned on after isolating for " + aCategory);
});
// Ensure all other filter buttons are toggled off and their
// associated filters are turned off
let buttons = hudBox.querySelectorAll(".webconsole-filter-button[category]");
Array.forEach(buttons, (filterButton) => {
if (filterButton !== targetButton) {
let category = filterButton.getAttribute("category");
ok(!isChecked(filterButton), "the button for category " +
category + " is unchecked after isolating for " + aCategory);
menuItems = filterButton.querySelectorAll("menuitem");
Array.forEach(menuItems, (item) => {
let prefKey = item.getAttribute("prefKey");
ok(!isChecked(item), "menu item " + prefKey + " for category " +
aCategory + " is unchecked after isolating for " + aCategory);
ok(!hud.ui.filterPrefs[prefKey], prefKey + " messages are " +
"turned off after isolating for " + aCategory);
});
// Turn all the filters on again by clicking the button.
let mainButton = getMainButton(filterButton);
clickButton(mainButton);
}
});
}
/**
* Return the main part of the target filter button.
*/
function getMainButton(aTargetButton) {
let anonymousNodes = hud.ui.document.getAnonymousNodes(aTargetButton);
let subbutton;
for (let i = 0; i < anonymousNodes.length; i++) {
let node = anonymousNodes[i];
if (node.classList.contains("toolbarbutton-menubutton-button")) {
subbutton = node;
break;
}
}
return subbutton;
}
function clickButton(aNode) {
EventUtils.sendMouseEvent({ type: "click" }, aNode);
}
function altClickButton(aNode) {
EventUtils.sendMouseEvent({ type: "click", altKey: true }, aNode);
}
function chooseMenuItem(aNode) {
let event = document.createEvent("XULCommandEvent");
event.initCommandEvent("command", true, true, window, 0, false, false, false,

View File

@ -0,0 +1,58 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Test for the message timestamps option: check if the preference toggles the
// display of messages in the console output. See bug 722267.
function test()
{
const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages";
let hud;
registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP);
});
addTab("data:text/html;charset=utf-8,Web Console test for bug 722267 - " +
"preference for toggling timestamps in messages");
browser.addEventListener("load", function tabLoad() {
browser.removeEventListener("load", tabLoad, true);
openConsole(null, consoleOpened);
}, true);
function consoleOpened(aHud)
{
hud = aHud;
info("console opened");
let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP);
ok(!prefValue, "messages have no timestamp by default (pref check)");
ok(hud.outputNode.classList.contains("hideTimestamps"),
"messages have no timestamp (class name check)");
let toolbox = gDevTools.getToolbox(hud.target);
toolbox.selectTool("options").then(onOptionsPanelSelected);
}
function onOptionsPanelSelected(panel)
{
info("options panel opened");
gDevTools.once("pref-changed", onPrefChanged);
let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages");
checkbox.scrollIntoView();
EventUtils.synthesizeMouseAtCenter(checkbox, {}, panel.panelWin);
}
function onPrefChanged()
{
info("pref changed");
let prefValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP);
ok(prefValue, "messages have timestamps (pref check)");
ok(!hud.outputNode.classList.contains("hideTimestamps"),
"messages have timestamps (class name check)");
finishTest();
}
}

View File

@ -171,6 +171,7 @@ const MAX_LONG_STRING_LENGTH = 200000;
const PREF_CONNECTION_TIMEOUT = "devtools.debugger.remote-timeout";
const PREF_PERSISTLOG = "devtools.webconsole.persistlog";
const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages";
/**
* A WebConsoleFrame instance is an interactive console initialized *per target*
@ -201,6 +202,7 @@ function WebConsoleFrame(aWebConsoleOwner)
this._toggleFilter = this._toggleFilter.bind(this);
this._onPanelSelected = this._onPanelSelected.bind(this);
this._flushMessageQueue = this._flushMessageQueue.bind(this);
this._onToolboxPrefChanged = this._onToolboxPrefChanged.bind(this);
this._outputTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this._outputTimerInitialized = false;
@ -571,6 +573,13 @@ WebConsoleFrame.prototype = {
if (toolbox) {
toolbox.on("webconsole-selected", this._onPanelSelected);
}
// Toggle the timestamp on preference change
gDevTools.on("pref-changed", this._onToolboxPrefChanged);
this._onToolboxPrefChanged("pref-changed", {
pref: PREF_MESSAGE_TIMESTAMP,
newValue: Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP),
});
},
/**
@ -801,18 +810,26 @@ WebConsoleFrame.prototype = {
break;
}
// Toggle on the targeted filter button, and if the user alt clicked,
// toggle off all other filter buttons and their associated filters.
let state = target.getAttribute("checked") !== "true";
if (aEvent.getModifierState("Alt")) {
let buttons = this.document
.querySelectorAll(".webconsole-filter-button");
Array.forEach(buttons, (button) => {
if (button !== target) {
button.setAttribute("checked", false);
this._setMenuState(button, false);
}
});
state = true;
}
target.setAttribute("checked", state);
// This is a filter button with a drop-down, and the user clicked the
// main part of the button. Go through all the severities and toggle
// their associated filters.
let menuItems = target.querySelectorAll("menuitem");
for (let i = 0; i < menuItems.length; i++) {
menuItems[i].setAttribute("checked", state);
let prefKey = menuItems[i].getAttribute("prefKey");
this.setFilterState(prefKey, state);
}
this._setMenuState(target, state);
break;
}
@ -851,6 +868,25 @@ WebConsoleFrame.prototype = {
}
},
/**
* Set the menu attributes for a specific toggle button.
*
* @private
* @param XULElement aTarget
* Button with drop down items to be toggled.
* @param boolean aState
* True if the menu item is being toggled on, and false otherwise.
*/
_setMenuState: function WCF__setMenuState(aTarget, aState)
{
let menuItems = aTarget.querySelectorAll("menuitem");
Array.forEach(menuItems, (item) => {
item.setAttribute("checked", aState);
let prefKey = item.getAttribute("prefKey");
this.setFilterState(prefKey, aState);
});
},
/**
* Set the filter state for a specific toggle button.
*
@ -2775,6 +2811,29 @@ WebConsoleFrame.prototype = {
}, false);
},
/**
* Handler for the pref-changed event coming from the toolbox.
* Currently this function only handles the timestamps preferences.
*
* @private
* @param object aEvent
* This parameter is a string that holds the event name
* pref-changed in this case.
* @param object aData
* This is the pref-changed data object.
*/
_onToolboxPrefChanged: function WCF__onToolboxPrefChanged(aEvent, aData)
{
if (aData.pref == PREF_MESSAGE_TIMESTAMP) {
if (aData.newValue) {
this.outputNode.classList.remove("hideTimestamps");
}
else {
this.outputNode.classList.add("hideTimestamps");
}
}
},
/**
* Copies the selected items to the system clipboard.
*
@ -2885,6 +2944,8 @@ WebConsoleFrame.prototype = {
toolbox.off("webconsole-selected", this._onPanelSelected);
}
gDevTools.off("pref-changed", this._onToolboxPrefChanged);
this._repeatNodes = {};
this._outputQueue = [];
this._pruneCategoriesQueue = {};

View File

@ -48,8 +48,8 @@ function goUpdateConsoleCommands() {
<command id="cmd_close" oncommand="goDoCommand('cmd_close');" disabled="true"/>
</commandset>
<keyset id="consoleKeys">
<key id="key_fullZoomReduce" key="&fullZoomReduceCmd.commandkey;" command="cmd_fullZoomReduce" modifiers="accel"/>
<key key="&fullZoomReduceCmd.commandkey2;" command="cmd_fullZoomReduce" modifiers="accel"/>
<key id="key_fullZoomReduce" key="&fullZoomReduceCmd.commandkey;" command="cmd_fullZoomReduce" modifiers="accel"/>
<key key="&fullZoomReduceCmd.commandkey2;" command="cmd_fullZoomReduce" modifiers="accel"/>
<key id="key_fullZoomEnlarge" key="&fullZoomEnlargeCmd.commandkey;" command="cmd_fullZoomEnlarge" modifiers="accel"/>
<key key="&fullZoomEnlargeCmd.commandkey2;" command="cmd_fullZoomEnlarge" modifiers="accel"/>
<key key="&fullZoomEnlargeCmd.commandkey3;" command="cmd_fullZoomEnlarge" modifiers="accel"/>

View File

@ -109,6 +109,11 @@
<!ENTITY options.enablePersistentLogging.label "Enable persistent logs">
<!ENTITY options.enablePersistentLogging.tooltip "If you enable this option the Web Console will not clear the output each time you navigate to a new page">
<!-- LOCALIZATION NOTE (options.timestampMessages.label): This is the
- label for the checkbox that toggles timestamps in the Web Console -->
<!ENTITY options.timestampMessages.label "Enable timestamps">
<!ENTITY options.timestampMessages.tooltip "If you enable this option commands and output in the Web Console will display a timestamp">
<!-- LOCALIZATION NOTE (options.profiler.label): This is the label for the
- heading of the group of JavaScript Profiler preferences in the options
- panel. -->

View File

@ -112,6 +112,10 @@ a {
align-items: flex-start;
}
#output-container.hideTimestamps > .message > .timestamp {
display: none;
}
.filtered-by-type,
.filtered-by-string {
display: none;