[Pkg-mozext-commits] [firebug] 14/35: Issue 7396 (XHR requests don't apply to other filters) http://code.google.com/p/fbug/issues/detail?id=7396
David Prévot
taffit at moszumanska.debian.org
Sat May 24 14:54:27 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository firebug.
commit 835f94a0f772eb2ee1c3649cc738cd78e274f09d
Author: Sebastian Zartner <sebastianzartner at gmail.com>
Date: Mon Apr 28 15:10:11 2014 +0200
Issue 7396 (XHR requests don't apply to other filters)
http://code.google.com/p/fbug/issues/detail?id=7396
Part 2: Allow to add multiple categories for a request
---
extension/content/firebug/net/netPanel.js | 54 ++++++++++++++++++-------------
extension/content/firebug/net/netReps.js | 19 +++++------
extension/content/firebug/net/netUtils.js | 49 ++++++++++++++++++++--------
3 files changed, 77 insertions(+), 45 deletions(-)
diff --git a/extension/content/firebug/net/netPanel.js b/extension/content/firebug/net/netPanel.js
index fcebfe1..8fcf152 100644
--- a/extension/content/firebug/net/netPanel.js
+++ b/extension/content/firebug/net/netPanel.js
@@ -387,16 +387,19 @@ NetPanel.prototype = Obj.extend(ActivablePanel,
}
);
- if (NetUtils.textFileCategories.hasOwnProperty(file.category))
+ file.categories.forEach((category) =>
{
- items.push(
- {
- label: "CopyResponse",
- tooltiptext: "net.tip.Copy_Response",
- command: Obj.bindFixed(this.copyResponse, this, file)
- }
- );
- }
+ if (category in NetUtils.textFileCategories)
+ {
+ items.push(
+ {
+ label: "CopyResponse",
+ tooltiptext: "net.tip.Copy_Response",
+ command: Obj.bindFixed(this.copyResponse, this, file)
+ }
+ );
+ }
+ });
items.push(
{
@@ -416,16 +419,19 @@ NetPanel.prototype = Obj.extend(ActivablePanel,
}
);
- if (NetUtils.textFileCategories.hasOwnProperty(file.category))
+ file.categories.forEach((category) =>
{
- items.push(
- {
- label: "Open_Response_In_New_Tab",
- tooltiptext: "net.tip.Open_Response_In_New_Tab",
- command: Obj.bindFixed(NetUtils.openResponseInTab, this, file)
- }
- );
- }
+ if (category in NetUtils.textFileCategories)
+ {
+ items.push(
+ {
+ label: "Open_Response_In_New_Tab",
+ tooltiptext: "net.tip.Open_Response_In_New_Tab",
+ command: Obj.bindFixed(NetUtils.openResponseInTab, this, file)
+ }
+ );
+ }
+ });
items.push("-");
@@ -1006,11 +1012,12 @@ NetPanel.prototype = Obj.extend(ActivablePanel,
if (file.mimeType)
{
- // Force update category.
- file.category = null;
+ // Force update categories
+ file.categories = null;
for (var category in NetUtils.fileCategories)
- Css.removeClass(row, "category-" + category);
- Css.setClass(row, "category-" + NetUtils.getFileCategory(file));
+ row.classList.remove("category-" + category);
+ var categories = NetUtils.getFileCategories(file);
+ categories.forEach((category) => row.classList.add("category-" + category));
}
var remoteIPLabel = row.querySelector(".netRemoteAddressCol .netAddressLabel");
@@ -1262,7 +1269,8 @@ NetPanel.prototype = Obj.extend(ActivablePanel,
if (!Options.get("netShowBFCacheResponses") && file.fromBFCache)
continue;
- if (!categories || categories.indexOf(file.category) != -1)
+ if (!categories || (file.categories && file.categories.some((category) =>
+ categories.indexOf(category) !== -1)))
{
if (file.loaded)
{
diff --git a/extension/content/firebug/net/netReps.js b/extension/content/firebug/net/netReps.js
index 9919c48..cce1c28 100644
--- a/extension/content/firebug/net/netReps.js
+++ b/extension/content/firebug/net/netReps.js
@@ -410,7 +410,7 @@ Firebug.NetMonitor.NetRequestEntry = domplate(Rep, new EventSource(),
{
fileTag:
FOR("file", "$files",
- TR({"class": "netRow $file.file|getCategory focusRow outerFocusRow",
+ TR({"class": "netRow $file.file|getCategories focusRow outerFocusRow",
onclick: "$onClick", "role": "row", "aria-expanded": "false",
$hasHeaders: "$file.file|hasRequestHeaders",
$history: "$file.file.history",
@@ -474,7 +474,7 @@ Firebug.NetMonitor.NetRequestEntry = domplate(Rep, new EventSource(),
),
netInfoTag:
- TR({"class": "netInfoRow $file|getCategory outerFocusRow", "role" : "row"},
+ TR({"class": "netInfoRow $file|getCategories outerFocusRow", "role" : "row"},
TD({"class": "sourceLine netRowHeader"}),
TD({"class": "netInfoCol", colspan: 8, "role" : "gridcell"})
),
@@ -602,11 +602,11 @@ Firebug.NetMonitor.NetRequestEntry = domplate(Rep, new EventSource(),
}
},
- getCategory: function(file)
+ getCategories: function(file)
{
- var category = NetUtils.getFileCategory(file);
- if (category)
- return "category-" + category;
+ var categories = NetUtils.getFileCategories(file);
+ if (categories.length !== 0)
+ return categories.map((category) => "category-" + category).join(" ");
return "category-undefined";
},
@@ -952,7 +952,8 @@ Firebug.NetMonitor.NetInfoBody = domplate(Rep, new EventSource(),
return headers[i].value == 0;
}
- return file.category in NetUtils.binaryFileCategories || file.responseText == "";
+ return (file.categories && file.categories.some((category) => category in NetUtils.binaryFileCategories)) ||
+ file.responseText == "";
},
hideHtml: function(file)
@@ -1147,7 +1148,7 @@ Firebug.NetMonitor.NetInfoBody = domplate(Rep, new EventSource(),
FBTrace.sysout("netInfoResponseTab", {netInfoBox: netInfoBox, file: file});
if (!netInfoBox.responsePresented)
{
- if (file.category == "image")
+ if (file.categories && file.categories.indexOf("image") !== -1)
{
netInfoBox.responsePresented = true;
@@ -1157,7 +1158,7 @@ Firebug.NetMonitor.NetInfoBody = domplate(Rep, new EventSource(),
Dom.clearNode(responseTextBox);
responseTextBox.appendChild(responseImage, responseTextBox);
}
- else if (!(NetUtils.binaryCategoryMap.hasOwnProperty(file.category)))
+ else if (!file.categories || !file.categories.some((category) => category in NetUtils.binaryCategoryMap))
{
this.setResponseText(file, netInfoBox, responseTextBox, context);
}
diff --git a/extension/content/firebug/net/netUtils.js b/extension/content/firebug/net/netUtils.js
index eadce17..cb125dc 100644
--- a/extension/content/firebug/net/netUtils.js
+++ b/extension/content/firebug/net/netUtils.js
@@ -367,24 +367,45 @@ var NetUtils =
},
/**
- * Returns a category for specific request (file). The logic is as follows:
- * 1) Use file-extension to guess the mime type. This is prefered since
- * mime-types in HTTP requests are often wrong.
- * This part is based on mimeExtensionMap map.
- * 2) If the file extension is missing or unknown, try to get the mime-type
+ * Returns the most appropriate category for a specific request (file).
+ * The logic is as follows:
+ * 1) If the request is an XHR, return 'xhr' as category
+ * 2) Otherwise use the file extension to guess the MIME type.
+ * This is prefered since MIME types in HTTP requests are often wrong.
+ * This part is based on the 'mimeExtensionMap' map.
+ * 3) If the file extension is missing or unknown, try to get the MIME type
* from the HTTP request object.
- * 3) If there is still no mime-type, return empty category name.
- * 4) Use the mime-type and look up the right category.
- * This part is based on mimeCategoryMap map.
+ * 4) If there is still no MIME type, return an empty category name.
+ * 5) Use the MIME type and look up the right category.
+ * This part is based on the 'mimeCategoryMap' map.
*/
getFileCategory: function(file)
{
- if (file.category)
- return file.category;
+ return this.getFileCategories(file)[0];
+ },
+
+ /**
+ * Returns the categories for a specific request (file).
+ * The logic is as follows:
+ * 1) If the request is an XHR, add 'xhr' as category
+ * 2) Use the file extension to guess the MIME type.
+ * This is prefered since MIME types in HTTP requests are often wrong.
+ * This part is based on the 'mimeExtensionMap' map.
+ * 3) If the file extension is missing or unknown, try to get the MIME type
+ * from the HTTP request object.
+ * 4) If there is still no MIME type, return an empty category name.
+ * 5) Use the MIME type and look up the right category.
+ * This part is based on the 'mimeCategoryMap' map.
+ */
+ getFileCategories: function(file)
+ {
+ if (file.categories)
+ return file.categories;
+ var categories = [];
// All XHRs have its own category.
if (file.isXHR)
- return file.category = "xhr";
+ categories.push("xhr");
// Guess mime-type according to the file extension. Using file extension
// is prefered way since mime-types in HTTP requests are often wrong.
@@ -397,10 +418,12 @@ var NetUtils =
// No mime-type, no category.
if (!mimeType)
- return "";
+ return categories;
// Finally, get the category according to the mime type.
- return file.category = mimeCategoryMap[mimeType];
+ categories.push(mimeCategoryMap[mimeType]);
+
+ return file.categories = categories;
},
getCategory: function(mimeType)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git
More information about the Pkg-mozext-commits
mailing list