Backout of bug 575789 and bug 589089 due to oranges, a=#developers

This commit is contained in:
Rob Campbell 2010-08-31 17:04:23 -03:00
Родитель 5c79da4781
Коммит 0e8c0c45f3
7 изменённых файлов: 31 добавлений и 474 удалений

Просмотреть файл

@ -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);
@ -83,11 +79,6 @@ XPCOMUtils.defineLazyGetter(this, "PropertyPanel", function () {
return obj.PropertyPanel;
});
XPCOMUtils.defineLazyGetter(this, "namesAndValuesOf", function () {
var obj = {};
Cu.import("resource://gre/modules/PropertyPanel.jsm", obj);
return obj.namesAndValuesOf;
});
function LogFactory(aMessagePrefix)
{
@ -508,76 +499,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"
}
}
@ -728,39 +649,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, null, null);
if (uri instanceof Ci.nsIURL) {
if (uri.fileExtension) {
return mimeService.getTypeFromExtension(uri.fileExtension);
}
}
return null;
},
/**
*
* @returns boolean
@ -768,34 +656,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) {
return true;
}
switch (NetworkHelper.mimeCategoryMap[contentType]) {
case "txt":
case "js":
case "json":
case "css":
case "html":
case "svg":
case "xml":
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;
default:
}
else {
return false;
}
}
return response.header["Content-Type"].indexOf("image/") != -1;
},
/**
@ -1077,26 +949,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.
@ -1181,10 +1033,6 @@ NetworkPanel.prototype =
this._displayResponseImage();
this._callIsDone();
}
else if (!this._isResponseBodyTextData) {
this._displayResponseBodyUnknownType();
this._callIsDone();
}
else if (response.body) {
this._displayResponseBody();
this._callIsDone();
@ -3626,171 +3474,6 @@ function JSPropertyProvider(aScope, aInputValue)
// JSTerm
//////////////////////////////////////////////////////////////////////////
/**
* JSTermHelper
*
* Defines a set of functions ("helper functions") that are available from the
* WebConsole but not from the webpage.
* A list of helper functions used by Firebug can be found here:
* http://getfirebug.com/wiki/index.php/Command_Line_API
*/
function JSTermHelper(aJSTerm)
{
return {
/**
* Returns the result of document.getElementById(aId).
*
* @param string aId
* A string that is passed to window.document.getElementById.
* @returns nsIDOMNode or null
*/
$: function JSTH_$(aId)
{
try {
return aJSTerm._window.document.getElementById(aId);
}
catch (ex) {
aJSTerm.console.error(ex.message);
}
},
/**
* Returns the result of document.querySelectorAll(aSelector).
*
* @param string aSelector
* A string that is passed to window.document.querySelectorAll.
* @returns array of nsIDOMNode
*/
$$: function JSTH_$$(aSelector)
{
try {
return aJSTerm._window.document.querySelectorAll(aSelector);
}
catch (ex) {
aJSTerm.console.error(ex.message);
}
},
/**
* Runs a xPath query and returns all matched nodes.
*
* @param string aXPath
* xPath search query to execute.
* @param [optional] nsIDOMNode aContext
* Context to run the xPath query on. Uses window.document if not set.
* @returns array of nsIDOMNode
*/
$x: function JSTH_$x(aXPath, aContext)
{
let nodes = [];
let doc = aJSTerm._window.wrappedJSObject.document;
let aContext = aContext || doc;
try {
let results = doc.evaluate(aXPath, aContext, null,
Ci.nsIDOMXPathResult.ANY_TYPE, null);
let node;
while (node = results.iterateNext()) {
nodes.push(node);
}
}
catch (ex) {
aJSTerm.console.error(ex.message);
}
return nodes;
},
/**
* Clears the output of the JSTerm.
*/
clear: function JSTH_clear()
{
aJSTerm.clearOutput();
},
/**
* Returns the result of Object.keys(aObject).
*
* @param object aObject
* Object to return the property names from.
* @returns array of string
*/
keys: function JSTH_keys(aObject)
{
try {
return Object.keys(XPCNativeWrapper.unwrap(aObject));
}
catch (ex) {
aJSTerm.console.error(ex.message);
}
},
/**
* Returns the values of all properties on aObject.
*
* @param object aObject
* Object to display the values from.
* @returns array of string
*/
values: function JSTH_values(aObject)
{
let arrValues = [];
let obj = XPCNativeWrapper.unwrap(aObject);
try {
for (let prop in obj) {
arrValues.push(obj[prop]);
}
}
catch (ex) {
aJSTerm.console.error(ex.message);
}
return arrValues;
},
/**
* Inspects the passed aObject. This is done by opening the PropertyPanel.
*
* @param object aObject
* Object to inspect.
* @returns void
*/
inspect: function JSTH_inspect(aObject)
{
let obj = XPCNativeWrapper.unwrap(aObject);
aJSTerm.openPropertyPanel(null, obj);
},
/**
* Prints aObject to the output.
*
* @param object aObject
* Object to print to the output.
* @returns void
*/
pprint: function JSTH_pprint(aObject)
{
if (aObject === null || aObject === undefined || aObject === true || aObject === false) {
aJSTerm.console.error(HUDService.getStr("helperFuncUnsupportedTypeError"));
return;
}
let output = [];
if (typeof aObject != "string") {
aObject = XPCNativeWrapper.unwrap(aObject);
}
let pairs = namesAndValuesOf(aObject);
pairs.forEach(function(pair) {
output.push(" " + pair.display);
});
aJSTerm.writeOutput(output.join("\n"));
}
}
}
/**
* JSTerm
*
@ -3879,7 +3562,6 @@ JSTerm.prototype = {
this.sandbox = new Cu.Sandbox(this._window);
this.sandbox.window = this._window;
this.sandbox.console = this.console;
this.sandbox.__helperFunctions__ = JSTermHelper(this);
this.sandbox.__proto__ = this._window.wrappedJSObject;
},
@ -3898,7 +3580,7 @@ JSTerm.prototype = {
*/
evalInSandbox: function JST_evalInSandbox(aString)
{
let execStr = "with(__helperFunctions__) { with(window) {" + aString + "} }";
let execStr = "with(window) {" + aString + "}";
return Cu.evalInSandbox(execStr, this.sandbox, "default", "HUD Console", 1);
},

Просмотреть файл

@ -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;

Просмотреть файл

@ -44,7 +44,7 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
var EXPORTED_SYMBOLS = ["PropertyPanel", "PropertyTreeView", "namesAndValuesOf"];
var EXPORTED_SYMBOLS = ["PropertyPanel", "PropertyTreeView"];
///////////////////////////////////////////////////////////////////////////
//// Helper for PropertyTreeView

Просмотреть файл

@ -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,84 +897,26 @@ function testNetworkPanel()
networkPanel = HUDService.openNetworkPanel(filterBox, httpActivity);
networkPanel.isDoneCallback = function NP_doneCallback() {
networkPanel.isDoneCallback = null;
testDriver.next();
checkIsVisible(networkPanel, {
requestBody: false,
requestFormData: true,
requestCookie: true,
responseContainer: true,
responseBody: false,
responseBodyCached: true,
responseNoBody: false,
responseImage: false,
responseImageCached: false
});
checkNodeContent(networkPanel, "responseBodyCachedContent", "<body>\u00fc\u00f6\u00E4</body>");
networkPanel.panel.hidePopup();
// Run the next test.
testErrorOnPageReload();
}
yield;
checkIsVisible(networkPanel, {
requestBody: false,
requestFormData: true,
requestCookie: true,
responseContainer: true,
responseBody: false,
responseBodyCached: true,
responseNoBody: false,
responseImage: false,
responseImageCached: false
});
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
});
checkNodeContent(networkPanel, "responseBodyUnknownTypeContent", "Unable to display responses of type \"application/x-shockwave-flash\"");
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", "Unable to display responses of type \"application/x-shockwave-flash\"");
networkPanel.panel.hidePopup();
// Run the next test.
testErrorOnPageReload();
};
testDriver = testGen();
@ -1108,51 +1049,6 @@ function testExecutionScope()
"command was executed in the window scope");
}
function testJSTermHelper()
{
content.location.href = TEST_URI;
let HUD = HUDService.hudWeakReferences[hudId].get();
let jsterm = HUD.jsterm;
jsterm.clearOutput();
jsterm.execute("'id=' + $('header').getAttribute('id')");
let group = jsterm.outputNode.querySelector(".hud-group");
is(group.childNodes[2].textContent, "id=header", "$() worked");
jsterm.clearOutput();
jsterm.execute("headerQuery = $$('h1')");
jsterm.execute("'length=' + headerQuery.length");
let group = jsterm.outputNode.querySelector(".hud-group");
is(group.childNodes[4].textContent, "length=1", "$$() worked");
jsterm.clearOutput();
jsterm.execute("xpathQuery = $x('.//*', document.body);");
jsterm.execute("'headerFound=' + (xpathQuery[0] == headerQuery[0])");
let group = jsterm.outputNode.querySelector(".hud-group");
is(group.childNodes[4].textContent, "headerFound=true", "$x() worked");
// no jsterm.clearOutput() here as we clear the output using the clear() fn.
jsterm.execute("clear()");
let group = jsterm.outputNode.querySelector(".hud-group");
is(group.childNodes[1].textContent, "undefined", "clear() worked");
jsterm.clearOutput();
jsterm.execute("'keysResult=' + (keys({b:1})[0] == 'b')");
let group = jsterm.outputNode.querySelector(".hud-group");
is(group.childNodes[2].textContent, "keysResult=true", "keys() worked");
jsterm.clearOutput();
jsterm.execute("'valuesResult=' + (values({b:1})[0] == 1)");
let group = jsterm.outputNode.querySelector(".hud-group");
is(group.childNodes[2].textContent, "valuesResult=true", "values() worked");
jsterm.clearOutput();
jsterm.execute("pprint({b:2, a:1})");
let group = jsterm.outputNode.querySelector(".hud-group");
is(group.childNodes[2].textContent, " a: 1\n b: 2", "pprint() worked");
}
function testPropertyPanel()
{
var HUD = HUDService.hudWeakReferences[hudId].get();
@ -1481,7 +1377,6 @@ function test() {
testPropertyProvider();
testJSInputExpand();
testPropertyPanel();
testJSTermHelper();
// NOTE: Put any sync test above this comment.
//

Просмотреть файл

@ -16,7 +16,7 @@
</script>
</head>
<body>
<h1 id="header">Heads Up Display Demo</h1>
<h1>Heads Up Display Demo</h1>
<button onclick="test();">Log stuff about Dolske</button>
</body>
</html>

Просмотреть файл

@ -63,7 +63,6 @@ jsPropertyTitle=Object Inspector
jsPropertyInspectTitle=Inspect: %S
copyCmd.label=Copy
copyCmd.accesskey=C
helperFuncUnsupportedTypeError=Can't call pprint on this type of object.
# LOCALIZATION NOTE (networkUrlWithStatus):
#
# When the HTTP request is started only the URL of the request is printed to the
@ -100,14 +99,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
# 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"

Просмотреть файл

@ -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">