summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/inspector/InjectedScriptManager.cpp')
-rw-r--r--Source/JavaScriptCore/inspector/InjectedScriptManager.cpp63
1 files changed, 25 insertions, 38 deletions
diff --git a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
index 812ad3d75..72d20df3e 100644
--- a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
+++ b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
@@ -12,7 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
@@ -31,6 +31,8 @@
#include "config.h"
#include "InjectedScriptManager.h"
+#if ENABLE(INSPECTOR)
+
#include "Completion.h"
#include "InjectedScriptHost.h"
#include "InjectedScriptSource.h"
@@ -58,13 +60,7 @@ InjectedScriptManager::~InjectedScriptManager()
void InjectedScriptManager::disconnect()
{
discardInjectedScripts();
-}
-
-void InjectedScriptManager::discardInjectedScripts()
-{
- m_injectedScriptHost->clearAllWrappers();
- m_idToInjectedScript.clear();
- m_scriptStateToId.clear();
+ m_injectedScriptHost = nullptr;
}
InjectedScriptHost* InjectedScriptManager::injectedScriptHost()
@@ -99,36 +95,33 @@ int InjectedScriptManager::injectedScriptIdFor(ExecState* scriptState)
InjectedScript InjectedScriptManager::injectedScriptForObjectId(const String& objectId)
{
- RefPtr<InspectorValue> parsedObjectId;
- if (!InspectorValue::parseJSON(objectId, parsedObjectId))
- return InjectedScript();
-
- RefPtr<InspectorObject> resultObject;
- if (!parsedObjectId->asObject(resultObject))
- return InjectedScript();
-
- long injectedScriptId = 0;
- if (!resultObject->getInteger(ASCIILiteral("injectedScriptId"), injectedScriptId))
- return InjectedScript();
+ RefPtr<InspectorValue> parsedObjectId = InspectorValue::parseJSON(objectId);
+ if (parsedObjectId && parsedObjectId->type() == InspectorValue::TypeObject) {
+ long injectedScriptId = 0;
+ bool success = parsedObjectId->asObject()->getNumber(ASCIILiteral("injectedScriptId"), &injectedScriptId);
+ if (success)
+ return m_idToInjectedScript.get(injectedScriptId);
+ }
- return m_idToInjectedScript.get(injectedScriptId);
+ return InjectedScript();
}
-void InjectedScriptManager::releaseObjectGroup(const String& objectGroup)
+void InjectedScriptManager::discardInjectedScripts()
{
- for (auto& injectedScript : m_idToInjectedScript.values())
- injectedScript.releaseObjectGroup(objectGroup);
+ m_injectedScriptHost->clearAllWrappers();
+ m_idToInjectedScript.clear();
+ m_scriptStateToId.clear();
}
-void InjectedScriptManager::clearExceptionValue()
+void InjectedScriptManager::releaseObjectGroup(const String& objectGroup)
{
- for (auto& injectedScript : m_idToInjectedScript.values())
- injectedScript.clearExceptionValue();
+ for (auto it = m_idToInjectedScript.begin(); it != m_idToInjectedScript.end(); ++it)
+ it->value.releaseObjectGroup(objectGroup);
}
String InjectedScriptManager::injectedScriptSource()
{
- return StringImpl::createWithoutCopying(InjectedScriptSource_js, sizeof(InjectedScriptSource_js));
+ return String(reinterpret_cast<const char*>(InjectedScriptSource_js), sizeof(InjectedScriptSource_js));
}
Deprecated::ScriptObject InjectedScriptManager::createInjectedScript(const String& source, ExecState* scriptState, int id)
@@ -139,9 +132,9 @@ Deprecated::ScriptObject InjectedScriptManager::createInjectedScript(const Strin
JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
JSValue globalThisValue = scriptState->globalThisValue();
- NakedPtr<Exception> evaluationException;
+ JSValue evaluationException;
InspectorEvaluateHandler evaluateHandler = m_environment.evaluateHandler();
- JSValue functionValue = evaluateHandler(scriptState, sourceCode, globalThisValue, evaluationException);
+ JSValue functionValue = evaluateHandler(scriptState, sourceCode, globalThisValue, &evaluationException);
if (evaluationException)
return Deprecated::ScriptObject();
@@ -151,12 +144,11 @@ Deprecated::ScriptObject InjectedScriptManager::createInjectedScript(const Strin
return Deprecated::ScriptObject();
MarkedArgumentBuffer args;
- args.append(m_injectedScriptHost->wrapper(scriptState, globalObject));
+ args.append(m_injectedScriptHost->jsWrapper(scriptState, globalObject));
args.append(globalThisValue);
args.append(jsNumber(id));
JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args);
- scriptState->clearException();
if (result.isObject())
return Deprecated::ScriptObject(scriptState, result.getObject());
@@ -177,22 +169,17 @@ InjectedScript InjectedScriptManager::injectedScriptFor(ExecState* inspectedExec
int id = injectedScriptIdFor(inspectedExecState);
Deprecated::ScriptObject injectedScriptObject = createInjectedScript(injectedScriptSource(), inspectedExecState, id);
- if (injectedScriptObject.scriptState() != inspectedExecState) {
- WTFLogAlways("Failed to parse/execute InjectedScriptSource.js!");
- WTFLogAlways("%s\n", injectedScriptSource().ascii().data());
- RELEASE_ASSERT_NOT_REACHED();
- }
-
InjectedScript result(injectedScriptObject, &m_environment);
m_idToInjectedScript.set(id, result);
didCreateInjectedScript(result);
return result;
}
-void InjectedScriptManager::didCreateInjectedScript(const InjectedScript&)
+void InjectedScriptManager::didCreateInjectedScript(InjectedScript)
{
// Intentionally empty. This allows for subclasses to inject additional scripts.
}
} // namespace Inspector
+#endif // ENABLE(INSPECTOR)