Title: [129476] trunk/Source/WebCore
Revision
129476
Author
[email protected]
Date
2012-09-25 01:39:41 -0700 (Tue, 25 Sep 2012)

Log Message

Web Inspector:  The JS code injected by worker inspector shouldn't be evaluated through JSMainThreadExecState
https://bugs.webkit.org/show_bug.cgi?id=95341

Patch by Peter Wang <[email protected]> on 2012-09-25
Reviewed by Yury Semikhatsky.

Add extra code to "JSC::InjectedScriptManager" and "JSC::ScriptFunctionCall" to make sure the
interfaces of JSMainThreadExecState are invoked only in main thread.

No new test case for this bug. Without this patch, opening worker inspector will meet failed assert statements.

* bindings/js/JSInjectedScriptManager.cpp:
(WebCore::InjectedScriptManager::createInjectedScript):
* bindings/js/ScriptFunctionCall.cpp:
(WebCore::ScriptFunctionCall::call):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129475 => 129476)


--- trunk/Source/WebCore/ChangeLog	2012-09-25 08:34:22 UTC (rev 129475)
+++ trunk/Source/WebCore/ChangeLog	2012-09-25 08:39:41 UTC (rev 129476)
@@ -1,3 +1,20 @@
+2012-09-25  Peter Wang  <[email protected]>
+
+        Web Inspector:  The JS code injected by worker inspector shouldn't be evaluated through JSMainThreadExecState
+        https://bugs.webkit.org/show_bug.cgi?id=95341
+
+        Reviewed by Yury Semikhatsky.
+
+        Add extra code to "JSC::InjectedScriptManager" and "JSC::ScriptFunctionCall" to make sure the
+        interfaces of JSMainThreadExecState are invoked only in main thread.
+
+        No new test case for this bug. Without this patch, opening worker inspector will meet failed assert statements.   
+
+        * bindings/js/JSInjectedScriptManager.cpp:
+        (WebCore::InjectedScriptManager::createInjectedScript):
+        * bindings/js/ScriptFunctionCall.cpp:
+        (WebCore::ScriptFunctionCall::call):
+
 2012-09-25  Andreas Kling  <[email protected]>
 
         CSSParserString: Avoid pointless String refcount churn in init().

Modified: trunk/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp (129475 => 129476)


--- trunk/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp	2012-09-25 08:34:22 UTC (rev 129475)
+++ trunk/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp	2012-09-25 08:39:41 UTC (rev 129476)
@@ -59,7 +59,13 @@
     JSValue globalThisValue = scriptState->globalThisValue();
 
     JSValue evaluationException;
-    JSValue evaluationReturnValue = JSMainThreadExecState::evaluate(scriptState, sourceCode, globalThisValue, &evaluationException);
+    JSValue evaluationReturnValue;
+    if (isMainThread())
+        evaluationReturnValue = JSMainThreadExecState::evaluate(scriptState, sourceCode, globalThisValue, &evaluationException);
+    else {
+        JSC::JSLockHolder lock(scriptState);
+        evaluationReturnValue = JSC::evaluate(scriptState, sourceCode, globalThisValue, &evaluationException);
+    }
     if (evaluationException)
         return ScriptObject();
 

Modified: trunk/Source/WebCore/bindings/js/ScriptFunctionCall.cpp (129475 => 129476)


--- trunk/Source/WebCore/bindings/js/ScriptFunctionCall.cpp	2012-09-25 08:34:22 UTC (rev 129475)
+++ trunk/Source/WebCore/bindings/js/ScriptFunctionCall.cpp	2012-09-25 08:39:41 UTC (rev 129476)
@@ -135,7 +135,12 @@
     if (callType == CallTypeNone)
         return ScriptValue();
 
-    JSValue result = JSMainThreadExecState::call(m_exec, function, callType, callData, thisObject, m_arguments);
+    JSValue result;
+    if (isMainThread())
+        result = JSMainThreadExecState::call(m_exec, function, callType, callData, thisObject, m_arguments);
+    else
+        result = JSC::call(m_exec, function, callType, callData, thisObject, m_arguments);
+
     if (m_exec->hadException()) {
         if (reportExceptions)
             reportException(m_exec, m_exec->exception());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to