summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-05-20 09:56:07 +0000
commit41386e9cb918eed93b3f13648cbef387e371e451 (patch)
treea97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
parente15dd966d523731101f70ccf768bba12435a0208 (diff)
downloadWebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/inspector/InjectedScriptManager.cpp')
-rw-r--r--Source/JavaScriptCore/inspector/InjectedScriptManager.cpp43
1 files changed, 18 insertions, 25 deletions
diff --git a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
index 1bac2ecbd..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,6 +60,7 @@ InjectedScriptManager::~InjectedScriptManager()
void InjectedScriptManager::disconnect()
{
discardInjectedScripts();
+ m_injectedScriptHost = nullptr;
}
InjectedScriptHost* InjectedScriptManager::injectedScriptHost()
@@ -92,19 +95,15 @@ 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::discardInjectedScripts()
@@ -116,19 +115,13 @@ void InjectedScriptManager::discardInjectedScripts()
void InjectedScriptManager::releaseObjectGroup(const String& objectGroup)
{
- for (auto& injectedScript : m_idToInjectedScript.values())
- injectedScript.releaseObjectGroup(objectGroup);
-}
-
-void InjectedScriptManager::clearExceptionValue()
-{
- 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();
@@ -156,7 +149,6 @@ Deprecated::ScriptObject InjectedScriptManager::createInjectedScript(const Strin
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());
@@ -190,3 +182,4 @@ void InjectedScriptManager::didCreateInjectedScript(InjectedScript)
} // namespace Inspector
+#endif // ENABLE(INSPECTOR)