From bb2b6a828446d53a8aed057412f42c133ec57511 Mon Sep 17 00:00:00 2001 From: David Dahl Date: Thu, 9 Sep 2010 11:01:04 -0700 Subject: [PATCH] backout of leaking changesets r=sheriff a=sheriff --- .../console/hudservice/HUDService.jsm | 313 +----------------- .../console/hudservice/NetworkPanel.xhtml | 7 - .../hudservice/tests/browser/Makefile.in | 5 - .../browser/browser_HUDServiceTestsAll.js | 66 +--- .../browser_warn_user_about_replaced_api.js | 114 ------- ...rowser_webconsole_bug_586388_select_all.js | 98 ------ ...rowser_webconsole_bug_589162_css_filter.js | 137 -------- .../browser/test-console-replaced-api.html | 15 - .../chrome/global/headsUpDisplay.properties | 15 - .../en-US/chrome/global/webConsole.dtd | 1 - 10 files changed, 14 insertions(+), 757 deletions(-) delete mode 100644 toolkit/components/console/hudservice/tests/browser/browser_warn_user_about_replaced_api.js delete mode 100644 toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_586388_select_all.js delete mode 100644 toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_589162_css_filter.js delete mode 100644 toolkit/components/console/hudservice/tests/browser/test-console-replaced-api.html diff --git a/toolkit/components/console/hudservice/HUDService.jsm b/toolkit/components/console/hudservice/HUDService.jsm index 5c6c8ff38ee9..b087ad7a8a68 100644 --- a/toolkit/components/console/hudservice/HUDService.jsm +++ b/toolkit/components/console/hudservice/HUDService.jsm @@ -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 /////////////////////////////////////////////////////////////////////////////// diff --git a/toolkit/components/console/hudservice/NetworkPanel.xhtml b/toolkit/components/console/hudservice/NetworkPanel.xhtml index 24933cf3dc43..a7235de1e891 100644 --- a/toolkit/components/console/hudservice/NetworkPanel.xhtml +++ b/toolkit/components/console/hudservice/NetworkPanel.xhtml @@ -109,13 +109,6 @@ Δ -