]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - inspector/InjectedScriptBase.cpp
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / inspector / InjectedScriptBase.cpp
index d9561e1f4a786f96550e22daa34237ec93aecf1b..2dd5643dea49ab64e16575bb6bd071e68b33b35d 100644 (file)
@@ -32,8 +32,7 @@
 #include "config.h"
 #include "InjectedScriptBase.h"
 
-#if ENABLE(INSPECTOR)
-
+#include "DebuggerEvalEnabler.h"
 #include "InspectorValues.h"
 #include "JSCInlines.h"
 #include "JSGlobalObject.h"
@@ -81,18 +80,12 @@ Deprecated::ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(Deprecat
         m_environment->willCallInjectedScriptFunction(m_injectedScriptObject.scriptState(), name(), 1);
 
     JSC::ExecState* scriptState = m_injectedScriptObject.scriptState();
-    bool evalIsDisabled = false;
-    if (scriptState) {
-        evalIsDisabled = !scriptState->lexicalGlobalObject()->evalEnabled();
-        // Temporarily enable allow evals for inspector.
-        if (evalIsDisabled)
-            scriptState->lexicalGlobalObject()->setEvalEnabled(true);
-    }
-
-    Deprecated::ScriptValue resultValue = function.call(hadException);
+    Deprecated::ScriptValue resultValue;
 
-    if (evalIsDisabled)
-        scriptState->lexicalGlobalObject()->setEvalEnabled(false);
+    {
+        JSC::DebuggerEvalEnabler evalEnabler(scriptState);
+        resultValue = function.call(hadException);
+    }
 
     if (m_environment)
         m_environment->didCallInjectedScriptFunction(m_injectedScriptObject.scriptState());
@@ -119,38 +112,48 @@ void InjectedScriptBase::makeCall(Deprecated::ScriptFunctionCall& function, RefP
         *result = InspectorString::create("Exception while making a call.");
 }
 
-void InjectedScriptBase::makeEvalCall(ErrorString* errorString, Deprecated::ScriptFunctionCall& function, RefPtr<TypeBuilder::Runtime::RemoteObject>* objectResult, TypeBuilder::OptOutput<bool>* wasThrown)
+void InjectedScriptBase::makeEvalCall(ErrorString& errorString, Deprecated::ScriptFunctionCall& function, RefPtr<Protocol::Runtime::RemoteObject>* objectResult, Protocol::OptOutput<bool>* wasThrown, Protocol::OptOutput<int>* savedResultIndex)
 {
     RefPtr<InspectorValue> result;
     makeCall(function, &result);
     if (!result) {
-        *errorString = ASCIILiteral("Internal error: result value is empty");
+        errorString = ASCIILiteral("Internal error: result value is empty");
         return;
     }
 
-    if (result->type() == InspectorValue::TypeString) {
+    if (result->type() == InspectorValue::Type::String) {
         result->asString(errorString);
-        ASSERT(errorString->length());
+        ASSERT(errorString.length());
         return;
     }
 
-    RefPtr<InspectorObject> resultPair = result->asObject();
-    if (!resultPair) {
-        *errorString = ASCIILiteral("Internal error: result is not an Object");
+    RefPtr<InspectorObject> resultTuple;
+    if (!result->asObject(resultTuple)) {
+        errorString = ASCIILiteral("Internal error: result is not an Object");
         return;
     }
 
-    RefPtr<InspectorObject> resultObj = resultPair->getObject(ASCIILiteral("result"));
-    bool wasThrownVal = false;
-    if (!resultObj || !resultPair->getBoolean(ASCIILiteral("wasThrown"), &wasThrownVal)) {
-        *errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag");
+    RefPtr<InspectorObject> resultObject;
+    if (!resultTuple->getObject(ASCIILiteral("result"), resultObject)) {
+        errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag");
         return;
     }
 
-    *objectResult = TypeBuilder::Runtime::RemoteObject::runtimeCast(resultObj);
-    *wasThrown = wasThrownVal;
+    bool wasThrownValue = false;
+    if (!resultTuple->getBoolean(ASCIILiteral("wasThrown"), wasThrownValue)) {
+        errorString = ASCIILiteral("Internal error: result is not a pair of value and wasThrown flag");
+        return;
+    }
+
+    *objectResult = BindingTraits<Protocol::Runtime::RemoteObject>::runtimeCast(resultObject);
+    *wasThrown = wasThrownValue;
+
+    if (savedResultIndex) {
+        int savedIndex = 0;
+        if (resultTuple->getInteger(ASCIILiteral("savedResultIndex"), savedIndex))
+            *savedResultIndex = savedIndex;
+    }
 }
 
 } // namespace Inspector
 
-#endif // ENABLE(INSPECTOR)