Bug 1024054 - Create a previewer for ES6 Symbol. r=past

This commit is contained in:
Nick Fitzgerald 2014-08-25 11:07:00 +02:00
parent d625777813
commit 152c74b8e9
4 changed files with 28 additions and 0 deletions

View File

@ -3209,6 +3209,7 @@ VariablesView.isPrimitive = function(aDescriptor) {
type == "-Infinity" ||
type == "NaN" ||
type == "-0" ||
type == "symbol" ||
type == "longString") {
return true;
}
@ -3426,6 +3427,11 @@ VariablesView.stringifiers.byType = {
}
return null;
},
symbol: function(aGrip, aOptions) {
const name = aGrip.name || "";
return "Symbol(" + name + ")";
},
}; // VariablesView.stringifiers.byType
VariablesView.stringifiers.byObjectClass = {

View File

@ -1129,6 +1129,7 @@ Messages.Extended.prototype = Heritage.extend(Messages.Simple.prototype,
"infinity": "cm-atom",
"null": "cm-atom",
"undefined": "cm-comment",
"symbol": "cm-atom"
};
let className = map[typeof grip];

View File

@ -75,6 +75,24 @@ let inputTests = [
output: "/foobar/",
inspectable: true,
},
// 9
{
input: "Symbol()",
output: "Symbol()"
},
// 10
{
input: "Symbol('foo')",
output: "Symbol(foo)"
},
// 11
{
input: "Symbol.iterator",
output: "Symbol(Symbol.iterator)"
},
];
longString = initialString = null;

View File

@ -1743,6 +1743,9 @@ function JSTermHelpers(aOwner)
aOwner.sandbox.print = function JSTH_print(aValue)
{
aOwner.helperResult = { rawOutput: true };
if (typeof aValue === "symbol") {
return Symbol.prototype.toString.call(aValue);
}
// Waiving Xrays here allows us to see a closer representation of the
// underlying object. This may execute arbitrary content code, but that
// code will run with content privileges, and the result will be rendered