Add isPromise V8 extras util
This is used by streams in
https://streams.spec.whatwg.org/commit-snapshots/1375e266b2fe8246bd95cb9d8a49876ba9359dc9/#rs-pipe-through
This also fixes an omission in a6e635d692
that did not properly update the
%OptimizeObjectForAddingMultipleProperties call in prologue.js.
BUG=chromium:668951
R=gsathya@chromium.org,littledan@chromium.org
Review-Url: https://codereview.chromium.org/2796243002
Cr-Commit-Position: refs/heads/master@{#44442}
This commit is contained in:
parent
8b380d518e
commit
0d25fee308
@ -4214,6 +4214,8 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
|
||||
factory()->NewStringFromAsciiChecked("createPromise"));
|
||||
InstallFunction(extras_utils, isolate()->promise_resolve(),
|
||||
factory()->NewStringFromAsciiChecked("resolvePromise"));
|
||||
InstallFunction(extras_utils, isolate()->is_promise(),
|
||||
factory()->NewStringFromAsciiChecked("isPromise"));
|
||||
|
||||
int builtin_index = Natives::GetDebuggerCount();
|
||||
// Only run prologue.js and runtime.js at this point.
|
||||
|
@ -168,7 +168,7 @@ utils.PostNatives = PostNatives;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
%OptimizeObjectForAddingMultipleProperties(extrasUtils, 7);
|
||||
%OptimizeObjectForAddingMultipleProperties(extrasUtils, 11);
|
||||
|
||||
extrasUtils.logStackTrace = function logStackTrace() {
|
||||
%DebugTrace();
|
||||
|
@ -25492,6 +25492,17 @@ TEST(ExtrasUtilsObject) {
|
||||
.As<v8::String>();
|
||||
String::Utf8Value promise_states_string(promise_states);
|
||||
CHECK_EQ(0, strcmp(*promise_states_string, "pending fulfilled rejected"));
|
||||
|
||||
auto promise_is_promise = result->Get(env.local(), v8_str("promiseIsPromise"))
|
||||
.ToLocalChecked()
|
||||
.As<v8::Boolean>();
|
||||
CHECK_EQ(true, promise_is_promise->Value());
|
||||
|
||||
auto thenable_is_promise =
|
||||
result->Get(env.local(), v8_str("thenableIsPromise"))
|
||||
.ToLocalChecked()
|
||||
.As<v8::Boolean>();
|
||||
CHECK_EQ(false, thenable_is_promise->Value());
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,7 +93,9 @@
|
||||
fulfilledPromise2, // should be fulfilled with 2
|
||||
rejectedPromise, // should be rejected with 3
|
||||
rejectedButHandledPromise, // should be rejected but have a handler
|
||||
promiseStates // should be the string "pending fulfilled rejected"
|
||||
promiseStates, // should be the string "pending fulfilled rejected"
|
||||
promiseIsPromise: v8.isPromise(fulfilledPromise), // should be true
|
||||
thenableIsPromise: v8.isPromise({ then() { } }) // should be false
|
||||
};
|
||||
};
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user