bool VoidCallbackFunctionInterfaceArg::call(ScriptWrappable* scriptWrappable, HTMLDivElement* divElement) {
  if (!m_scriptState->contextIsValid())
    return false;

  ExecutionContext* context = m_scriptState->getExecutionContext();
  DCHECK(context);
  if (context->activeDOMObjectsAreSuspended() || context->activeDOMObjectsAreStopped())
    return false;

  if (m_callback.isEmpty())
    return false;

  // TODO(bashi): Make sure that using TrackExceptionState is OK.
  // crbug.com/653769
  TrackExceptionState exceptionState;
  ScriptState::Scope scope(m_scriptState.get());

  v8::Local<v8::Value> divElementArgument = toV8(divElement, m_scriptState->context()->Global(), m_scriptState->isolate());

  v8::Local<v8::Value> thisValue = toV8(scriptWrappable, m_scriptState->context()->Global(), m_scriptState->isolate());

  v8::Local<v8::Value> argv[] = { divElementArgument };

  v8::Local<v8::Value> v8ReturnValue;
  v8::TryCatch exceptionCatcher(m_scriptState->isolate());
  exceptionCatcher.SetVerbose(true);

  if (V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()), m_scriptState->getExecutionContext(), thisValue, 1, argv, m_scriptState->isolate()).ToLocal(&v8ReturnValue)) {
    return true;
  }
  return false;
}
ScriptPromise Notification::requestPermission(ScriptState* scriptState, NotificationPermissionCallback* deprecatedCallback)
{
    ExecutionContext* context = scriptState->executionContext();
    if (NotificationPermissionClient* permissionClient = NotificationPermissionClient::from(context))
        return permissionClient->requestPermission(scriptState, deprecatedCallback);

    // The context has been detached. Return a promise that will never settle.
    ASSERT(context->activeDOMObjectsAreStopped());
    return ScriptPromise();
}
bool StringSequenceCallbackFunctionLongSequenceArg::call(ScriptState* scriptState, ScriptWrappable* scriptWrappable, const Vector<int>& arg, Vector<String>& returnValue)
{
    if (!scriptState->contextIsValid())
        return false;

    ExecutionContext* context = scriptState->getExecutionContext();
    DCHECK(context);
    if (context->activeDOMObjectsAreSuspended() || context->activeDOMObjectsAreStopped())
        return false;

    if (m_callback.isEmpty())
        return false;

    // TODO(bashi): Make sure that using TrackExceptionState is OK.
    // crbug.com/653769
    TrackExceptionState exceptionState;
    ScriptState::Scope scope(scriptState);

    v8::Local<v8::Value> argArgument = toV8(arg, scriptState->context()->Global(), scriptState->isolate());

    v8::Local<v8::Value> thisValue = toV8(scriptWrappable, scriptState->context()->Global(), scriptState->isolate());

    v8::Local<v8::Value> argv[] = { argArgument };

    v8::Local<v8::Value> v8ReturnValue;
    v8::TryCatch exceptionCatcher(scriptState->isolate());
    exceptionCatcher.SetVerbose(true);

    if (V8ScriptRunner::callFunction(m_callback.newLocal(scriptState->isolate()), scriptState->getExecutionContext(), thisValue, 1, argv, scriptState->isolate()).ToLocal(&v8ReturnValue))
    {
        Vector<String> cppValue = toImplArray<Vector<String>>(v8ReturnValue, 0, scriptState->isolate(), exceptionState);
        if (exceptionState.hadException())
            return false;
        returnValue = cppValue;
        return true;
    }
    return false;
}
bool ActiveDOMCallback::canInvokeCallback() const
{
    ExecutionContext* context = executionContext();
    return context && !context->activeDOMObjectsAreSuspended() && !context->activeDOMObjectsAreStopped();
}