WebCoreTestSupport.cpp [plain text]
#include "config.h"
#include "WebCoreTestSupport.h"
#include "Frame.h"
#include "InternalSettings.h"
#include "Internals.h"
#include "JSDocument.h"
#include "JSInternals.h"
#include <JavaScriptCore/APICast.h>
#include <interpreter/CallFrame.h>
#include <runtime/IdentifierInlines.h>
using namespace JSC;
using namespace WebCore;
namespace WebCoreTestSupport {
void injectInternalsObject(JSContextRef context)
{
ExecState* exec = toJS(context);
JSLockHolder lock(exec);
JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
if (scriptContext->isDocument())
globalObject->putDirect(exec->vm(), Identifier(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create(toDocument(scriptContext))));
}
void resetInternalsObject(JSContextRef context)
{
ExecState* exec = toJS(context);
JSLockHolder lock(exec);
JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
Page* page = toDocument(scriptContext)->frame()->page();
Internals::resetToConsistentState(page);
InternalSettings::from(page)->resetToConsistentState();
}
}