mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1170760 part 3. Add an @@species getter on Promise. r=peterv
This commit is contained in:
parent
6a4cd2a0cf
commit
cd3eff21f4
@ -2979,6 +2979,21 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||
else:
|
||||
unforgeableHolderSetup = None
|
||||
|
||||
if self.descriptor.name == "Promise":
|
||||
speciesSetup = CGGeneric(fill(
|
||||
"""
|
||||
JS::Rooted<JSObject*> promiseConstructor(aCx, *interfaceCache);
|
||||
JS::Rooted<jsid> species(aCx,
|
||||
SYMBOL_TO_JSID(JS::GetWellKnownSymbol(aCx, JS::SymbolCode::species)));
|
||||
if (!JS_DefinePropertyById(aCx, promiseConstructor, species, JS::UndefinedHandleValue,
|
||||
JSPROP_SHARED, Promise::PromiseSpecies, nullptr)) {
|
||||
$*{failureCode}
|
||||
}
|
||||
""",
|
||||
failureCode=failureCode))
|
||||
else:
|
||||
speciesSetup = None
|
||||
|
||||
if (self.descriptor.interface.isOnGlobalProtoChain() and
|
||||
needInterfacePrototypeObject):
|
||||
makeProtoPrototypeImmutable = CGGeneric(fill(
|
||||
@ -3004,7 +3019,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||
return CGList(
|
||||
[getParentProto, CGGeneric(getConstructorProto), initIds,
|
||||
prefCache, CGGeneric(call), defineAliases, unforgeableHolderSetup,
|
||||
makeProtoPrototypeImmutable],
|
||||
speciesSetup, makeProtoPrototypeImmutable],
|
||||
"\n").define()
|
||||
|
||||
|
||||
|
@ -1174,6 +1174,15 @@ Promise::Race(const GlobalObject& aGlobal, JS::Handle<JS::Value> aThisv,
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
Promise::PromiseSpecies(JSContext* aCx, unsigned aArgc, JS::Value* aVp)
|
||||
{
|
||||
JS::CallArgs args = CallArgsFromVp(aArgc, aVp);
|
||||
args.rval().set(args.thisv());
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Promise::AppendNativeHandler(PromiseNativeHandler* aRunnable)
|
||||
{
|
||||
|
@ -198,6 +198,9 @@ public:
|
||||
Race(const GlobalObject& aGlobal, JS::Handle<JS::Value> aThisv,
|
||||
const Sequence<JS::Value>& aIterable, ErrorResult& aRv);
|
||||
|
||||
static bool
|
||||
PromiseSpecies(JSContext* aCx, unsigned aArgc, JS::Value* aVp);
|
||||
|
||||
void AppendNativeHandler(PromiseNativeHandler* aRunnable);
|
||||
|
||||
JSObject* GlobalJSObject() const;
|
||||
|
@ -11,3 +11,4 @@
|
||||
support-files = file_promise_and_timeout_ordering.js
|
||||
[test_promise_and_timeout_ordering_workers.html]
|
||||
support-files = file_promise_and_timeout_ordering.js
|
||||
[test_species_getter.html]
|
||||
|
24
dom/promise/tests/test_species_getter.html
Normal file
24
dom/promise/tests/test_species_getter.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Test for ...</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var desc = Object.getOwnPropertyDescriptor(Promise, Symbol.species);
|
||||
assert_not_equals(desc, undefined, "Should have a property");
|
||||
|
||||
assert_equals(desc.configurable, true, "Property should be configurable");
|
||||
assert_equals(desc.enumerable, false, "Property should not be enumerable");
|
||||
assert_equals(desc.set, undefined, "Should not have a setter");
|
||||
var getter = desc.get;
|
||||
|
||||
var things = [undefined, null, 5, "xyz", Promise, Object];
|
||||
for (var thing of things) {
|
||||
assert_equals(getter.call(thing), thing,
|
||||
"Getter should return its this value");
|
||||
}
|
||||
|
||||
}, "Promise should have an @@species getter that works per spec");
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user