Title: [198531] trunk/Source/_javascript_Core
- Revision
- 198531
- Author
- [email protected]
- Date
- 2016-03-22 10:01:04 -0700 (Tue, 22 Mar 2016)
Log Message
[JSC] allow duplicate property names returned from Proxy ownKeys() trap
https://bugs.webkit.org/show_bug.cgi?id=155560
Patch by Caitlin Potter <[email protected]> on 2016-03-22
Reviewed by Darin Adler.
Specification allows duplicate property names to be reported by the
Proxy ownKeys() trap --- and this is observable in any API which
operates on the returned list, such as Object.keys(),
Object.getOwnPropertyNames(), Object.getOwnPropertySymbols(), or
Object.getOwnPropertyDescriptors().
* runtime/PropertyNameArray.h:
(JSC::PropertyNameArray::addUnchecked):
(JSC::PropertyNameArray::add):
(JSC::PropertyNameArray::addKnownUnique): Deleted.
* runtime/ProxyObject.cpp:
(JSC::ProxyObject::performGetOwnPropertyNames):
* runtime/Structure.cpp:
(JSC::Structure::getPropertyNamesFromStructure):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (198530 => 198531)
--- trunk/Source/_javascript_Core/ChangeLog 2016-03-22 16:02:22 UTC (rev 198530)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-03-22 17:01:04 UTC (rev 198531)
@@ -1,3 +1,25 @@
+2016-03-22 Caitlin Potter <[email protected]>
+
+ [JSC] allow duplicate property names returned from Proxy ownKeys() trap
+ https://bugs.webkit.org/show_bug.cgi?id=155560
+
+ Reviewed by Darin Adler.
+
+ Specification allows duplicate property names to be reported by the
+ Proxy ownKeys() trap --- and this is observable in any API which
+ operates on the returned list, such as Object.keys(),
+ Object.getOwnPropertyNames(), Object.getOwnPropertySymbols(), or
+ Object.getOwnPropertyDescriptors().
+
+ * runtime/PropertyNameArray.h:
+ (JSC::PropertyNameArray::addUnchecked):
+ (JSC::PropertyNameArray::add):
+ (JSC::PropertyNameArray::addKnownUnique): Deleted.
+ * runtime/ProxyObject.cpp:
+ (JSC::ProxyObject::performGetOwnPropertyNames):
+ * runtime/Structure.cpp:
+ (JSC::Structure::getPropertyNamesFromStructure):
+
2016-03-21 Yusuke Suzuki <[email protected]>
[JSC] Clean up Math.floor thunk and use SSE round instruction
Modified: trunk/Source/_javascript_Core/runtime/PropertyNameArray.h (198530 => 198531)
--- trunk/Source/_javascript_Core/runtime/PropertyNameArray.h 2016-03-22 16:02:22 UTC (rev 198530)
+++ trunk/Source/_javascript_Core/runtime/PropertyNameArray.h 2016-03-22 17:01:04 UTC (rev 198531)
@@ -69,7 +69,7 @@
void add(const Identifier&);
void add(UniquedStringImpl*);
- void addKnownUnique(UniquedStringImpl*);
+ void addUnchecked(UniquedStringImpl*);
Identifier& operator[](unsigned i) { return m_data->propertyNameVector()[i]; }
const Identifier& operator[](unsigned i) const { return m_data->propertyNameVector()[i]; }
@@ -103,7 +103,7 @@
add(identifier.impl());
}
-ALWAYS_INLINE void PropertyNameArray::addKnownUnique(UniquedStringImpl* identifier)
+ALWAYS_INLINE void PropertyNameArray::addUnchecked(UniquedStringImpl* identifier)
{
if (!isUidMatchedToTypeMode(identifier))
return;
@@ -131,7 +131,7 @@
return;
}
- addKnownUnique(identifier);
+ addUnchecked(identifier);
}
ALWAYS_INLINE bool PropertyNameArray::isUidMatchedToTypeMode(UniquedStringImpl* identifier)
Modified: trunk/Source/_javascript_Core/runtime/ProxyObject.cpp (198530 => 198531)
--- trunk/Source/_javascript_Core/runtime/ProxyObject.cpp 2016-03-22 16:02:22 UTC (rev 198530)
+++ trunk/Source/_javascript_Core/runtime/ProxyObject.cpp 2016-03-22 17:01:04 UTC (rev 198531)
@@ -878,7 +878,7 @@
++uncheckedResultKeys.add(ident.impl(), 0).iterator->value;
++totalSize;
- trapResult.add(ident.impl());
+ trapResult.addUnchecked(ident.impl());
return dontExitEarly;
};
Modified: trunk/Source/_javascript_Core/runtime/Structure.cpp (198530 => 198531)
--- trunk/Source/_javascript_Core/runtime/Structure.cpp 2016-03-22 16:02:22 UTC (rev 198530)
+++ trunk/Source/_javascript_Core/runtime/Structure.cpp 2016-03-22 17:01:04 UTC (rev 198531)
@@ -1060,7 +1060,7 @@
if (iter->key->isSymbol() && !propertyNames.includeSymbolProperties())
continue;
if (knownUnique)
- propertyNames.addKnownUnique(iter->key);
+ propertyNames.addUnchecked(iter->key);
else
propertyNames.add(iter->key);
}
Added: trunk/Source/_javascript_Core/tests/es6/Proxy_ownKeys_duplicates.js (0 => 198531)
--- trunk/Source/_javascript_Core/tests/es6/Proxy_ownKeys_duplicates.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/es6/Proxy_ownKeys_duplicates.js 2016-03-22 17:01:04 UTC (rev 198531)
@@ -0,0 +1,25 @@
+function test() {
+
+var symbol = Symbol("test");
+var proxy = new Proxy({}, {
+ ownKeys: function (t) {
+ return ["A", "A", "0", "0", symbol, symbol];
+ }
+});
+var keys = Object.keys(proxy);
+var names = Object.getOwnPropertyNames(proxy);
+var symbols = Object.getOwnPropertySymbols(proxy);
+
+if (keys.length === 4 && keys[0] === keys[1] && keys[2] === keys[3] &&
+ keys[0] === "A" && keys[2] === "0" &&
+ names.length === 4 && names[0] === names[1] && names[2] === names[3] &&
+ names[0] === "A" && names[2] === "0" &&
+ symbols.length === 2 && symbols[0] === symbols[1] && symbols[0] === symbol)
+ return true;
+return false;
+
+}
+
+if (!test())
+ throw new Error("Test failed");
+
Modified: trunk/Source/_javascript_Core/tests/es6.yaml (198530 => 198531)
--- trunk/Source/_javascript_Core/tests/es6.yaml 2016-03-22 16:02:22 UTC (rev 198530)
+++ trunk/Source/_javascript_Core/tests/es6.yaml 2016-03-22 17:01:04 UTC (rev 198531)
@@ -1062,6 +1062,8 @@
cmd: runES6 :normal
- path: es6/Proxy_ownKeys_handler.js
cmd: runES6 :normal
+- path: es6/Proxy_ownKeys_duplicates.js
+ cmd: runES6 :normal
- path: es6/Proxy_preventExtensions_handler.js
cmd: runES6 :normal
- path: es6/Proxy_Proxy.revocable.js
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes