summaryrefslogtreecommitdiffstats
path: root/Source/JavaScriptCore/API
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-24 11:24:40 +0100
committerBen Murdoch <benm@google.com>2011-06-02 09:53:15 +0100
commit81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch)
tree7a9e5ed86ff429fd347a25153107221543909b19 /Source/JavaScriptCore/API
parent94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff)
downloadexternal_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/JavaScriptCore/API')
-rw-r--r--Source/JavaScriptCore/API/JSCallbackConstructor.cpp3
-rw-r--r--Source/JavaScriptCore/API/JSCallbackConstructor.h9
-rw-r--r--Source/JavaScriptCore/API/JSCallbackFunction.cpp3
-rw-r--r--Source/JavaScriptCore/API/JSCallbackFunction.h5
-rw-r--r--Source/JavaScriptCore/API/JSCallbackObject.cpp4
-rw-r--r--Source/JavaScriptCore/API/JSCallbackObject.h5
-rw-r--r--Source/JavaScriptCore/API/JSCallbackObjectFunctions.h4
-rw-r--r--Source/JavaScriptCore/API/JSClassRef.cpp15
-rw-r--r--Source/JavaScriptCore/API/JSClassRef.h2
-rw-r--r--Source/JavaScriptCore/API/JSObjectRef.cpp23
-rw-r--r--Source/JavaScriptCore/API/JSValueRef.cpp4
-rw-r--r--Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp6
-rw-r--r--Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.h3
-rw-r--r--Source/JavaScriptCore/API/tests/testapi.c11
14 files changed, 51 insertions, 46 deletions
diff --git a/Source/JavaScriptCore/API/JSCallbackConstructor.cpp b/Source/JavaScriptCore/API/JSCallbackConstructor.cpp
index 66c6b88..e8ae274 100644
--- a/Source/JavaScriptCore/API/JSCallbackConstructor.cpp
+++ b/Source/JavaScriptCore/API/JSCallbackConstructor.cpp
@@ -36,13 +36,14 @@
namespace JSC {
-const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 };
+const ClassInfo JSCallbackConstructor::s_info = { "CallbackConstructor", &JSObjectWithGlobalObject::s_info, 0, 0 };
JSCallbackConstructor::JSCallbackConstructor(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
: JSObjectWithGlobalObject(globalObject, structure)
, m_class(jsClass)
, m_callback(callback)
{
+ ASSERT(inherits(&s_info));
if (m_class)
JSClassRetain(jsClass);
}
diff --git a/Source/JavaScriptCore/API/JSCallbackConstructor.h b/Source/JavaScriptCore/API/JSCallbackConstructor.h
index a6d64cc..cd307a6 100644
--- a/Source/JavaScriptCore/API/JSCallbackConstructor.h
+++ b/Source/JavaScriptCore/API/JSCallbackConstructor.h
@@ -37,11 +37,11 @@ public:
virtual ~JSCallbackConstructor();
JSClassRef classRef() const { return m_class; }
JSObjectCallAsConstructorCallback callback() const { return m_callback; }
- static const ClassInfo info;
-
+ static const ClassInfo s_info;
+
static PassRefPtr<Structure> createStructure(JSValue proto)
- {
- return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ {
+ return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
protected:
@@ -49,7 +49,6 @@ protected:
private:
virtual ConstructType getConstructData(ConstructData&);
- virtual const ClassInfo* classInfo() const { return &info; }
JSClassRef m_class;
JSObjectCallAsConstructorCallback m_callback;
diff --git a/Source/JavaScriptCore/API/JSCallbackFunction.cpp b/Source/JavaScriptCore/API/JSCallbackFunction.cpp
index c488aa6..28b3419 100644
--- a/Source/JavaScriptCore/API/JSCallbackFunction.cpp
+++ b/Source/JavaScriptCore/API/JSCallbackFunction.cpp
@@ -40,12 +40,13 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction);
-const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 };
+const ClassInfo JSCallbackFunction::s_info = { "CallbackFunction", &InternalFunction::s_info, 0, 0 };
JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const Identifier& name)
: InternalFunction(&exec->globalData(), globalObject, globalObject->callbackFunctionStructure(), name)
, m_callback(callback)
{
+ ASSERT(inherits(&s_info));
}
EncodedJSValue JSCallbackFunction::call(ExecState* exec)
diff --git a/Source/JavaScriptCore/API/JSCallbackFunction.h b/Source/JavaScriptCore/API/JSCallbackFunction.h
index b119b97..d8ae608 100644
--- a/Source/JavaScriptCore/API/JSCallbackFunction.h
+++ b/Source/JavaScriptCore/API/JSCallbackFunction.h
@@ -35,18 +35,17 @@ class JSCallbackFunction : public InternalFunction {
public:
JSCallbackFunction(ExecState*, JSGlobalObject*, JSObjectCallAsFunctionCallback, const Identifier& name);
- static const ClassInfo info;
+ static const ClassInfo s_info;
// InternalFunction mish-mashes constructor and function behavior -- we should
// refactor the code so this override isn't necessary
static PassRefPtr<Structure> createStructure(JSValue proto)
{
- return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
private:
virtual CallType getCallData(CallData&);
- virtual const ClassInfo* classInfo() const { return &info; }
static EncodedJSValue JSC_HOST_CALL call(ExecState*);
diff --git a/Source/JavaScriptCore/API/JSCallbackObject.cpp b/Source/JavaScriptCore/API/JSCallbackObject.cpp
index b8e5843..e3ef7a4 100644
--- a/Source/JavaScriptCore/API/JSCallbackObject.cpp
+++ b/Source/JavaScriptCore/API/JSCallbackObject.cpp
@@ -36,7 +36,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObjectWithGlobalObject>);
ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSGlobalObject>);
// Define the two types of JSCallbackObjects we support.
-template <> const ClassInfo JSCallbackObject<JSObjectWithGlobalObject>::info = { "CallbackObject", 0, 0, 0 };
-template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 };
+template <> const ClassInfo JSCallbackObject<JSObjectWithGlobalObject>::s_info = { "CallbackObject", &JSObjectWithGlobalObject::s_info, 0, 0 };
+template <> const ClassInfo JSCallbackObject<JSGlobalObject>::s_info = { "CallbackGlobalObject", &JSGlobalObject::s_info, 0, 0 };
} // namespace JSC
diff --git a/Source/JavaScriptCore/API/JSCallbackObject.h b/Source/JavaScriptCore/API/JSCallbackObject.h
index f47d0b1..732cc1d 100644
--- a/Source/JavaScriptCore/API/JSCallbackObject.h
+++ b/Source/JavaScriptCore/API/JSCallbackObject.h
@@ -123,14 +123,14 @@ public:
void setPrivate(void* data);
void* getPrivate();
- static const ClassInfo info;
+ static const ClassInfo s_info;
JSClassRef classRef() const { return m_callbackObjectData->jsClass; }
bool inherits(JSClassRef) const;
static PassRefPtr<Structure> createStructure(JSValue proto)
{
- return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), Base::AnonymousSlotCount);
+ return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), Base::AnonymousSlotCount, &s_info);
}
JSValue getPrivateProperty(const Identifier& propertyName) const
@@ -171,7 +171,6 @@ private:
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
- virtual const ClassInfo* classInfo() const { return &info; }
virtual void markChildren(MarkStack& markStack)
{
diff --git a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
index 59373ec..ca15e1f 100644
--- a/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
+++ b/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
@@ -45,7 +45,7 @@ namespace JSC {
template <class Base>
inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValue value)
{
- ASSERT(asObject(value)->inherits(&info));
+ ASSERT(asObject(value)->inherits(&s_info));
return static_cast<JSCallbackObject*>(asObject(value));
}
@@ -54,6 +54,7 @@ JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSGlobalObject* global
: Base(globalObject, structure)
, m_callbackObjectData(adoptPtr(new JSCallbackObjectData(data, jsClass)))
{
+ ASSERT(Base::inherits(&s_info));
init(exec);
}
@@ -64,6 +65,7 @@ JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass, NonNullPassRefPtr<S
: Base(structure)
, m_callbackObjectData(adoptPtr(new JSCallbackObjectData(0, jsClass)))
{
+ ASSERT(Base::inherits(&s_info));
ASSERT(Base::isGlobalObject());
init(static_cast<JSGlobalObject*>(this)->globalExec());
}
diff --git a/Source/JavaScriptCore/API/JSClassRef.cpp b/Source/JavaScriptCore/API/JSClassRef.cpp
index decf493..d953dce 100644
--- a/Source/JavaScriptCore/API/JSClassRef.cpp
+++ b/Source/JavaScriptCore/API/JSClassRef.cpp
@@ -142,19 +142,12 @@ PassRefPtr<OpaqueJSClass> OpaqueJSClass::createNoAutomaticPrototype(const JSClas
return adoptRef(new OpaqueJSClass(definition, 0));
}
-static void clearReferenceToPrototype(JSObjectRef prototype)
-{
- OpaqueJSClassContextData* jsClassData = static_cast<OpaqueJSClassContextData*>(JSObjectGetPrivate(prototype));
- ASSERT(jsClassData);
- jsClassData->cachedPrototype.clear(toJS(prototype));
-}
-
PassRefPtr<OpaqueJSClass> OpaqueJSClass::create(const JSClassDefinition* clientDefinition)
{
JSClassDefinition definition = *clientDefinition; // Avoid modifying client copy.
JSClassDefinition protoDefinition = kJSClassDefinitionEmpty;
- protoDefinition.finalize = clearReferenceToPrototype;
+ protoDefinition.finalize = 0;
swap(definition.staticFunctions, protoDefinition.staticFunctions); // Move static functions to the prototype.
// We are supposed to use JSClassRetain/Release but since we know that we currently have
@@ -163,7 +156,7 @@ PassRefPtr<OpaqueJSClass> OpaqueJSClass::create(const JSClassDefinition* clientD
return adoptRef(new OpaqueJSClass(&definition, protoClass.get()));
}
-OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass)
+OpaqueJSClassContextData::OpaqueJSClassContextData(JSC::JSGlobalData&, OpaqueJSClass* jsClass)
: m_class(jsClass)
{
if (jsClass->m_staticValues) {
@@ -209,7 +202,7 @@ OpaqueJSClassContextData& OpaqueJSClass::contextData(ExecState* exec)
{
OpaqueJSClassContextData*& contextData = exec->globalData().opaqueJSClassData.add(this, 0).first->second;
if (!contextData)
- contextData = new OpaqueJSClassContextData(this);
+ contextData = new OpaqueJSClassContextData(exec->globalData(), this);
return *contextData;
}
@@ -256,7 +249,7 @@ JSObject* OpaqueJSClass::prototype(ExecState* exec)
if (!jsClassData.cachedPrototype) {
// Recursive, but should be good enough for our purposes
- jsClassData.cachedPrototype = new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction
+ jsClassData.cachedPrototype.set(exec->globalData(), new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData), 0); // set jsClassData as the object's private data, so it can clear our reference on destruction
if (parentClass) {
if (JSObject* prototype = parentClass->prototype(exec))
jsClassData.cachedPrototype->setPrototype(prototype);
diff --git a/Source/JavaScriptCore/API/JSClassRef.h b/Source/JavaScriptCore/API/JSClassRef.h
index 0971700..0f4119a 100644
--- a/Source/JavaScriptCore/API/JSClassRef.h
+++ b/Source/JavaScriptCore/API/JSClassRef.h
@@ -69,7 +69,7 @@ struct OpaqueJSClass;
struct OpaqueJSClassContextData {
WTF_MAKE_NONCOPYABLE(OpaqueJSClassContextData); WTF_MAKE_FAST_ALLOCATED;
public:
- OpaqueJSClassContextData(OpaqueJSClass*);
+ OpaqueJSClassContextData(JSC::JSGlobalData&, OpaqueJSClass*);
~OpaqueJSClassContextData();
// It is necessary to keep OpaqueJSClass alive because of the following rare scenario:
diff --git a/Source/JavaScriptCore/API/JSObjectRef.cpp b/Source/JavaScriptCore/API/JSObjectRef.cpp
index d3c1993..36ca338 100644
--- a/Source/JavaScriptCore/API/JSObjectRef.cpp
+++ b/Source/JavaScriptCore/API/JSObjectRef.cpp
@@ -79,7 +79,7 @@ JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
APIEntryShim entryShim(exec);
if (!jsClass)
- return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient
+ return toRef(constructEmptyObject(exec));
JSCallbackObject<JSObjectWithGlobalObject>* object = new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
if (JSObject* prototype = jsClass->prototype(exec))
@@ -340,9 +340,9 @@ void* JSObjectGetPrivate(JSObjectRef object)
{
JSObject* jsObject = toJS(object);
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
- else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
+ if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivate();
return 0;
@@ -352,10 +352,11 @@ bool JSObjectSetPrivate(JSObjectRef object, void* data)
{
JSObject* jsObject = toJS(object);
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
return true;
- } else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
+ }
+ if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivate(data);
return true;
}
@@ -370,9 +371,9 @@ JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSSt
JSObject* jsObject = toJS(object);
JSValue result;
Identifier name(propertyName->identifier(&exec->globalData()));
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
result = static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
- else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
+ else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info))
result = static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivateProperty(name);
return toRef(exec, result);
}
@@ -384,11 +385,11 @@ bool JSObjectSetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRe
JSObject* jsObject = toJS(object);
JSValue jsValue = value ? toJS(exec, value) : JSValue();
Identifier name(propertyName->identifier(&exec->globalData()));
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
return true;
}
- if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
+ if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
return true;
}
@@ -401,11 +402,11 @@ bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStrin
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->globalData()));
- if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
+ if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
- if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
+ if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
diff --git a/Source/JavaScriptCore/API/JSValueRef.cpp b/Source/JavaScriptCore/API/JSValueRef.cpp
index faf4712..e2626be 100644
--- a/Source/JavaScriptCore/API/JSValueRef.cpp
+++ b/Source/JavaScriptCore/API/JSValueRef.cpp
@@ -129,9 +129,9 @@ bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsCla
JSValue jsValue = toJS(exec, value);
if (JSObject* o = jsValue.getObject()) {
- if (o->inherits(&JSCallbackObject<JSGlobalObject>::info))
+ if (o->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(o)->inherits(jsClass);
- else if (o->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
+ if (o->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(o)->inherits(jsClass);
}
return false;
diff --git a/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp b/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp
index 8182075..bc5e383 100644
--- a/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp
+++ b/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp
@@ -57,8 +57,8 @@ void JSWeakObjectMapSet(JSContextRef ctx, JSWeakObjectMapRef map, void* key, JSO
JSObject* obj = toJS(object);
if (!obj)
return;
- ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::info) || obj->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info));
- map->map().set(key, obj);
+ ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::s_info) || obj->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info));
+ map->map().set(exec->globalData(), key, obj);
}
JSObjectRef JSWeakObjectMapGet(JSContextRef ctx, JSWeakObjectMapRef map, void* key)
@@ -73,7 +73,7 @@ bool JSWeakObjectMapClear(JSContextRef ctx, JSWeakObjectMapRef map, void* key, J
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* obj = toJS(object);
- if (map->map().uncheckedRemove(key, obj))
+ if (map->map().deprecatedRemove(key, obj))
return true;
return false;
}
diff --git a/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.h b/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.h
index d36111c..bb3fe96 100644
--- a/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.h
+++ b/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.h
@@ -52,8 +52,7 @@ typedef void (*JSWeakMapDestroyedCallback)(JSWeakObjectMapRef map, void* data);
@param destructor A function to call when the weak map is destroyed.
@result A JSWeakObjectMapRef bound to the given context, data and destructor.
@discussion The JSWeakObjectMapRef can be used as a storage mechanism to hold custom JS objects without forcing those objects to
- remain live as JSValueProtect would. Any objects that are intended to be stored in a weak map must be user defined objects that
- remove themselves from the map in their finalizer.
+ remain live as JSValueProtect would.
*/
JS_EXPORT JSWeakObjectMapRef JSWeakObjectMapCreate(JSContextRef ctx, void* data, JSWeakMapDestroyedCallback destructor);
diff --git a/Source/JavaScriptCore/API/tests/testapi.c b/Source/JavaScriptCore/API/tests/testapi.c
index 1ecfc7e..28d47bb 100644
--- a/Source/JavaScriptCore/API/tests/testapi.c
+++ b/Source/JavaScriptCore/API/tests/testapi.c
@@ -32,6 +32,10 @@
#include <wtf/Assertions.h>
#include <wtf/UnusedParam.h>
+#if OS(WINDOWS)
+#include <windows.h>
+#endif
+
#if COMPILER(MSVC)
#include <wtf/MathExtras.h>
@@ -819,6 +823,13 @@ static bool checkForCycleInPrototypeChain()
int main(int argc, char* argv[])
{
+#if OS(WINDOWS)
+ // Cygwin calls ::SetErrorMode(SEM_FAILCRITICALERRORS), which we will inherit. This is bad for
+ // testing/debugging, as it causes the post-mortem debugger not to be invoked. We reset the
+ // error mode here to work around Cygwin's behavior. See <http://webkit.org/b/55222>.
+ ::SetErrorMode(0);
+#endif
+
const char *scriptPath = "testapi.js";
if (argc > 1) {
scriptPath = argv[1];