Commit eee9fcbc authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[d8] Report errors in setTimeout

If an error is thrown in a setTimeout callback, exit d8 with an error
code.
This will allow us to test asynchronous failures better, see linked bug.

R=yangguo@chromium.org
CC=mathias@chromium.org

Bug: v8:6981
Change-Id: Ifad152e6039f12dc4ceaac0bdc4b87f709898087
Reviewed-on: https://chromium-review.googlesource.com/738372Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49104}
parent c61f9171
......@@ -595,6 +595,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
try_catch.SetVerbose(true);
MaybeLocal<Value> maybe_result;
bool success = true;
{
PerIsolateData* data = PerIsolateData::Get(isolate);
Local<Context> realm =
......@@ -608,7 +609,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
return false;
}
maybe_result = script->Run(realm);
EmptyMessageQueues(isolate);
if (!EmptyMessageQueues(isolate)) success = false;
data->realm_current_ = data->realm_switch_;
}
Local<Value> result;
......@@ -634,7 +635,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
printf("\n");
}
}
return true;
return success;
}
namespace {
......@@ -2910,7 +2911,7 @@ void Shell::SetWaitUntilDone(Isolate* isolate, bool value) {
}
namespace {
void ProcessMessages(Isolate* isolate,
bool ProcessMessages(Isolate* isolate,
std::function<platform::MessageLoopBehavior()> behavior) {
Platform* platform = GetDefaultPlatform();
while (true) {
......@@ -2932,9 +2933,10 @@ void ProcessMessages(Isolate* isolate,
Context::Scope context_scope(context);
if (callback->Call(context, Undefined(isolate), 0, nullptr).IsEmpty()) {
Shell::ReportException(isolate, &try_catch);
return;
return false;
}
}
return true;
}
} // anonymous namespace
......@@ -2948,9 +2950,9 @@ void Shell::CompleteMessageLoop(Isolate* isolate) {
});
}
void Shell::EmptyMessageQueues(Isolate* isolate) {
ProcessMessages(isolate,
[]() { return platform::MessageLoopBehavior::kDoNotWait; });
bool Shell::EmptyMessageQueues(Isolate* isolate) {
return ProcessMessages(
isolate, []() { return platform::MessageLoopBehavior::kDoNotWait; });
}
class Serializer : public ValueSerializer::Delegate {
......
......@@ -358,7 +358,7 @@ class Shell : public i::AllStatic {
static void Exit(int exit_code);
static void OnExit(Isolate* isolate);
static void CollectGarbage(Isolate* isolate);
static void EmptyMessageQueues(Isolate* isolate);
static bool EmptyMessageQueues(Isolate* isolate);
static void EnsureEventLoopInitialized(Isolate* isolate);
static void CompleteMessageLoop(Isolate* isolate);
......
......@@ -305,6 +305,9 @@
'js1_5/Regress/regress-317476': [FAIL],
'js1_5/Regress/regress-314401': [FAIL],
# d8 implements setTimeout, but not clearTimeout.
'js1_5/GC/regress-319980-01': [FAIL],
# Any local 'arguments' variable should not be allowed to shadow the value
# returned via the indirect 'arguments' property accessor.
'js1_4/Functions/function-001': [FAIL_OK],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment