WebCoreSupport needs objects each of which follows major WebCore objects
[WebKit-https.git] / Source / WebCore / testing / v8 / WebCoreTestSupport.cpp
index 28c3729..f4cde6d 100644 (file)
@@ -27,6 +27,7 @@
 #include "WebCoreTestSupport.h"
 
 #include "Document.h"
+#include "InternalSettings.h"
 #include "Internals.h"
 #include "ScriptExecutionContext.h"
 #include "V8Internals.h"
@@ -43,8 +44,8 @@ void injectInternalsObject(v8::Local<v8::Context> context)
     v8::HandleScope scope;
 
     ScriptExecutionContext* scriptContext = getScriptExecutionContext();
-    Document* document = scriptContext->isDocument() ? static_cast<Document*>(scriptContext) : 0;
-    context->Global()->Set(v8::String::New(Internals::internalsId), toV8(Internals::create(document)));
+    if (scriptContext->isDocument())
+        context->Global()->Set(v8::String::New(Internals::internalsId), toV8(Internals::create(static_cast<Document*>(scriptContext))));
 }
 
 void resetInternalsObject(v8::Local<v8::Context> context)
@@ -56,13 +57,9 @@ void resetInternalsObject(v8::Local<v8::Context> context)
     v8::Context::Scope contextScope(context);
     v8::HandleScope scope;
 
-    v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(context->Global()->Get(v8::String::New(Internals::internalsId)));
-    Internals* internals = object->IsUndefined() ? 0 : V8Internals::toNative(object);
-    if (internals) {
-        ScriptExecutionContext* scriptContext = getScriptExecutionContext();
-        if (scriptContext->isDocument())
-            internals->reset(static_cast<Document*>(scriptContext));
-    }
+    ScriptExecutionContext* scriptContext = getScriptExecutionContext();
+    ASSERT(scriptContext->isDocument());
+    InternalSettings::from(static_cast<Document*>(scriptContext)->frame()->page())->reset();
 }
 
 }