Bug 837630 - Stop hiding __proto__ from O.getOwnPropertyNames. r=Waldo,peterv,past

This commit is contained in:
Tom Schuster 2015-03-19 17:42:15 +01:00
Родитель 8106721a08
Коммит 2de182147c
6 изменённых файлов: 22 добавлений и 30 удалений

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

@ -50,9 +50,9 @@ let consoleOpened = Task.async(function*(aHud) {
// 4 values, and the following properties:
// __defineGetter__ __defineSetter__ __lookupGetter__ __lookupSetter__
// hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString
// toSource unwatch valueOf watch constructor.
is(popup.itemCount, 18, "popup.itemCount is correct");
// __proto__ hasOwnProperty isPrototypeOf propertyIsEnumerable
// toLocaleString toString toSource unwatch valueOf watch constructor.
is(popup.itemCount, 19, "popup.itemCount is correct");
let sameItems = popup.getItems().reverse().map(function(e) {return e.label;});
ok(sameItems.every(function(prop, index) {
@ -61,6 +61,7 @@ let consoleOpened = Task.async(function*(aHud) {
"__defineSetter__",
"__lookupGetter__",
"__lookupSetter__",
"__proto__",
"constructor",
"hasOwnProperty",
"isPrototypeOf",
@ -77,7 +78,7 @@ let consoleOpened = Task.async(function*(aHud) {
"watch",
][index] === prop}), "getItems returns the items we expect");
is(popup.selectedIndex, 17,
is(popup.selectedIndex, 18,
"Index of the first item from bottom is selected.");
EventUtils.synthesizeKey("VK_DOWN", {});
@ -115,7 +116,7 @@ let consoleOpened = Task.async(function*(aHud) {
ok(popup.selectedIndex < currentSelectionIndex, "Index is less after Page UP");
EventUtils.synthesizeKey("VK_END", {});
is(popup.selectedIndex, 17, "index is last after End");
is(popup.selectedIndex, 18, "index is last after End");
EventUtils.synthesizeKey("VK_HOME", {});
is(popup.selectedIndex, 0, "index is first after Home");
@ -152,9 +153,9 @@ function popupHideAfterTab()
ok(popup.isOpen, "popup is open");
is(popup.itemCount, 18, "popup.itemCount is correct");
is(popup.itemCount, 19, "popup.itemCount is correct");
is(popup.selectedIndex, 17, "First index from bottom is selected");
is(popup.selectedIndex, 18, "First index from bottom is selected");
EventUtils.synthesizeKey("VK_DOWN", {});
let prefix = jsterm.inputNode.value.replace(/[\S]/g, " ");
@ -201,9 +202,9 @@ function testReturnKey()
ok(popup.isOpen, "popup is open");
is(popup.itemCount, 18, "popup.itemCount is correct");
is(popup.itemCount, 19, "popup.itemCount is correct");
is(popup.selectedIndex, 17, "First index from bottom is selected");
is(popup.selectedIndex, 18, "First index from bottom is selected");
EventUtils.synthesizeKey("VK_DOWN", {});
let prefix = jsterm.inputNode.value.replace(/[\S]/g, " ");

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

@ -7,9 +7,6 @@
<script>
test(function() {
var props = Object.getOwnPropertyNames(Object.prototype);
// getOwnPropertyNames intentionally filters out the non-standard
// "__proto__" property.
props.push("__proto__");
// If you change this list, make sure it continues to match the list in
// Codegen.py's CGDictionary.getMemberDefinition method.
var expected = [

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

@ -98,15 +98,6 @@ static inline bool
Enumerate(JSContext *cx, HandleObject pobj, jsid id,
bool enumerable, unsigned flags, Maybe<IdSet>& ht, AutoIdVector *props)
{
// We implement __proto__ using a property on |Object.prototype|, but
// because __proto__ is highly deserving of removal, we don't want it to
// show up in property enumeration, even if only for |Object.prototype|
// (think introspection by Prototype-like frameworks that add methods to
// the built-in prototypes). So exclude __proto__ if the object where the
// property was found has no [[Prototype]] and might be |Object.prototype|.
if (MOZ_UNLIKELY(!pobj->getTaggedProto().isObject() && JSID_IS_ATOM(id, cx->names().proto)))
return true;
if (!(flags & JSITER_OWNONLY) || pobj->is<ProxyObject>() || pobj->getOps()->enumerate) {
if (!ht) {
ht.emplace(cx);

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

@ -4,10 +4,8 @@
*/
//-----------------------------------------------------------------------------
var BUGNUMBER = 690031;
var summary =
'Exclude __proto__ from showing up when enumerating properties of ' +
'Object.prototype again';
var BUGNUMBER = 837630;
var summary ='__proto__ should show up with O.getOwnPropertyNames(O.prototype)';
print(BUGNUMBER + ": " + summary);
@ -16,8 +14,8 @@ print(BUGNUMBER + ": " + summary);
**************/
var keys = Object.getOwnPropertyNames(Object.prototype);
assertEq(keys.indexOf("__proto__"), -1,
"shouldn't have gotten __proto__ as a property of Object.prototype " +
assertEq(keys.indexOf("__proto__") >= 0, true,
"should have gotten __proto__ as a property of Object.prototype " +
"(got these properties: " + keys + ")");
/******************************************************************************/

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

@ -160,11 +160,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
"toLocaleDateString", "toLocaleTimeString", "toDateString", "toTimeString",
"toISOString", "toJSON", "toSource", "toString", "valueOf", "constructor",
"toGMTString"];
gPrototypeProperties['Object'] = /* __proto__ is intentionally excluded here, because
the JS engine filters it out of getOwnPropertyNames */
gPrototypeProperties['Object'] =
["constructor", "toSource", "toString", "toLocaleString", "valueOf", "watch",
"unwatch", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable",
"__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"];
"__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__",
"__proto__"];
gPrototypeProperties['Array'] =
["length", "toSource", "toString", "toLocaleString", "join", "reverse", "sort", "push",
"pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf",

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

@ -3440,6 +3440,11 @@ ObjectActor.prototype = {
continue;
}
// Ignore __proto__ on Object.prototye.
if (!obj.proto && name == "__proto__") {
continue;
}
let desc = null, getter = null;
try {
desc = obj.getOwnPropertyDescriptor(name);