summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/scripts/test/JS
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/scripts/test/JS')
-rw-r--r--WebCore/bindings/scripts/test/JS/JSTestCallback.cpp36
-rw-r--r--WebCore/bindings/scripts/test/JS/JSTestCallback.h13
-rw-r--r--WebCore/bindings/scripts/test/JS/JSTestObj.cpp105
3 files changed, 107 insertions, 47 deletions
diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp
index 6f6b568..069b8ae 100644
--- a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp
+++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp
@@ -35,18 +35,20 @@ using namespace JSC;
namespace WebCore {
JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
- : m_data(new JSCallbackData(callback, globalObject))
- , m_isolatedWorld(globalObject->world())
- , m_scriptExecutionContext(globalObject->scriptExecutionContext())
+ : ActiveDOMCallback(globalObject->scriptExecutionContext())
+ , m_data(new JSCallbackData(callback, globalObject))
{
}
JSTestCallback::~JSTestCallback()
{
- if (m_scriptExecutionContext->isContextThread())
+ ScriptExecutionContext* context = scriptExecutionContext();
+ // When the context is destroyed, all tasks with a reference to a callback
+ // should be deleted. So if the context is 0, we are on the context thread.
+ if (!context || context->isContextThread())
delete m_data;
else
- m_scriptExecutionContext->postTask(DeleteCallbackDataTask::create(m_data));
+ context->postTask(DeleteCallbackDataTask::create(m_data));
#ifndef NDEBUG
m_data = 0;
#endif
@@ -54,20 +56,16 @@ JSTestCallback::~JSTestCallback()
// Functions
-bool JSTestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param)
+bool JSTestCallback::callbackWithClass1Param(Class1* class1Param)
{
- ASSERT(m_data);
- ASSERT(context);
+ if (!canInvokeCallback())
+ return true;
RefPtr<JSTestCallback> protect(this);
JSLock lock(SilenceAssertionsOnly);
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());
- if (!globalObject)
- return true;
-
- ExecState* exec = globalObject->globalExec();
+ ExecState* exec = m_data->globalObject()->globalExec();
MarkedArgumentBuffer args;
args.append(toJS(exec, class1Param));
@@ -76,20 +74,16 @@ bool JSTestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Cl
return !raisedException;
}
-bool JSTestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg)
+bool JSTestCallback::callbackWithClass2Param(Class2* class2Param, const String& strArg)
{
- ASSERT(m_data);
- ASSERT(context);
+ if (!canInvokeCallback())
+ return true;
RefPtr<JSTestCallback> protect(this);
JSLock lock(SilenceAssertionsOnly);
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());
- if (!globalObject)
- return true;
-
- ExecState* exec = globalObject->globalExec();
+ ExecState* exec = m_data->globalObject()->globalExec();
MarkedArgumentBuffer args;
args.append(toJS(exec, class2Param));
args.append(jsString(exec, strArg));
diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/WebCore/bindings/scripts/test/JS/JSTestCallback.h
index 47a5e95..ae91a6c 100644
--- a/WebCore/bindings/scripts/test/JS/JSTestCallback.h
+++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.h
@@ -23,13 +23,14 @@
#if ENABLE(DATABASE)
+#include "ActiveDOMCallback.h"
#include "JSCallbackData.h"
#include "TestCallback.h"
#include <wtf/Forward.h>
namespace WebCore {
-class JSTestCallback : public TestCallback {
+class JSTestCallback : public TestCallback, public ActiveDOMCallback {
public:
static PassRefPtr<JSTestCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
{
@@ -39,17 +40,15 @@ public:
virtual ~JSTestCallback();
// Functions
- virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param);
- virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg);
- COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param);
- virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param);
+ virtual bool callbackWithClass1Param(Class1* class1Param);
+ virtual bool callbackWithClass2Param(Class2* class2Param, const String& strArg);
+ COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param);
+ virtual int customCallback(Class5* class5Param, Class6* class6Param);
private:
JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*);
JSCallbackData* m_data;
- RefPtr<DOMWrapperWorld> m_isolatedWorld;
- ScriptExecutionContext* m_scriptExecutionContext;
};
} // namespace WebCore
diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
index 9c11bde..01a860c 100644
--- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
+++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
@@ -25,6 +25,7 @@
#include "HTMLNames.h"
#include "IDBBindingUtilities.h"
#include "IDBKey.h"
+#include "JSDOMBinding.h"
#include "JSEventListener.h"
#include "JSTestCallback.h"
#include "JSTestObj.h"
@@ -794,8 +795,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(ExecSt
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
int intArg = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
const String& strArg = ustringToString(exec->argument(1).toString(exec));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
TestObj* objArg = toTestObj(exec->argument(2));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->voidMethodWithArgs(intArg, strArg, objArg);
return JSValue::encode(jsUndefined());
@@ -822,8 +829,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(ExecSta
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
int intArg = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
const String& strArg = ustringToString(exec->argument(1).toString(exec));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
TestObj* objArg = toTestObj(exec->argument(2));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
JSC::JSValue result = jsNumber(exec, imp->intMethodWithArgs(intArg, strArg, objArg));
@@ -851,8 +864,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecSta
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
int intArg = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
const String& strArg = ustringToString(exec->argument(1).toString(exec));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
TestObj* objArg = toTestObj(exec->argument(2));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethodWithArgs(intArg, strArg, objArg)));
@@ -869,7 +888,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs
if (exec->argumentCount() < 2)
return JSValue::encode(jsUndefined());
const String& strArg = ustringToString(exec->argument(0).toString(exec));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
TestObj* objArg = toTestObj(exec->argument(1));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgs(strArg, objArg)));
@@ -887,7 +910,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs
return throwVMError(exec, createSyntaxError(exec, "Not enough arguments"));
ExceptionCode ec = 0;
const String& strArg = ustringToString(exec->argument(0).toString(exec));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
TestObj* objArg = toTestObj(exec->argument(1));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec)));
@@ -903,6 +930,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, exec->argument(0));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->serializedValue(serializedArg);
return JSValue::encode(jsUndefined());
@@ -916,6 +945,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(ExecState* exec)
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
RefPtr<IDBKey> key = createIDBKeyFromValue(exec, exec->argument(0));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->idbKey(key);
return JSValue::encode(jsUndefined());
@@ -963,6 +994,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(Ex
ExceptionCode ec = 0;
ScriptCallStack callStack(exec, 1);
log* intArg = tolog(exec->argument(0));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->customArgsAndException(intArg, &callStack, ec);
setDOMException(exec, ec);
@@ -1023,6 +1056,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(Ex
if (!dynamicFrame)
return JSValue::encode(jsUndefined());
int intArg = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->withDynamicFrameAndArg(dynamicFrame, intArg);
return JSValue::encode(jsUndefined());
@@ -1039,14 +1074,18 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOption
if (!dynamicFrame)
return JSValue::encode(jsUndefined());
int intArg = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
int argsCount = exec->argumentCount();
- if (argsCount < 2) {
+ if (argsCount <= 1) {
imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg);
return JSValue::encode(jsUndefined());
}
int optionalArg = exec->argument(1).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg, optionalArg);
return JSValue::encode(jsUndefined());
@@ -1063,6 +1102,8 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGe
if (!dynamicFrame)
return JSValue::encode(jsUndefined());
int intArg = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture(exec));
return JSValue::encode(jsUndefined());
@@ -1079,14 +1120,18 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGe
if (!dynamicFrame)
return JSValue::encode(jsUndefined());
int intArg = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
int argsCount = exec->argumentCount();
- if (argsCount < 2) {
+ if (argsCount <= 1) {
imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg);
return JSValue::encode(jsUndefined());
}
int optionalArg = exec->argument(1).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture(exec));
return JSValue::encode(jsUndefined());
@@ -1174,12 +1219,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(Exe
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
int argsCount = exec->argumentCount();
- if (argsCount < 1) {
+ if (argsCount <= 0) {
imp->methodWithOptionalArg();
return JSValue::encode(jsUndefined());
}
int opt = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->methodWithOptionalArg(opt);
return JSValue::encode(jsUndefined());
@@ -1193,14 +1240,18 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
int nonOpt = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
int argsCount = exec->argumentCount();
- if (argsCount < 2) {
+ if (argsCount <= 1) {
imp->methodWithNonOptionalArgAndOptionalArg(nonOpt);
return JSValue::encode(jsUndefined());
}
int opt = exec->argument(1).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt);
return JSValue::encode(jsUndefined());
@@ -1214,15 +1265,21 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
int nonOpt = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
int argsCount = exec->argumentCount();
- if (argsCount < 2) {
+ if (argsCount <= 1) {
imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt);
return JSValue::encode(jsUndefined());
}
int opt1 = exec->argument(1).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
int opt2 = exec->argument(2).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2);
return JSValue::encode(jsUndefined());
@@ -1237,7 +1294,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(Exe
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) {
setDOMException(exec, TYPE_MISMATCH_ERR);
- return jsUndefined();
+ return JSValue::encode(jsUndefined());
}
RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject());
@@ -1253,9 +1310,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgA
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
int nonCallback = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
if (exec->argumentCount() <= 1 || !exec->argument(1).isObject()) {
setDOMException(exec, TYPE_MISMATCH_ERR);
- return jsUndefined();
+ return JSValue::encode(jsUndefined());
}
RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(1)), castedThis->globalObject());
@@ -1270,18 +1329,14 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAndOpti
return throwVMTypeError(exec);
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
-
- int argsCount = exec->argumentCount();
- if (argsCount < 1) {
- imp->methodWithCallbackAndOptionalArg();
- return JSValue::encode(jsUndefined());
- }
-
- if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) {
- setDOMException(exec, TYPE_MISMATCH_ERR);
- return jsUndefined();
+ RefPtr<TestCallback> callback;
+ if (exec->argumentCount() > 0 && !exec->argument(0).isNull() && !exec->argument(0).isUndefined()) {
+ if (!exec->argument(0).isObject()) {
+ setDOMException(exec, TYPE_MISMATCH_ERR);
+ return JSValue::encode(jsUndefined());
+ }
+ callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject());
}
- RefPtr<TestCallback> callback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject());
imp->methodWithCallbackAndOptionalArg(callback);
return JSValue::encode(jsUndefined());
@@ -1295,7 +1350,11 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
TestObj* objArg = toTestObj(exec->argument(0));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
const String& strArg = ustringToString(exec->argument(1).toString(exec));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->overloadedMethod(objArg, strArg);
return JSValue::encode(jsUndefined());
@@ -1309,14 +1368,18 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2(
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
TestObj* objArg = toTestObj(exec->argument(0));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
int argsCount = exec->argumentCount();
- if (argsCount < 2) {
+ if (argsCount <= 1) {
imp->overloadedMethod(objArg);
return JSValue::encode(jsUndefined());
}
int intArg = exec->argument(1).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->overloadedMethod(objArg, intArg);
return JSValue::encode(jsUndefined());
@@ -1330,6 +1393,8 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3(
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
const String& strArg = ustringToString(exec->argument(0).toString(exec));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->overloadedMethod(strArg);
return JSValue::encode(jsUndefined());
@@ -1343,6 +1408,8 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4(
JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
TestObj* imp = static_cast<TestObj*>(castedThis->impl());
int intArg = exec->argument(0).toInt32(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
imp->overloadedMethod(intArg);
return JSValue::encode(jsUndefined());