Skip to content

Commit

Permalink
Improve how to serialize fulfilled promise status
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=225328

Reviewed by Patrick Angle.

While the `[[PromiseStatus]]` enum matches the spec to have `fulfilled`
status, WebKit is translating it to `resolved` which doesn't match the
spec[1]. Thus, this commit will make `fulfilled` status to be serialized
as `fulfilled` instead of `resolved`.

[1]: https://tc39.es/ecma262/#sec-properties-of-promise-instances

* LayoutTests/inspector/model/remote-object/promise-expected.txt:
* LayoutTests/inspector/runtime/getDisplayableProperties-expected.txt:
* LayoutTests/inspector/runtime/getProperties-expected.txt:
* Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::getInternalProperties):

Canonical link: https://commits.webkit.org/266058@main
  • Loading branch information
CYBAI authored and rcaliman-apple committed Jul 14, 2023
1 parent e51b17e commit 359976c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ EXPRESSION: Promise.resolve()
{
"_name": "status",
"_type": "string",
"_value": "resolved",
"_value": "fulfilled",
"_internal": true
},
{
Expand Down Expand Up @@ -124,7 +124,7 @@ EXPRESSION: Promise.resolve({result:1})
{
"_name": "status",
"_type": "string",
"_value": "resolved",
"_value": "fulfilled",
"_internal": true
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Getting displayable properties...
Properties:
"__proto__" => "Promise" (object) [writable | configurable | isOwn]
Internal Properties:
"status" => "resolved" (string) []
"status" => "fulfilled" (string) []
"result" => 123 (number) []

-- Running test case: Runtime.getDisplayableProperties.Promise.Rejected
Expand Down
2 changes: 1 addition & 1 deletion LayoutTests/inspector/runtime/getProperties-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Getting own properties...
Properties:
"__proto__" => "Promise" (object) [writable | configurable | isOwn]
Internal Properties:
"status" => "resolved" (string) []
"status" => "fulfilled" (string) []
"result" => 123 (number) []

-- Running test case: Runtime.getProperties.Promise.Rejected
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ JSValue JSInjectedScriptHost::getInternalProperties(JSGlobalObject* globalObject
array->putDirectIndex(globalObject, index++, constructInternalProperty(globalObject, "status"_s, jsNontrivialString(vm, "pending"_s)));
return array;
case JSPromise::Status::Fulfilled:
array->putDirectIndex(globalObject, index++, constructInternalProperty(globalObject, "status"_s, jsNontrivialString(vm, "resolved"_s)));
array->putDirectIndex(globalObject, index++, constructInternalProperty(globalObject, "status"_s, jsNontrivialString(vm, "fulfilled"_s)));
RETURN_IF_EXCEPTION(scope, JSValue());
scope.release();
array->putDirectIndex(globalObject, index++, constructInternalProperty(globalObject, "result"_s, promise->result(vm)));
Expand Down

0 comments on commit 359976c

Please sign in to comment.