InjectedScriptModule.cpp [plain text]
#include "config.h"
#include "InjectedScriptModule.h"
#include "InjectedScript.h"
#include "InjectedScriptManager.h"
#include "ScriptFunctionCall.h"
#include "ScriptObject.h"
namespace Inspector {
InjectedScriptModule::InjectedScriptModule(const String& name)
: InjectedScriptBase(name)
{
}
InjectedScriptModule::~InjectedScriptModule()
{
}
void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, JSC::ExecState* scriptState)
{
InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(scriptState);
ensureInjected(injectedScriptManager, injectedScript);
}
void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, const InjectedScript& injectedScript)
{
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return;
JSC::JSLockHolder locker(injectedScript.scriptState());
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), ASCIILiteral("module"), injectedScriptManager->inspectorEnvironment().functionCallHandler());
function.appendArgument(name());
bool hadException = false;
auto resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
if (hadException || !resultValue || !resultValue.isObject()) {
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), ASCIILiteral("injectModule"), injectedScriptManager->inspectorEnvironment().functionCallHandler());
function.appendArgument(name());
function.appendArgument(source());
function.appendArgument(host(injectedScriptManager, injectedScript.scriptState()));
resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
if (hadException) {
ASSERT_NOT_REACHED();
return;
}
}
}
}