Bug 608358 - inspect() and pprint() console helper functions not working on window object, r=gavin, a=blocking2.0

This commit is contained in:
Rob Campbell 2010-11-10 11:10:25 -05:00
Родитель e8af7757f2
Коммит 1dccfbc615
2 изменённых файлов: 30 добавлений и 7 удалений

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

@ -670,6 +670,17 @@ function createAndAppendElement(aParent, aTag, aAttributes)
return node;
}
/**
* Convenience function to unwrap a wrapped object.
*
* @param aObject the object to unwrap
*/
function unwrap(aObject)
{
return XPCNativeWrapper.unwrap(aObject);
}
///////////////////////////////////////////////////////////////////////////
//// NetworkPanel
@ -2929,7 +2940,7 @@ HUD_SERVICE.prototype =
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler.ownerDocument.defaultView;
let xulWindow = XPCNativeWrapper.unwrap(xulWindow);
let xulWindow = unwrap(xulWindow);
let docElem = xulWindow.document.documentElement;
if (!docElem || docElem.getAttribute("windowtype") != "navigator:browser" ||
@ -3813,7 +3824,7 @@ function findCompletionBeginning(aStr)
*/
function JSPropertyProvider(aScope, aInputValue)
{
let obj = XPCNativeWrapper.unwrap(aScope);
let obj = unwrap(aScope);
// Analyse the aInputValue and find the beginning of the last part that
// should be completed.
@ -3981,7 +3992,7 @@ function JSTermHelper(aJSTerm)
aJSTerm.sandbox.keys = function JSTH_keys(aObject)
{
try {
return Object.keys(aObject);
return Object.keys(unwrap(aObject));
}
catch (ex) {
aJSTerm.console.error(ex.message);
@ -3998,10 +4009,11 @@ function JSTermHelper(aJSTerm)
aJSTerm.sandbox.values = function JSTH_values(aObject)
{
let arrValues = [];
let obj = unwrap(aObject);
try {
for (let prop in aObject) {
arrValues.push(aObject[prop]);
for (let prop in obj) {
arrValues.push(obj[prop]);
}
}
catch (ex) {
@ -4019,7 +4031,7 @@ function JSTermHelper(aJSTerm)
*/
aJSTerm.sandbox.inspect = function JSTH_inspect(aObject)
{
aJSTerm.openPropertyPanel(null, aObject);
aJSTerm.openPropertyPanel(null, unwrap(aObject));
};
/**
@ -4036,7 +4048,7 @@ function JSTermHelper(aJSTerm)
return;
}
let output = [];
let pairs = namesAndValuesOf(aObject);
let pairs = namesAndValuesOf(unwrap(aObject));
pairs.forEach(function(pair) {
output.push(" " + pair.display);

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

@ -114,5 +114,16 @@ function testJSTerm()
is(label.textContent.trim().search(/\[object XrayWrapper/), -1,
"check for non-existence of [object XrayWrapper ");
// check that pprint(window) and keys(window) don't throw, bug 608358
jsterm.clearOutput();
jsterm.execute("pprint(window)");
let labels = jsterm.outputNode.querySelectorAll(".jsterm-output-line");
ok(labels.length > 1, "more than one line of output for pprint(window)");
jsterm.clearOutput();
jsterm.execute("keys(window)");
let labels = jsterm.outputNode.querySelectorAll(".jsterm-output-line");
ok(labels.length, "more than 0 lines of output for keys(window)");
finishTest();
}