summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2019-03-13 19:03:07 +0200
committerJustOff <Off.Just.Off@gmail.com>2019-03-13 19:03:07 +0200
commite17501d5ebc3eb019905be985a3addf3732b2fef (patch)
tree6fee243abf55f46bd2e44c6b95463f7dbc26529c
parent7d411777a35aedc5cd5f31e58e3d3468a20320b8 (diff)
downloadUXP-e17501d5ebc3eb019905be985a3addf3732b2fef.tar
UXP-e17501d5ebc3eb019905be985a3addf3732b2fef.tar.gz
UXP-e17501d5ebc3eb019905be985a3addf3732b2fef.tar.lz
UXP-e17501d5ebc3eb019905be985a3addf3732b2fef.tar.xz
UXP-e17501d5ebc3eb019905be985a3addf3732b2fef.zip
Change JS to MozMap conversion to more closely follow the record<> spec
-rw-r--r--dom/bindings/Codegen.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
index 378ecf737..1f0f2d9bf 100644
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -4780,8 +4780,11 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
auto& mozMapEntries = ${mozMapRef}.Entries();
JS::Rooted<JSObject*> mozMapObj(cx, &$${val}.toObject());
- JS::Rooted<JS::IdVector> ids(cx, JS::IdVector(cx));
- if (!JS_Enumerate(cx, mozMapObj, &ids)) {
+ JS::AutoIdVector ids(cx);
+ // Keep skipping symbols until
+ // https://github.com/heycam/webidl/issues/294 is sorted out.
+ if (!js::GetPropertyKeys(cx, mozMapObj,
+ JSITER_OWNONLY | JSITER_HIDDEN, &ids)) {
$*{exceptionCode}
}
if (!mozMapEntries.SetCapacity(ids.length(), mozilla::fallible)) {
@@ -4793,14 +4796,29 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
JS::Rooted<jsid> curId(cx);
for (size_t i = 0; i < ids.length(); ++i) {
curId = ids[i];
+
+ MOZ_ASSERT(!JSID_IS_SYMBOL(curId), "No symbols, we said!");
+
+ JS::Rooted<JS::PropertyDescriptor> desc(cx);
+ if (!JS_GetOwnPropertyDescriptorById(cx, mozMapObj, curId,
+ &desc)) {
+ $*{exceptionCode}
+ }
+
+ if (!desc.object() /* == undefined in spec terms */ ||
+ !desc.enumerable()) {
+ continue;
+ }
+
binding_detail::FakeString propName;
bool isSymbol;
- if (!ConvertIdToString(cx, curId, propName, isSymbol) ||
- (!isSymbol && !JS_GetPropertyById(cx, mozMapObj, curId, &temp))) {
+ if (!ConvertIdToString(cx, curId, propName, isSymbol)) {
$*{exceptionCode}
}
- if (isSymbol) {
- continue;
+ MOZ_ASSERT(!isSymbol, "We said, no symbols!");
+
+ if (!JS_GetPropertyById(cx, mozMapObj, curId, &temp)) {
+ $*{exceptionCode}
}
// Safe to do an infallible append here, because we did a