diff options
author | Moonchild <moonchild@palemoon.org> | 2020-09-23 23:45:46 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-09-23 23:45:46 +0000 |
commit | 9f5c27ba479c54d4ebb1bd59b61fbf793f6df93f (patch) | |
tree | 831e0ae1649d6135429def03688bc93ff7c86b03 /js | |
parent | 42f895f27f239e973c9c06241f7a58da7381353c (diff) | |
parent | f624bd1375655dea196cdcb70a9860bc5817df49 (diff) | |
download | UXP-RELBASE_20200929.tar UXP-RELBASE_20200929.tar.gz UXP-RELBASE_20200929.tar.lz UXP-RELBASE_20200929.tar.xz UXP-RELBASE_20200929.zip |
Merge branch 'redwood' into releaseRELBASE_20200929RC_20200924
Diffstat (limited to 'js')
-rw-r--r-- | js/src/builtin/Object.cpp | 1 | ||||
-rw-r--r-- | js/src/builtin/Object.js | 18 | ||||
-rw-r--r-- | js/src/jsapi.cpp | 6 | ||||
-rw-r--r-- | js/xpconnect/tests/chrome/test_xrayToJS.xul | 4 |
4 files changed, 24 insertions, 5 deletions
diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp index bfcc8d20e..d3001b69e 100644 --- a/js/src/builtin/Object.cpp +++ b/js/src/builtin/Object.cpp @@ -1239,6 +1239,7 @@ static const JSFunctionSpec object_static_methods[] = { JS_FN("isFrozen", obj_isFrozen, 1, 0), JS_FN("seal", obj_seal, 1, 0), JS_FN("isSealed", obj_isSealed, 1, 0), + JS_SELF_HOSTED_FN("fromEntries", "ObjectFromEntries", 1, 0), JS_FS_END }; diff --git a/js/src/builtin/Object.js b/js/src/builtin/Object.js index 9ed1be0e1..c4739037e 100644 --- a/js/src/builtin/Object.js +++ b/js/src/builtin/Object.js @@ -202,3 +202,21 @@ function ObjectLookupGetter(name) { // Step 3.d. (implicit) } + +// Stage 4 draft 2020-09-06 https://tc39.github.io/proposal-object-from-entries/ +// Object.fromEntries (iterable) +function ObjectFromEntries(iter) { + // We omit the usual step number comments here because they don't help. + // This implementation inlines AddEntriesFromIterator and + // CreateDataPropertyOnObject, so it looks more like the polyfill + // than the step-by-step spec algorithm. + const obj = {}; + + for (const pair of allowContentIter(iter)) { + if (!IsObject(pair)) + ThrowTypeError(JSMSG_INVALID_MAP_ITERABLE, "Object.fromEntries"); + _DefineDataProperty(obj, pair[0], pair[1]); + } + + return obj; +} diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 69a3ba2ac..c0f0e61cc 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4708,7 +4708,7 @@ JS::ModuleInstantiate(JSContext* cx, JS::HandleObject moduleArg) { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); - assertSameCompartment(cx, moduleArg); + releaseAssertSameCompartment(cx, moduleArg); return ModuleObject::Instantiate(cx, moduleArg.as<ModuleObject>()); } @@ -4717,7 +4717,7 @@ JS::ModuleEvaluate(JSContext* cx, JS::HandleObject moduleArg) { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); - assertSameCompartment(cx, moduleArg); + releaseAssertSameCompartment(cx, moduleArg); return ModuleObject::Evaluate(cx, moduleArg.as<ModuleObject>()); } @@ -6204,7 +6204,7 @@ JS_SetPendingException(JSContext* cx, HandleValue value) { AssertHeapIsIdle(cx); CHECK_REQUEST(cx); - assertSameCompartment(cx, value); + releaseAssertSameCompartment(cx, value); cx->setPendingException(value); } diff --git a/js/xpconnect/tests/chrome/test_xrayToJS.xul b/js/xpconnect/tests/chrome/test_xrayToJS.xul index 38f3f447d..d1cc3e26c 100644 --- a/js/xpconnect/tests/chrome/test_xrayToJS.xul +++ b/js/xpconnect/tests/chrome/test_xrayToJS.xul @@ -190,9 +190,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681 constructorProps(["setPrototypeOf", "getOwnPropertyDescriptor", "getOwnPropertyDescriptors", "keys", "is", "defineProperty", "defineProperties", "create", "getOwnPropertyNames", "getOwnPropertySymbols", - "preventExtensions", "freeze", "isFrozen", "seal", + "preventExtensions", "freeze", "fromEntries", "isFrozen", "seal", "isSealed", "assign", "getPrototypeOf", "values", - "entries", "isExtensible"]) + "entries", "isExtensible"]); gPrototypeProperties['Array'] = ["length", "toSource", "toString", "toLocaleString", "join", "reverse", "sort", "push", "pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf", |