02595c60a3
This reverts commit7dcc8effbd
. Reason for revert: Some flakes still (see comments) and breaks predictable testing: https://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20predictable/builds/11452 Original change's description: > Revert "Revert "Introducing an event loop mechanism for d8."" > > This reverts commitf7c25da680
. > > Reason for revert: Fixed > > Original change's description: > > Revert "Introducing an event loop mechanism for d8." > > > > This reverts commitde964dbe57
. > > > > Reason for revert: > > https://build.chromium.org/p/client.v8/builders/V8%20Linux/builds/17958 > > > > Original change's description: > > > Introducing an event loop mechanism for d8. > > > > > > This mechanism ensures APIs like wasm async complete their work, > > > without requiring use of natives (%APIs). > > > > > > The mechanism is similar to the one used in content_shell, > > > which should allow us to easily port tests in that environment. > > > > > > Review-Url: https://codereview.chromium.org/2842843005 > > > Cr-Original-Commit-Position: refs/heads/master@{#44908} > > > Bug: > > > Change-Id: I9deee0d256a600c60b42902fc8ef8478e5546344 > > > Reviewed-on: https://chromium-review.googlesource.com/494968 > > > Commit-Queue: Mircea Trofin <mtrofin@google.com> > > > Reviewed-by: Jochen Eisinger <jochen@chromium.org> > > > Cr-Commit-Position: refs/heads/master@{#45165} > > > > TBR=bradnelson@chromium.org,mtrofin@chromium.org,mtrofin@google.com,jochen@chromium.org > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > > > Change-Id: Iafec2615d705d1990c57229cab3a988c00b5e12f > > Reviewed-on: https://chromium-review.googlesource.com/498630 > > Reviewed-by: Michael Achenbach <machenbach@chromium.org> > > Commit-Queue: Michael Achenbach <machenbach@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#45166} > > TBR=bradnelson@chromium.org,machenbach@chromium.org,mtrofin@chromium.org,mtrofin@google.com,jochen@chromium.org,v8-reviews@googlegroups.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Change-Id: Ic3c782e918326e291a6cb9bb349c609e9a340b09 > Reviewed-on: https://chromium-review.googlesource.com/498430 > Reviewed-by: Mircea Trofin <mtrofin@chromium.org> > Commit-Queue: Mircea Trofin <mtrofin@google.com> > Cr-Commit-Position: refs/heads/master@{#45172} TBR=bradnelson@chromium.org,machenbach@chromium.org,mtrofin@chromium.org,mtrofin@google.com,jochen@chromium.org,v8-reviews@googlegroups.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I21ffba7141db0bfb4a3275b6e1bf4fb399800ed2 Reviewed-on: https://chromium-review.googlesource.com/500128 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#45177}
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
// We have to patch mjsunit because normal assertion failures just throw
|
|
// exceptions which are swallowed in a then clause.
|
|
failWithMessage = (msg) => %AbortJS(msg);
|
|
|
|
let decrement = () => { %DecrementWaitCount(); }
|
|
let increment = () => { %IncrementWaitCount(); }
|
|
|
|
function WaitForPromise(p) {
|
|
increment();
|
|
p.then(decrement, decrement);
|
|
}
|
|
|
|
function newPromise() {
|
|
var outerResolve;
|
|
var outerReject;
|
|
let promise = new Promise((resolve, reject) => {
|
|
outerResolve = resolve;
|
|
outerReject = reject;
|
|
});
|
|
WaitForPromise(promise); // explicitly wait for promise to resolve.
|
|
return {
|
|
resolve: outerResolve,
|
|
reject: outerReject,
|
|
then: (f, g) => promise.then(f, g)
|
|
};
|
|
}
|
|
|
|
(function ResolveOK() {
|
|
let promise = newPromise();
|
|
promise.then(msg => {print("resolved: " + msg); assertEquals("ok", msg); },
|
|
ex => {print("rejected: " + ex); %AbortJS("" + ex); });
|
|
|
|
promise.resolve("ok");
|
|
promise.reject(11); // ignored
|
|
})();
|
|
|
|
(function RejectOK() {
|
|
let promise = newPromise();
|
|
promise.then(msg => {print("resolved: " + msg); %AbortJS("fail"); },
|
|
ex => {print("rejected: " + ex); assertEquals(42, ex); });
|
|
|
|
promise.reject(42);
|
|
promise.resolve("fail"); // ignored
|
|
})();
|