#include "config.h"
#include "V8TestCallbackInterface.h"
+#include "bindings/core/v8/ScriptController.h"
+#include "bindings/core/v8/V8Binding.h"
#include "bindings/tests/v8/V8TestInterfaceEmpty.h"
#include "bindings/tests/v8/V8TestInterfaceWillBeGarbageCollected.h"
-#include "bindings/v8/V8Binding.h"
-#include "bindings/v8/V8Callback.h"
#include "core/dom/ExecutionContext.h"
#include "wtf/Assertions.h"
#include "wtf/GetPtr.h"
#include "wtf/RefPtr.h"
-namespace WebCore {
+namespace blink {
V8TestCallbackInterface::V8TestCallbackInterface(v8::Handle<v8::Function> callback, ScriptState* scriptState)
: ActiveDOMCallback(scriptState->executionContext())
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return;
ScriptState::Scope scope(m_scriptState.get());
v8::Handle<v8::Value> *argv = 0;
- invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 0, argv);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 0, argv, m_scriptState->isolate());
}
bool V8TestCallbackInterface::booleanMethod()
if (!canInvokeCallback())
return true;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return true;
ScriptState::Scope scope(m_scriptState.get());
v8::Handle<v8::Value> *argv = 0;
- return invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 0, argv);
+ v8::TryCatch exceptionCatcher;
+ exceptionCatcher.SetVerbose(true);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 0, argv, m_scriptState->isolate());
+ return !exceptionCatcher.HasCaught();
}
void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg)
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return;
ScriptState::Scope scope(m_scriptState.get());
- v8::Handle<v8::Value> boolArgHandle = v8Boolean(boolArg, isolate);
+ v8::Handle<v8::Value> boolArgHandle = v8Boolean(boolArg, m_scriptState->isolate());
if (boolArgHandle.IsEmpty()) {
if (!isScriptControllerTerminating())
CRASH();
}
v8::Handle<v8::Value> argv[] = { boolArgHandle };
- invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
}
void V8TestCallbackInterface::voidMethodSequenceArg(const Vector<RefPtr<TestInterfaceEmpty> >& sequenceArg)
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return;
ScriptState::Scope scope(m_scriptState.get());
- v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_scriptState->context()->Global(), isolate);
+ v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_scriptState->context()->Global(), m_scriptState->isolate());
if (sequenceArgHandle.IsEmpty()) {
if (!isScriptControllerTerminating())
CRASH();
}
v8::Handle<v8::Value> argv[] = { sequenceArgHandle };
- invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
}
void V8TestCallbackInterface::voidMethodFloatArg(float floatArg)
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return;
ScriptState::Scope scope(m_scriptState.get());
- v8::Handle<v8::Value> floatArgHandle = v8::Number::New(isolate, floatArg);
+ v8::Handle<v8::Value> floatArgHandle = v8::Number::New(m_scriptState->isolate(), floatArg);
if (floatArgHandle.IsEmpty()) {
if (!isScriptControllerTerminating())
CRASH();
}
v8::Handle<v8::Value> argv[] = { floatArgHandle };
- invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
}
void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty* testInterfaceEmptyArg)
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return;
ScriptState::Scope scope(m_scriptState.get());
- v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, m_scriptState->context()->Global(), isolate);
+ v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, m_scriptState->context()->Global(), m_scriptState->isolate());
if (testInterfaceEmptyArgHandle.IsEmpty()) {
if (!isScriptControllerTerminating())
CRASH();
}
v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle };
- invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
}
void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg)
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return;
ScriptState::Scope scope(m_scriptState.get());
- v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, m_scriptState->context()->Global(), isolate);
+ v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, m_scriptState->context()->Global(), m_scriptState->isolate());
if (testInterfaceEmptyArgHandle.IsEmpty()) {
if (!isScriptControllerTerminating())
CRASH();
return;
}
- v8::Handle<v8::Value> stringArgHandle = v8String(isolate, stringArg);
+ v8::Handle<v8::Value> stringArgHandle = v8String(m_scriptState->isolate(), stringArg);
if (stringArgHandle.IsEmpty()) {
if (!isScriptControllerTerminating())
CRASH();
}
v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle, stringArgHandle };
- invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 2, argv);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 2, argv, m_scriptState->isolate());
}
void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptValue thisValue, const String& stringArg)
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return;
CRASH();
return;
}
- v8::Handle<v8::Value> stringArgHandle = v8String(isolate, stringArg);
+ v8::Handle<v8::Value> stringArgHandle = v8String(m_scriptState->isolate(), stringArg);
if (stringArgHandle.IsEmpty()) {
if (!isScriptControllerTerminating())
CRASH();
}
v8::Handle<v8::Value> argv[] = { stringArgHandle };
- invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), thisHandle, 1, argv);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), thisHandle, 1, argv, m_scriptState->isolate());
}
void V8TestCallbackInterface::voidMethodWillBeGarbageCollectedSequenceArg(const WillBeHeapVector<RefPtrWillBeMember<TestInterfaceWillBeGarbageCollected> >& sequenceArg)
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return;
ScriptState::Scope scope(m_scriptState.get());
- v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_scriptState->context()->Global(), isolate);
+ v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_scriptState->context()->Global(), m_scriptState->isolate());
if (sequenceArgHandle.IsEmpty()) {
if (!isScriptControllerTerminating())
CRASH();
}
v8::Handle<v8::Value> argv[] = { sequenceArgHandle };
- invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
}
void V8TestCallbackInterface::voidMethodWillBeGarbageCollectedArrayArg(const WillBeHeapVector<RefPtrWillBeMember<TestInterfaceWillBeGarbageCollected> >& arrayArg)
if (!canInvokeCallback())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
if (m_scriptState->contextIsEmpty())
return;
ScriptState::Scope scope(m_scriptState.get());
- v8::Handle<v8::Value> arrayArgHandle = v8Array(arrayArg, m_scriptState->context()->Global(), isolate);
+ v8::Handle<v8::Value> arrayArgHandle = v8Array(arrayArg, m_scriptState->context()->Global(), m_scriptState->isolate());
if (arrayArgHandle.IsEmpty()) {
if (!isScriptControllerTerminating())
CRASH();
}
v8::Handle<v8::Value> argv[] = { arrayArgHandle };
- invokeCallback(m_scriptState.get(), m_callback.newLocal(isolate), 1, argv);
+ ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate());
}
-} // namespace WebCore
+} // namespace blink