backout of bug 586388 bug 589162 bug 589089 bug 592879 a=backout

This commit is contained in:
David Dahl 2010-09-09 11:12:29 -07:00
commit a2d94ddc92
10 changed files with 14 additions and 757 deletions

View File

@ -63,10 +63,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "sss",
"@mozilla.org/content/style-sheet-service;1",
"nsIStyleSheetService");
XPCOMUtils.defineLazyServiceGetter(this, "mimeService",
"@mozilla.org/mime;1",
"nsIMIMEService");
XPCOMUtils.defineLazyGetter(this, "NetUtil", function () {
var obj = {};
Cu.import("resource://gre/modules/NetUtil.jsm", obj);
@ -536,76 +532,6 @@ var NetworkHelper =
aCallback(NetworkHelper.readAndConvertFromStream(aInputStream,
contentCharset));
});
},
// This is a list of all the mine category maps jviereck could find in the
// firebug code base.
mimeCategoryMap: {
"text/plain": "txt",
"text/html": "html",
"text/xml": "xml",
"text/xsl": "txt",
"text/xul": "txt",
"text/css": "css",
"text/sgml": "txt",
"text/rtf": "txt",
"text/x-setext": "txt",
"text/richtext": "txt",
"text/javascript": "js",
"text/jscript": "txt",
"text/tab-separated-values": "txt",
"text/rdf": "txt",
"text/xif": "txt",
"text/ecmascript": "js",
"text/vnd.curl": "txt",
"text/x-json": "json",
"text/x-js": "txt",
"text/js": "txt",
"text/vbscript": "txt",
"view-source": "txt",
"view-fragment": "txt",
"application/xml": "xml",
"application/xhtml+xml": "xml",
"application/atom+xml": "xml",
"application/rss+xml": "xml",
"application/vnd.mozilla.maybe.feed": "xml",
"application/vnd.mozilla.xul+xml": "xml",
"application/javascript": "js",
"application/x-javascript": "js",
"application/x-httpd-php": "txt",
"application/rdf+xml": "xml",
"application/ecmascript": "js",
"application/http-index-format": "txt",
"application/json": "json",
"application/x-js": "txt",
"multipart/mixed": "txt",
"multipart/x-mixed-replace": "txt",
"image/svg+xml": "svg",
"application/octet-stream": "bin",
"image/jpeg": "image",
"image/jpg": "image",
"image/gif": "image",
"image/png": "image",
"image/bmp": "image",
"application/x-shockwave-flash": "flash",
"video/x-flv": "flash",
"audio/mpeg3": "media",
"audio/x-mpeg-3": "media",
"video/mpeg": "media",
"video/x-mpeg": "media",
"audio/ogg": "media",
"application/ogg": "media",
"application/x-ogg": "media",
"application/x-midi": "media",
"audio/midi": "media",
"audio/x-mid": "media",
"audio/x-midi": "media",
"music/crescendo": "media",
"audio/wav": "media",
"audio/x-wav": "media",
"text/json": "json",
"application/x-json": "json",
"application/json-rpc": "json"
}
}
@ -756,43 +682,6 @@ NetworkPanel.prototype =
return HUDService.getFormatStr("NetworkPanel." + aName, aArray);
},
/**
* Returns the content type of the response body. This is based on the
* response.header["Content-Type"] info. If this value is not available, then
* the content type is tried to be estimated by the url file ending.
*
* @returns string or null
* Content type or null if no content type could be figured out.
*/
get _contentType()
{
let response = this.httpActivity.response;
let contentTypeValue = null;
if (response.header && response.header["Content-Type"]) {
let types = response.header["Content-Type"].split(/,|;/);
for (let i = 0; i < types.length; i++) {
let type = NetworkHelper.mimeCategoryMap[types[i]];
if (type) {
return types[i];
}
}
}
// Try to get the content type from the request file extension.
let uri = NetUtil.newURI(this.httpActivity.url);
let mimeType = null;
if ((uri instanceof Ci.nsIURL) && uri.fileExtension) {
try {
mimeType = mimeService.getTypeFromExtension(uri.fileExtension);
} catch(e) {
// Added to prevent failures on OS X 64. No Flash?
Cu.reportError(e);
}
}
return mimeType;
},
/**
*
* @returns boolean
@ -800,34 +689,18 @@ NetworkPanel.prototype =
*/
get _responseIsImage()
{
return NetworkHelper.mimeCategoryMap[this._contentType] == "image";
},
/**
*
* @returns boolean
* True if the response body contains text, false otherwise.
*/
get _isResponseBodyTextData()
{
let contentType = this._contentType;
if (contentType.indexOf("text/") == 0) {
let response = this.httpActivity.response;
if (!response || !response.header || !response.header["Content-Type"]) {
let request = this.httpActivity.request;
if (request.header["Accept"] &&
request.header["Accept"].indexOf("image/") != -1) {
return true;
}
switch (NetworkHelper.mimeCategoryMap[contentType]) {
case "txt":
case "js":
case "json":
case "css":
case "html":
case "svg":
case "xml":
return true;
default:
else {
return false;
}
}
return response.header["Content-Type"].indexOf("image/") != -1;
},
/**
@ -1109,26 +982,6 @@ NetworkPanel.prototype =
aCachedContent || response.body);
},
/**
* Displays the `Unknown Content-Type hint` and sets the duration between the
* receiving of the response header on the NetworkPanel.
*
* @returns void
*/
_displayResponseBodyUnknownType: function NP_displayResponseBodyUnknownType()
{
let timing = this.httpActivity.timing;
this._displayNode("responseBodyUnknownType");
let deltaDuration =
Math.round((timing.RESPONSE_COMPLETE - timing.RESPONSE_HEADER) / 1000);
this._appendTextNode("responseBodyUnknownTypeInfo",
this._format("durationMS", [deltaDuration]));
this._appendTextNode("responseBodyUnknownTypeContent",
this._format("responseBodyUnableToDisplay.content", [this._contentType]));
},
/**
* Displays the `no response body` section and sets the the duration between
* the receiving of the response header and the end of the request.
@ -1213,10 +1066,6 @@ NetworkPanel.prototype =
this._displayResponseImage();
this._callIsDone();
}
else if (!this._isResponseBodyTextData) {
this._displayResponseBodyUnknownType();
this._callIsDone();
}
else if (response.body) {
this._displayResponseBody();
this._callIsDone();
@ -2112,45 +1961,6 @@ HUD_SERVICE.prototype =
}
},
/**
* Get OutputNode by Id
*
* @param string aId
* @returns nsIDOMNode
*/
getConsoleOutputNode: function HS_getConsoleOutputNode(aId)
{
let displayNode = this.getHeadsUpDisplay(aHUDId);
return displayNode.querySelectorAll(".hud-output-node")[0];
},
/**
* Inform user that the Web Console API has been replaced by a script
* in a content page.
*
* @param string aHUDId
* @returns void
*/
logWarningAboutReplacedAPI:
function HS_logWarningAboutReplacedAPI(aHUDId)
{
let domId = "hud-log-node-" + this.sequenceId();
let outputNode = this.getConsoleOutputNode(aHUDId);
let msgFormat = {
logLevel: "error",
activityObject: {},
hudId: aHUDId,
origin: "console-listener",
domId: domId,
message: this.getStr("ConsoleAPIDisabled"),
};
let messageObject =
this.messageFactory(msgFormat, "error", outputNode, msgFormat.activityObject);
this.logMessage(messageObject.messageObject, outputNode, messageObject.messageNode);
},
/**
* report consoleMessages recieved via the HUDConsoleObserver service
* @param nsIConsoleMessage aConsoleMessage
@ -2894,24 +2704,6 @@ HUD_SERVICE.prototype =
}
// capture JS Errors
this.setOnErrorHandler(aContentWindow);
// register the controller to handle "select all" properly
this.createController(xulWindow);
},
/**
* Adds the command controller to the XUL window if it's not already present.
*
* @param nsIDOMWindow aWindow
* The browser XUL window.
* @returns void
*/
createController: function HUD_createController(aWindow)
{
if (aWindow.commandController == null) {
aWindow.commandController = new CommandController(aWindow);
aWindow.controllers.insertControllerAt(0, aWindow.commandController);
}
}
};
@ -3315,15 +3107,6 @@ HeadsUpDisplay.prototype = {
copyItem.setAttribute("command", "cmd_copy");
menuPopup.appendChild(copyItem);
let selectAllItem = this.makeXULNode("menuitem");
selectAllItem.setAttribute("label", this.getStr("selectAllCmd.label"));
selectAllItem.setAttribute("accesskey",
this.getStr("selectAllCmd.accesskey"));
selectAllItem.setAttribute("hudId", this.hudId);
selectAllItem.setAttribute("buttonType", "selectAll");
selectAllItem.setAttribute("oncommand", "HUDConsoleUI.command(this);");
menuPopup.appendChild(selectAllItem);
menuPopup.appendChild(this.makeXULNode("menuseparator"));
let clearItem = this.makeXULNode("menuitem");
@ -4710,13 +4493,8 @@ LogMessage.prototype = {
this.messageNode.appendChild(messageTxtNode);
var classes = ["hud-msg-node", "hud-" + this.level];
if (this.activityObject.category == "CSS Parser") {
classes.push("hud-cssparser");
}
this.messageNode.setAttribute("class", classes.join(" "));
var klass = "hud-msg-node hud-" + this.level;
this.messageNode.setAttribute("class", klass);
var self = this;
@ -4922,16 +4700,8 @@ HeadsUpDisplayUICommands = {
command: function UIC_command(aButton) {
var filter = aButton.getAttribute("buttonType");
var hudId = aButton.getAttribute("hudId");
switch (filter) {
case "clear":
if (filter == "clear") {
HUDService.clearDisplay(hudId);
break;
case "selectAll":
let outputNode = HUDService.getOutputNodeById(hudId);
let chromeWindow = outputNode.ownerDocument.defaultView;
let commandController = chromeWindow.commandController;
commandController.selectAll(outputNode);
break;
}
},
@ -5235,67 +5005,6 @@ HUDWindowObserver = {
initialConsoleCreated: false,
};
///////////////////////////////////////////////////////////////////////////////
// CommandController
///////////////////////////////////////////////////////////////////////////////
/**
* A controller (an instance of nsIController) that makes editing actions
* behave appropriately in the context of the Web Console.
*/
function CommandController(aWindow) {
this.window = aWindow;
}
CommandController.prototype = {
/**
* Returns the HUD output node that currently has the focus, or null if the
* currently-focused element isn't inside the output node.
*
* @returns nsIDOMNode
* The currently-focused output node.
*/
_getFocusedOutputNode: function CommandController_getFocusedOutputNode()
{
let anchorNode = this.window.getSelection().anchorNode;
while (!(anchorNode.nodeType === anchorNode.ELEMENT_NODE &&
anchorNode.classList.contains("hud-output-node"))) {
anchorNode = anchorNode.parentNode;
}
return anchorNode;
},
/**
* Selects all the text in the HUD output.
*
* @param nsIDOMNode aOutputNode
* The HUD output node.
* @returns void
*/
selectAll: function CommandController_selectAll(aOutputNode)
{
let selection = this.window.getSelection();
selection.removeAllRanges();
selection.selectAllChildren(aOutputNode);
},
supportsCommand: function CommandController_supportsCommand(aCommand)
{
return aCommand === "cmd_selectAll" &&
this._getFocusedOutputNode() != null;
},
isCommandEnabled: function CommandController_isCommandEnabled(aCommand)
{
return aCommand === "cmd_selectAll";
},
doCommand: function CommandController_doCommand(aCommand)
{
this.selectAll(this._getFocusedOutputNode());
}
};
///////////////////////////////////////////////////////////////////////////////
// HUDConsoleObserver
///////////////////////////////////////////////////////////////////////////////

View File

@ -109,13 +109,6 @@
<span id="responseNoBodyInfo" class="info">&Delta;</span>
</h1>
</div>
<div id="responseBodyUnknownType" style="display:none">
<h1>
&networkPanel.responseBodyUnknownType;
<span id="responseBodyUnknownTypeInfo" class="info">&Delta;</span>
</h1>
<div class="property-header" id="responseBodyUnknownTypeContent"></div>
</div>
<div id="responseImage" style="display:none">
<h1>
&networkPanel.responseImage;

View File

@ -19,7 +19,6 @@
#
# Contributor(s):
# David Dahl <ddahl@mozilla.com>
# Patrick Walton <pcwalton@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
@ -46,12 +45,9 @@ include $(topsrcdir)/config/rules.mk
_BROWSER_TEST_FILES = \
browser_HUDServiceTestsAll.js \
browser_webconsole_bug_586388_select_all.js \
browser_webconsole_bug_585237_line_limit.js \
browser_webconsole_bug_588967_input_expansion.js \
browser_webconsole_netlogging.js \
browser_warn_user_about_replaced_api.js \
browser_webconsole_bug_589162_css_filter.js \
browser_webconsole_bug_581231_close_button.js \
$(NULL)
@ -69,7 +65,6 @@ _BROWSER_TEST_PAGES = \
test-duplicate-error.html \
test-image.png \
test-encoding-ISO-8859-1.html \
test-console-replaced-api.html \
$(NULL)
libs:: $(_BROWSER_TEST_FILES)

View File

@ -673,8 +673,7 @@ function testNetworkPanel()
httpActivity.timing.RESPONSE_HEADER = 1000;
httpActivity.response.status = "999 earthquake win";
httpActivity.response.header = {
leaveHouses: "true",
"Content-Type": "text/html"
leaveHouses: "true"
}
networkPanel.update();
checkIsVisible(networkPanel, {
@ -898,9 +897,6 @@ function testNetworkPanel()
networkPanel = HUDService.openNetworkPanel(filterBox, httpActivity);
networkPanel.isDoneCallback = function NP_doneCallback() {
networkPanel.isDoneCallback = null;
testDriver.next();
}
yield;
checkIsVisible(networkPanel, {
requestBody: false,
@ -917,66 +913,10 @@ function testNetworkPanel()
checkNodeContent(networkPanel, "responseBodyCachedContent", "<body>\u00fc\u00f6\u00E4</body>");
networkPanel.panel.hidePopup();
// Test a response with a content type that can't be displayed in the
// NetworkPanel.
httpActivity.response.header["Content-Type"] = "application/x-shockwave-flash";
networkPanel = HUDService.openNetworkPanel(filterBox, httpActivity);
networkPanel.isDoneCallback = function NP_doneCallback() {
networkPanel.isDoneCallback = null;
testDriver.next();
}
yield;
checkIsVisible(networkPanel, {
requestBody: false,
requestFormData: true,
requestCookie: true,
responseContainer: true,
responseBody: false,
responseBodyCached: false,
responseBodyUnknownType: true,
responseNoBody: false,
responseImage: false,
responseImageCached: false
});
let responseString = HUDService.getFormatStr("NetworkPanel.responseBodyUnableToDisplay.content", ["application/x-shockwave-flash"]);
checkNodeContent(networkPanel, "responseBodyUnknownTypeContent", responseString);
networkPanel.panel.hidePopup();
// Test if the NetworkPanel figures out the content type based on an URL as
// well.
delete httpActivity.response.header["Content-Type"];
httpActivity.url = "http://www.test.com/someCrazyFile.swf?done=right&ending=txt"
networkPanel = HUDService.openNetworkPanel(filterBox, httpActivity);
networkPanel.isDoneCallback = function NP_doneCallback() {
networkPanel.isDoneCallback = null;
testDriver.next();
}
yield;
checkIsVisible(networkPanel, {
requestBody: false,
requestFormData: true,
requestCookie: true,
responseContainer: true,
responseBody: false,
responseBodyCached: false,
responseBodyUnknownType: true,
responseNoBody: false,
responseImage: false,
responseImageCached: false
});
checkNodeContent(networkPanel, "responseBodyUnknownTypeContent", responseString);
networkPanel.panel.hidePopup();
// Run the next test.
testErrorOnPageReload();
}
yield;
};
testDriver = testGen();

View File

@ -1,114 +0,0 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is DevTools test code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* David Dahl <ddahl@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/HUDService.jsm");
const TEST_REPLACED_API_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console-replaced-api.html";
function log(aMsg)
{
dump("*** WebConsoleTest: " + aMsg + "\n");
}
function testOpenWebConsole()
{
HUDService.activateHUDForContext(gBrowser.selectedTab);
is(HUDService.displaysIndex().length, 1, "WebConsole was opened");
hudId = HUDService.displaysIndex()[0];
hud = HUDService.getHeadsUpDisplay(hudId);
HUDService.logWarningAboutReplacedAPI(hudId);
}
function testWarning()
{
const successMsg = "Found the warning message";
const errMsg = "Could not find the warning message about the replaced API";
var display = HUDService.getDisplayByURISpec(content.location.href);
var outputNode = display.querySelectorAll(".hud-output-node")[0];
executeSoon(function () {
testLogEntry(outputNode, "disabled", { success: successMsg, err: errMsg });
});
}
function testLogEntry(aOutputNode, aMatchString, aSuccessErrObj)
{
var message = aOutputNode.textContent.indexOf(aMatchString);
if (message > -1) {
ok(true, aSuccessErrObj.success);
return;
}
ok(false, aSuccessErrObj.err);
}
function finishTest() {
hud = null;
hudId = null;
executeSoon(function() {
finish();
});
}
let hud, hudId, tab, browser, filterBox, outputNode;
let win = gBrowser.selectedBrowser;
tab = gBrowser.selectedTab;
browser = gBrowser.getBrowserForTab(tab);
content.location.href = TEST_REPLACED_API_URI;
function test() {
waitForExplicitFinish();
browser.addEventListener("DOMContentLoaded", function onLoad(event) {
browser.removeEventListener("DOMContentLoaded", onLoad, false);
executeSoon(function (){
testOpenWebConsole();
executeSoon(function (){
testWarning();
});
});
}, false);
finishTest();
}

View File

@ -1,98 +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):
* Patrick Walton <pcwalton@mozilla.com>
*
* ***** END LICENSE BLOCK ***** */
const Cu = Components.utils;
Cu.import("resource://gre/modules/HUDService.jsm");
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html";
function test() {
waitForExplicitFinish();
content.location.href = TEST_URI;
waitForFocus(onFocus);
}
function onFocus() {
let tabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
tabBrowser.addEventListener("DOMContentLoaded",
testSelectionWhenMovingBetweenBoxes, false);
}
function testSelectionWhenMovingBetweenBoxes() {
let tabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
tabBrowser.removeEventListener("DOMContentLoaded",
testSelectionWhenMovingBetweenBoxes, false);
HUDService.activateHUDForContext(gBrowser.selectedTab);
let hudId = HUDService.displaysIndex()[0];
let jsterm = HUDService.hudWeakReferences[hudId].get().jsterm;
// Fill the console with some output.
jsterm.clearOutput();
jsterm.execute("1 + 2");
jsterm.execute("3 + 4");
jsterm.execute("5 + 6");
let outputNode = jsterm.outputNode;
let groupNode = outputNode.querySelector(".hud-group");
ok(groupNode.childNodes.length >= 3, "the output node has children after " +
"executing some JavaScript");
// Test that the global Firefox "Select All" functionality (e.g. Edit >
// Select All) works properly in the Web Console.
let selection = window.getSelection();
selection.removeAllRanges();
let range = document.createRange();
range.selectNode(outputNode.firstChild);
selection.addRange(range);
selection.collapseToStart();
let commandController = window.commandController;
ok(commandController != null, "the window has a command controller object");
commandController.selectAll(outputNode);
for (let i = 0; i < groupNode.childNodes.length; i++) {
ok(selection.containsNode(groupNode.childNodes[i], false),
"HUD message " + i + " is selected after performing a regular " +
"browser select-all operation");
}
selection.removeAllRanges();
// Test the context menu "Select All" (which has a different code path) works
// properly as well.
let contextMenuId = outputNode.getAttribute("context");
let contextMenu = document.getElementById(contextMenuId);
ok(contextMenu != null, "the output node has a context menu");
let selectAllItem = contextMenu.childNodes[1];
ok(selectAllItem != null,
"the context menu on the output node has a \"Select All\" item");
let commandEvent = document.createEvent("XULCommandEvent");
commandEvent.initCommandEvent("command", true, true, window, 0, false, false,
false, false, null);
selectAllItem.dispatchEvent(commandEvent);
for (let i = 0; i < groupNode.childNodes.length; i++) {
ok(selection.containsNode(groupNode.childNodes[i], false),
"HUD message " + i + " is selected after performing a select-all " +
"operation from the context menu");
}
selection.removeAllRanges();
HUDService.deactivateHUDForContext(gBrowser.selectedTab);
finish();
}

View File

@ -1,137 +0,0 @@
/* vim:set ts=2 sw=2 sts=2 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is DevTools test code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mihai Șucan <mihai.sucan@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
Cu.import("resource://gre/modules/HUDService.jsm");
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html";
/**
* 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 testLogEntry(aOutputNode, aMatchString, aSuccessErrObj, aOnlyVisible, aFailIfFound)
{
let found = true;
let notfound = false;
let foundMsg = aSuccessErrObj.success;
let notfoundMsg = aSuccessErrObj.err;
if (aFailIfFound) {
found = false;
notfound = true;
foundMsg = aSuccessErrObj.err;
notfoundMsg = aSuccessErrObj.success;
}
let selector = ".hud-group > *";
// Skip entries that are hidden by the filter.
if (aOnlyVisible) {
selector += ":not(.hud-filtered-by-type)";
}
let msgs = aOutputNode.querySelectorAll(selector);
for (let i = 1, n = msgs.length; i < n; i++) {
let message = msgs[i].textContent.indexOf(aMatchString);
if (message > -1) {
ok(found, foundMsg);
return;
}
}
ok(notfound, notfoundMsg);
}
function onContentLoaded() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
let HUD = HUDService.getDisplayByURISpec(content.location.href);
let hudId = HUD.getAttribute("id");
let filterBox = HUD.querySelector(".hud-filter-box");
let outputNode = HUD.querySelector(".hud-output-node");
let warningFound = "the unknown CSS property warning is displayed";
let warningNotFound = "could not find the unknown CSS property warning";
testLogEntry(outputNode, "foobarCssParser",
{ success: warningFound, err: warningNotFound });
HUDService.setFilterState(hudId, "cssparser", false);
warningNotFound = "the unknown CSS property warning is not displayed, " +
"after filtering";
warningFound = "the unknown CSS property warning is still displayed, " +
"after filtering";
testLogEntry(outputNode, "foobarCssParser",
{ success: warningNotFound, err: warningFound }, true, true);
HUDService.deactivateHUDForContext(gBrowser.selectedTab);
finish();
}
/**
* Unit test for bug 589162:
* CSS filtering on the console does not work
*/
function test() {
waitForExplicitFinish();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
waitForFocus(function () {
HUDService.activateHUDForContext(gBrowser.selectedTab);
gBrowser.selectedBrowser.addEventListener("load", onContentLoaded, true);
content.location = "data:text/html,<div style='font-size:3em;" +
"foobarCssParser:baz'>test CSS parser filter</div>";
});
}, true);
content.location = TEST_URI;
}

View File

@ -1,15 +0,0 @@
<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
<title>Console test replaced API</title>
<script type="text/javascript">
function replaceAPI() {
var console = {log: function (msg){}, info: function (msg){}, warn: function (msg){}, error: function (msg){}};
window.console = console;
}
</script>
</head>
<body>
<h1 id="header">Web Console Replace API Test</h1>
<button onclick="replaceAPI();">ReplaceAPI</button>
</body>
</html>

View File

@ -63,9 +63,6 @@ jsPropertyTitle=Object Inspector
jsPropertyInspectTitle=Inspect: %S
copyCmd.label=Copy
copyCmd.accesskey=C
selectAllCmd.label=Select All
selectAllCmd.accesskey=A
helperFuncUnsupportedTypeError=Can't call pprint on this type of object.
# LOCALIZATION NOTE (networkUrlWithStatus):
#
@ -103,15 +100,3 @@ NetworkPanel.durationMS=%Sms
# The third %S is replaced by the duration between the response header and the
# response body event.
NetworkPanel.imageSizeDeltaDurationMS=%Sx%Spx, Δ%Sms
ConsoleAPIDisabled=The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page.
# LOCALIZATION NOTE (NetworkPanel.responseBodyUnableToDisplay.content):
#
# This string is displayed within the response body section of the NetworkPanel
# if the content type of the network request can't be displayed in the
# NetworkPanel. E.g. any kind of text is easy to display, but some audio or
# flash data received from the server can't be displayed.
#
# The %S is replaced by the content type, that can't be displayed, examples are
# o application/x-shockwave-flash
# o music/crescendo
NetworkPanel.responseBodyUnableToDisplay.content=Unable to display responses of type "%S"

View File

@ -10,7 +10,6 @@
<!ENTITY networkPanel.responseHeaders "Response Headers">
<!ENTITY networkPanel.responseBody "Response Body">
<!ENTITY networkPanel.responseBodyCached "Cached Data">
<!ENTITY networkPanel.responseBodyUnknownType "Unknown Content Type">
<!ENTITY networkPanel.responseNoBody "No Response Body">
<!ENTITY networkPanel.responseImage "Received Image">
<!ENTITY networkPanel.responseImageCached "Cached Image">