// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "sky/engine/tonic/dart_invoke.h"

#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "sky/engine/tonic/dart_error.h"

namespace blink {

bool DartInvokeAppField(Dart_Handle target, Dart_Handle name,
                               int number_of_arguments,
                               Dart_Handle* arguments) {
  TRACE_EVENT0("sky", "DartInvoke::DartInvokeAppField");
  return LogIfError(Dart_Invoke(target, name, number_of_arguments, arguments));
}

bool DartInvokeAppClosure(Dart_Handle closure,
                          int number_of_arguments,
                          Dart_Handle* arguments) {
  TRACE_EVENT0("sky", "DartInvoke::DartInvokeAppClosure");
  return LogIfError(
      Dart_InvokeClosure(closure, number_of_arguments, arguments));
}

}  // namespace blink

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "sky/engine/tonic/dart_invoke.h"

#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "sky/engine/tonic/dart_error.h"

namespace blink {

bool DartInvokeAppField(Dart_Handle target, Dart_Handle name,
                               int number_of_arguments,
                               Dart_Handle* arguments) {
  TRACE_EVENT0("sky", "DartInvoke::DartInvokeAppField");
  return LogIfError(Dart_Invoke(target, name, number_of_arguments, arguments));
}

bool DartInvokeAppClosure(Dart_Handle closure,
                          int number_of_arguments,
                          Dart_Handle* arguments) {
  TRACE_EVENT0("sky", "DartInvoke::DartInvokeAppClosure");
  Dart_Handle handle = Dart_InvokeClosure(closure, number_of_arguments, arguments);
  bool result = LogIfError(handle);
  CHECK(!Dart_IsCompilationError(handle));
  return result;
}

}  // namespace blink

Check if invocation of a closure failed due to a compilation error
Check if invocation of a closure failed due to a compilation error

This is a fix for bug #1325.  The test framework is running the test code
as a microtask using DartInvokeAppClosure.  If the test causes a compilation
error, the test framework Dart code can not catch it.  The invocation in
sky_shell will return a compilation error handle.  The sky_shell process
will not shut down, and the test framework will hang.

This change will cause sky_shell to shut down on a compilation error in
the test microtask.
