Web Inspector: x-frame security errors logged when typing in the console are annoying.
authorvsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2012 13:28:25 +0000 (13:28 +0000)
committervsevik@chromium.org <vsevik@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Apr 2012 13:28:25 +0000 (13:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81970

Reviewed by Pavel Feldman.

Parameter DoNotPauseOnExceptions in Runtime.evaluate() renamed to DoNotPauseOnExceptionsAndMuteConsole.
Added this parameter to Runtime.callFunctionOn() and passed true in all call sites.
Added this parameter to Debugger.evaluateOnCallFrame().
Added a flag to console that mutes all messages unless they have ConsoleAPI message source.
This flag is now temporarily set from InspectorRuntimeAgent and InspectorDebuggerAgent for certain injected source calls.

* inspector/Inspector.json:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::asBool):
(WebCore):
(WebCore::InspectorDebuggerAgent::evaluateOnCallFrame):
* inspector/InspectorDebuggerAgent.h:
(InspectorDebuggerAgent):
* inspector/InspectorRuntimeAgent.cpp:
(WebCore):
(WebCore::setPauseOnExceptionsState):
(WebCore::InspectorRuntimeAgent::evaluate):
(WebCore::InspectorRuntimeAgent::callFunctionOn):
(WebCore::InspectorRuntimeAgent::getProperties):
* inspector/InspectorRuntimeAgent.h:
(InspectorRuntimeAgent):
* inspector/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::muteConsole):
(WebCore):
(WebCore::PageDebuggerAgent::unmuteConsole):
* inspector/PageDebuggerAgent.h:
(PageDebuggerAgent):
* inspector/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::muteConsole):
(WebCore):
(WebCore::PageRuntimeAgent::unmuteConsole):
* inspector/PageRuntimeAgent.h:
(PageRuntimeAgent):
* inspector/WorkerDebuggerAgent.cpp:
(WebCore::WorkerDebuggerAgent::muteConsole):
(WebCore):
(WebCore::WorkerDebuggerAgent::unmuteConsole):
* inspector/WorkerDebuggerAgent.h:
(WorkerDebuggerAgent):
* inspector/WorkerRuntimeAgent.cpp:
(WebCore::WorkerRuntimeAgent::muteConsole):
(WebCore):
(WebCore::WorkerRuntimeAgent::unmuteConsole):
* inspector/WorkerRuntimeAgent.h:
(WorkerRuntimeAgent):
* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleView.prototype.evalInInspectedWindow):
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype.evaluateInSelectedCallFrame):
(WebInspector.PresentationCallFrame.prototype.evaluate):
* inspector/front-end/RemoteObject.js:
(WebInspector.RemoteObject.prototype.setPropertyValue):
(WebInspector.RemoteObject.prototype.callFunction):
(WebInspector.RemoteObject.prototype.callFunctionJSON):
* inspector/front-end/WorkerManager.js:
* page/Console.cpp:
(WebCore::Console::addMessage):
(WebCore::Console::warn):
(WebCore):
(WebCore::Console::mute):
(WebCore::Console::unmute):
* page/Console.h:
(Console):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@114628 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/InspectorDebuggerAgent.h
Source/WebCore/inspector/InspectorRuntimeAgent.cpp
Source/WebCore/inspector/InspectorRuntimeAgent.h
Source/WebCore/inspector/PageDebuggerAgent.cpp
Source/WebCore/inspector/PageDebuggerAgent.h
Source/WebCore/inspector/PageRuntimeAgent.cpp
Source/WebCore/inspector/PageRuntimeAgent.h
Source/WebCore/inspector/WorkerDebuggerAgent.cpp
Source/WebCore/inspector/WorkerDebuggerAgent.h
Source/WebCore/inspector/WorkerRuntimeAgent.cpp
Source/WebCore/inspector/WorkerRuntimeAgent.h
Source/WebCore/inspector/front-end/ConsoleView.js
Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
Source/WebCore/inspector/front-end/RemoteObject.js
Source/WebCore/inspector/front-end/WorkerManager.js
Source/WebCore/page/Console.cpp
Source/WebCore/page/Console.h

index 1a25d66..667d4f1 100644 (file)
@@ -1,3 +1,74 @@
+2012-04-19  Vsevolod Vlasov  <vsevik@chromium.org>
+
+        Web Inspector: x-frame security errors logged when typing in the console are annoying.
+        https://bugs.webkit.org/show_bug.cgi?id=81970
+
+        Reviewed by Pavel Feldman.
+
+        Parameter DoNotPauseOnExceptions in Runtime.evaluate() renamed to DoNotPauseOnExceptionsAndMuteConsole.
+        Added this parameter to Runtime.callFunctionOn() and passed true in all call sites.
+        Added this parameter to Debugger.evaluateOnCallFrame().
+        Added a flag to console that mutes all messages unless they have ConsoleAPI message source.
+        This flag is now temporarily set from InspectorRuntimeAgent and InspectorDebuggerAgent for certain injected source calls.
+
+        * inspector/Inspector.json:
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::asBool):
+        (WebCore):
+        (WebCore::InspectorDebuggerAgent::evaluateOnCallFrame):
+        * inspector/InspectorDebuggerAgent.h:
+        (InspectorDebuggerAgent):
+        * inspector/InspectorRuntimeAgent.cpp:
+        (WebCore):
+        (WebCore::setPauseOnExceptionsState):
+        (WebCore::InspectorRuntimeAgent::evaluate):
+        (WebCore::InspectorRuntimeAgent::callFunctionOn):
+        (WebCore::InspectorRuntimeAgent::getProperties):
+        * inspector/InspectorRuntimeAgent.h:
+        (InspectorRuntimeAgent):
+        * inspector/PageDebuggerAgent.cpp:
+        (WebCore::PageDebuggerAgent::muteConsole):
+        (WebCore):
+        (WebCore::PageDebuggerAgent::unmuteConsole):
+        * inspector/PageDebuggerAgent.h:
+        (PageDebuggerAgent):
+        * inspector/PageRuntimeAgent.cpp:
+        (WebCore::PageRuntimeAgent::muteConsole):
+        (WebCore):
+        (WebCore::PageRuntimeAgent::unmuteConsole):
+        * inspector/PageRuntimeAgent.h:
+        (PageRuntimeAgent):
+        * inspector/WorkerDebuggerAgent.cpp:
+        (WebCore::WorkerDebuggerAgent::muteConsole):
+        (WebCore):
+        (WebCore::WorkerDebuggerAgent::unmuteConsole):
+        * inspector/WorkerDebuggerAgent.h:
+        (WorkerDebuggerAgent):
+        * inspector/WorkerRuntimeAgent.cpp:
+        (WebCore::WorkerRuntimeAgent::muteConsole):
+        (WebCore):
+        (WebCore::WorkerRuntimeAgent::unmuteConsole):
+        * inspector/WorkerRuntimeAgent.h:
+        (WorkerRuntimeAgent):
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleView.prototype.evalInInspectedWindow):
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.prototype.evaluateInSelectedCallFrame):
+        (WebInspector.PresentationCallFrame.prototype.evaluate):
+        * inspector/front-end/RemoteObject.js:
+        (WebInspector.RemoteObject.prototype.setPropertyValue):
+        (WebInspector.RemoteObject.prototype.callFunction):
+        (WebInspector.RemoteObject.prototype.callFunctionJSON):
+        * inspector/front-end/WorkerManager.js:
+        * page/Console.cpp:
+        (WebCore::Console::addMessage):
+        (WebCore::Console::warn):
+        (WebCore):
+        (WebCore::Console::mute):
+        (WebCore::Console::unmute):
+        * page/Console.h:
+        (Console):
+
 2012-04-19  No'am Rosenthal  <noam.rosenthal@nokia.com>
 
         [Qt] Fix Qt-Mac build after libxml patch
index 9add3b6..9dc9bf0 100644 (file)
                     { "name": "expression", "type": "string", "description": "Expression to evaluate." },
                     { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." },
                     { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation.", "hidden": true },
-                    { "name": "doNotPauseOnExceptions", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions. Overrides setPauseOnException state.", "hidden": true },
+                    { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true },
                     { "name": "frameId", "$ref": "Network.FrameId", "optional": true, "description": "Specifies in which frame to perform evaluation.", "hidden": true },
                     { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }
                 ],
                     { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to call function on." },
                     { "name": "functionDeclaration", "type": "string", "description": "Declaration of the function to call." },
                     { "name": "arguments", "type": "array", "items": { "$ref": "CallArgument", "description": "Call argument." }, "optional": true, "description": "Call arguments. All call arguments must belong to the same JavaScript world as the target object." },
+                    { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether function call should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true },
                     { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." }
                 ],
                 "returns": [
                     { "name": "expression", "type": "string", "description": "Expression to evaluate." },
                     { "name": "objectGroup", "type": "string", "optional": true, "description": "String object group name to put result into (allows rapid releasing resulting object handles using <code>releaseObjectGroup</code>)." },
                     { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Specifies whether command line API should be available to the evaluated expression, defaults to false.", "hidden": true },
+                    { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.", "hidden": true },
                     { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." }
                 ],
                 "returns": [
index 25fa3fb..f2a0875 100644 (file)
@@ -59,6 +59,11 @@ static const char pauseOnExceptionsState[] = "pauseOnExceptionsState";
 
 const char* InspectorDebuggerAgent::backtraceObjectGroup = "backtrace-object-group";
 
+static bool asBool(const bool* const b)
+{
+    return b ? *b : false;
+}
+
 InspectorDebuggerAgent::InspectorDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
     : InspectorBaseAgent<InspectorDebuggerAgent>("Debugger", instrumentingAgents, inspectorState)
     , m_injectedScriptManager(injectedScriptManager)
@@ -476,14 +481,29 @@ void InspectorDebuggerAgent::setPauseOnExceptionsImpl(ErrorString* errorString,
         m_state->setLong(DebuggerAgentState::pauseOnExceptionsState, pauseState);
 }
 
-void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
+void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
 {
     InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(callFrameId);
     if (injectedScript.hasNoValue()) {
         *errorString = "Inspected frame has gone";
         return;
     }
-    injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, expression, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, returnByValue ? *returnByValue : false, &result, wasThrown);
+
+    ASSERT(scriptDebugServer());
+    ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = scriptDebugServer().pauseOnExceptionsState();
+    if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
+        if (previousPauseOnExceptionsState != ScriptDebugServer::DontPauseOnExceptions)
+            scriptDebugServer().setPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions);
+        muteConsole();
+    }
+
+    injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, expression, objectGroup ? *objectGroup : "", asBool(includeCommandLineAPI), asBool(returnByValue), &result, wasThrown);
+
+    if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
+        unmuteConsole();
+        if (scriptDebugServer().pauseOnExceptionsState() != previousPauseOnExceptionsState)
+            scriptDebugServer().setPauseOnExceptionsState(previousPauseOnExceptionsState);
+    }
 }
 
 PassRefPtr<Array<TypeBuilder::Debugger::CallFrame> > InspectorDebuggerAgent::currentCallFrames()
index 46e3a33..9f415a5 100644 (file)
@@ -105,6 +105,7 @@ public:
                              const String& expression,
                              const String* objectGroup,
                              const bool* includeCommandLineAPI,
+                             const bool* doNotPauseOnExceptionsAndMuteConsole,
                              const bool* returnByValue,
                              RefPtr<TypeBuilder::Runtime::RemoteObject>& result,
                              TypeBuilder::OptOutput<bool>* wasThrown);
@@ -124,6 +125,8 @@ protected:
 
     virtual void startListeningScriptDebugServer() = 0;
     virtual void stopListeningScriptDebugServer() = 0;
+    virtual void muteConsole() = 0;
+    virtual void unmuteConsole() = 0;
 
 private:
     void enable();
index f240a88..ad6c8c6 100644 (file)
@@ -72,7 +72,18 @@ InspectorRuntimeAgent::~InspectorRuntimeAgent()
     m_instrumentingAgents->setInspectorRuntimeAgent(0);
 }
 
-void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, const String* const frameId, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+static ScriptDebugServer::PauseOnExceptionsState setPauseOnExceptionsState(ScriptDebugServer* scriptDebugServer, ScriptDebugServer::PauseOnExceptionsState newState)
+{
+    ASSERT(scriptDebugServer);
+    ScriptDebugServer::PauseOnExceptionsState presentState = scriptDebugServer->pauseOnExceptionsState();
+    if (presentState != newState)
+        scriptDebugServer->setPauseOnExceptionsState(newState);
+    return presentState;
+}
+#endif
+
+void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const String* const frameId, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
 {
     ScriptState* scriptState = 0;
     if (frameId) {
@@ -89,24 +100,24 @@ void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& exp
         return;
     }
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    ASSERT(m_scriptDebugServer);
-    bool pauseStateChanged = false;
-    ScriptDebugServer::PauseOnExceptionsState presentState = m_scriptDebugServer->pauseOnExceptionsState();
-    if (asBool(doNotPauseOnExceptions) && presentState != ScriptDebugServer::DontPauseOnExceptions) {
-        m_scriptDebugServer->setPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions);
-        pauseStateChanged = true;
-    }
+    ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = ScriptDebugServer::DontPauseOnExceptions;
+    if (asBool(doNotPauseOnExceptionsAndMuteConsole))
+        previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
 #endif
+    if (asBool(doNotPauseOnExceptionsAndMuteConsole))
+        muteConsole();
 
     injectedScript.evaluate(errorString, expression, objectGroup ? *objectGroup : "", asBool(includeCommandLineAPI), asBool(returnByValue), &result, wasThrown);
 
+    if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
+        unmuteConsole();
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    if (pauseStateChanged)
-        m_scriptDebugServer->setPauseOnExceptionsState(presentState);
+        setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
 #endif
+    }
 }
 
-void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const RefPtr<InspectorArray>* const optionalArguments, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
+void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const RefPtr<InspectorArray>* const optionalArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
 {
     InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
     if (injectedScript.hasNoValue()) {
@@ -117,7 +128,22 @@ void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const Strin
     if (optionalArguments)
         arguments = (*optionalArguments)->toJSONString();
 
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+    ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = ScriptDebugServer::DontPauseOnExceptions;
+    if (asBool(doNotPauseOnExceptionsAndMuteConsole))
+        previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
+#endif
+    if (asBool(doNotPauseOnExceptionsAndMuteConsole))
+        muteConsole();
+
     injectedScript.callFunctionOn(errorString, objectId, expression, arguments, asBool(returnByValue), &result, wasThrown);
+
+    if (asBool(doNotPauseOnExceptionsAndMuteConsole)) {
+        unmuteConsole();
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+        setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
+#endif
+    }
 }
 
 void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String& objectId, const bool* const ownProperties, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result)
@@ -127,7 +153,18 @@ void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String
         *errorString = "Inspected frame has gone";
         return;
     }
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+    ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
+#endif
+    muteConsole();
+
     injectedScript.getProperties(errorString, objectId, ownProperties ? *ownProperties : false, &result);
+
+    unmuteConsole();
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+    setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
+#endif
 }
 
 void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId)
index 21f3b90..8280ae2 100644 (file)
@@ -61,7 +61,7 @@ public:
                   const String& expression,
                   const String* objectGroup,
                   const bool* includeCommandLineAPI,
-                  const bool* doNotPauseOnExceptions,
+                  const bool* doNotPauseOnExceptionsAndMuteConsole,
                   const String* frameId,
                   const bool* returnByValue,
                   RefPtr<TypeBuilder::Runtime::RemoteObject>& result,
@@ -70,6 +70,7 @@ public:
                         const String& objectId,
                         const String& expression,
                         const RefPtr<InspectorArray>* optionalArguments,
+                        const bool* doNotPauseOnExceptionsAndMuteConsole,
                         const bool* returnByValue,
                         RefPtr<TypeBuilder::Runtime::RemoteObject>& result,
                         TypeBuilder::OptOutput<bool>* wasThrown);
@@ -89,6 +90,8 @@ protected:
     InspectorRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
     virtual ScriptState* scriptStateForFrameId(const String& frameId) = 0;
     virtual ScriptState* getDefaultInspectedState() = 0;
+    virtual void muteConsole() = 0;
+    virtual void unmuteConsole() = 0;
 
 private:
     InjectedScriptManager* m_injectedScriptManager;
index 113dd4e..ba9a7e4 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "PageDebuggerAgent.h"
 
+#include "Console.h"
 #include "PageScriptDebugServer.h"
 
 namespace WebCore {
@@ -68,6 +69,16 @@ PageScriptDebugServer& PageDebuggerAgent::scriptDebugServer()
     return PageScriptDebugServer::shared();
 }
 
+void PageDebuggerAgent::muteConsole()
+{
+    Console::mute();
+}
+
+void PageDebuggerAgent::unmuteConsole()
+{
+    Console::unmute();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR)
index 7d6af6c..7275248 100644 (file)
@@ -51,6 +51,8 @@ private:
     virtual void startListeningScriptDebugServer();
     virtual void stopListeningScriptDebugServer();
     virtual PageScriptDebugServer& scriptDebugServer();
+    virtual void muteConsole();
+    virtual void unmuteConsole();
 
     PageDebuggerAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*);
     Page* const m_inspectedPage;
index 7d07ee3..9284f39 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "PageRuntimeAgent.h"
 
+#include "Console.h"
 #include "InspectorPageAgent.h"
 #include "Page.h"
 #include "ScriptState.h"
@@ -64,6 +65,16 @@ ScriptState* PageRuntimeAgent::getDefaultInspectedState()
     return mainWorldScriptState(m_inspectedPage->mainFrame());
 }
 
+void PageRuntimeAgent::muteConsole()
+{
+    Console::mute();
+}
+
+void PageRuntimeAgent::unmuteConsole()
+{
+    Console::unmute();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index ffe290c..32614a8 100644 (file)
@@ -54,6 +54,8 @@ private:
 
     virtual ScriptState* scriptStateForFrameId(const String& frameId);
     virtual ScriptState* getDefaultInspectedState();
+    virtual void muteConsole();
+    virtual void unmuteConsole();
     Page* m_inspectedPage;
     InspectorPageAgent* m_pageAgent;
 };
index e22d068..2c6f2bd 100644 (file)
@@ -124,6 +124,16 @@ WorkerScriptDebugServer& WorkerDebuggerAgent::scriptDebugServer()
     return m_scriptDebugServer;
 }
 
+void WorkerDebuggerAgent::muteConsole()
+{
+    // We don't need to mute console for workers.
+}
+
+void WorkerDebuggerAgent::unmuteConsole()
+{
+    // We don't need to mute console for workers.
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) && ENABLE(WORKERS)
index 8017ac0..7ae68aa 100644 (file)
@@ -56,6 +56,8 @@ private:
     virtual void startListeningScriptDebugServer();
     virtual void stopListeningScriptDebugServer();
     virtual WorkerScriptDebugServer& scriptDebugServer();
+    virtual void muteConsole();
+    virtual void unmuteConsole();
 
     WorkerScriptDebugServer m_scriptDebugServer;
     WorkerContext* m_inspectedWorkerContext;
index 85b8ae5..1c4457e 100644 (file)
@@ -58,6 +58,16 @@ ScriptState* WorkerRuntimeAgent::getDefaultInspectedState()
     return scriptStateFromWorkerContext(m_workerContext);
 }
 
+void WorkerRuntimeAgent::muteConsole()
+{
+    // We don't need to mute console for workers.
+}
+
+void WorkerRuntimeAgent::unmuteConsole()
+{
+    // We don't need to mute console for workers.
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR) && ENABLE(WORKERS)
index d269a2f..ccfe1fb 100644 (file)
@@ -52,6 +52,8 @@ private:
     WorkerRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, WorkerContext*);
     virtual ScriptState* scriptStateForFrameId(const String& frameId);
     virtual ScriptState* getDefaultInspectedState();
+    virtual void muteConsole();
+    virtual void unmuteConsole();
     WorkerContext* m_workerContext;
 };
 
index 7626c3e..9b1192c 100644 (file)
@@ -586,14 +586,14 @@ WebInspector.ConsoleView.prototype = {
      * @param {string} expression
      * @param {string} objectGroup
      * @param {boolean} includeCommandLineAPI
-     * @param {boolean} doNotPauseOnExceptions
+     * @param {boolean} doNotPauseOnExceptionsAndMuteConsole
      * @param {boolean} returnByValue
      * @param {function(?WebInspector.RemoteObject, boolean, RuntimeAgent.RemoteObject=)} callback
      */
-    evalInInspectedWindow: function(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptions, returnByValue, callback)
+    evalInInspectedWindow: function(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, callback)
     {
         if (WebInspector.debuggerPresentationModel.selectedCallFrame) {
-            WebInspector.debuggerPresentationModel.evaluateInSelectedCallFrame(expression, objectGroup, includeCommandLineAPI, returnByValue, callback);
+            WebInspector.debuggerPresentationModel.evaluateInSelectedCallFrame(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, callback);
             return;
         }
 
@@ -620,7 +620,7 @@ WebInspector.ConsoleView.prototype = {
             else
                 callback(WebInspector.RemoteObject.fromPayload(result), !!wasThrown);
         }
-        RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptions, this._currentEvaluationContextId(), returnByValue, evalCallback);
+        RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, this._currentEvaluationContextId(), returnByValue, evalCallback);
     },
 
     evaluateUsingTextPrompt: function(expression, showResultOnly)
index abe475b..e9aab15 100644 (file)
@@ -459,9 +459,14 @@ WebInspector.DebuggerPresentationModel.prototype = {
     },
 
     /**
+     * @param {string} code
+     * @param {string} objectGroup
+     * @param {boolean} includeCommandLineAPI
+     * @param {boolean} doNotPauseOnExceptionsAndMuteConsole
+     * @param {boolean} returnByValue
      * @param {function(?WebInspector.RemoteObject, boolean, RuntimeAgent.RemoteObject=)} callback
      */
-    evaluateInSelectedCallFrame: function(code, objectGroup, includeCommandLineAPI, returnByValue, callback)
+    evaluateInSelectedCallFrame: function(code, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, callback)
     {
         /**
          * @param {?RuntimeAgent.RemoteObject} result
@@ -478,7 +483,7 @@ WebInspector.DebuggerPresentationModel.prototype = {
                 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame);
         }
 
-        this.selectedCallFrame.evaluate(code, objectGroup, includeCommandLineAPI, returnByValue, didEvaluate.bind(this));
+        this.selectedCallFrame.evaluate(code, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, didEvaluate.bind(this));
     },
 
     /**
@@ -684,10 +689,11 @@ WebInspector.PresentationCallFrame.prototype = {
      * @param {string} code
      * @param {string} objectGroup
      * @param {boolean} includeCommandLineAPI
+     * @param {boolean} doNotPauseOnExceptionsAndMuteConsole
      * @param {boolean} returnByValue
      * @param {function(?RuntimeAgent.RemoteObject, boolean=)=} callback
      */
-    evaluate: function(code, objectGroup, includeCommandLineAPI, returnByValue, callback)
+    evaluate: function(code, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, callback)
     {
         /**
          * @this {WebInspector.PresentationCallFrame}
@@ -704,7 +710,7 @@ WebInspector.PresentationCallFrame.prototype = {
             }
             callback(result, wasThrown);
         }
-        DebuggerAgent.evaluateOnCallFrame(this._callFrame.callFrameId, code, objectGroup, includeCommandLineAPI, returnByValue, didEvaluateOnCallFrame.bind(this));
+        DebuggerAgent.evaluateOnCallFrame(this._callFrame.callFrameId, code, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, didEvaluateOnCallFrame.bind(this));
     },
 
     /**
index 2f77dea..f3d3a4c 100644 (file)
@@ -219,7 +219,7 @@ WebInspector.RemoteObject.prototype = {
             return;
         }
 
-        RuntimeAgent.evaluate.invoke({expression:value, doNotPauseOnExceptions:true}, evaluatedCallback.bind(this));
+        RuntimeAgent.evaluate.invoke({expression:value, doNotPauseOnExceptionsAndMuteConsole:true}, evaluatedCallback.bind(this));
 
         /**
          * @param {?Protocol.Error} error
@@ -239,7 +239,7 @@ WebInspector.RemoteObject.prototype = {
             }
 
             delete result.description; // Optimize on traffic.
-            RuntimeAgent.callFunctionOn(this._objectId, setPropertyValue.toString(), [{ value:name }, result], undefined, propertySetCallback.bind(this));
+            RuntimeAgent.callFunctionOn(this._objectId, setPropertyValue.toString(), [{ value:name }, result], true, undefined, propertySetCallback.bind(this));
             if (result._objectId)
                 RuntimeAgent.releaseObject(result._objectId);
         }
@@ -287,7 +287,7 @@ WebInspector.RemoteObject.prototype = {
             callback((error || wasThrown) ? null : WebInspector.RemoteObject.fromPayload(result));
         }
 
-        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, undefined, mycallback);
+        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, undefined, mycallback);
     },
 
     /**
@@ -307,7 +307,7 @@ WebInspector.RemoteObject.prototype = {
             callback((error || wasThrown) ? null : result.value);
         }
 
-        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, mycallback);
+        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, true, mycallback);
     },
 
     release: function()
index 302841b..c9f053d 100644 (file)
@@ -98,7 +98,7 @@ WebInspector.WorkerManager._calculateWorkerInspectorTitle = function()
     var expression = "location.href";
     if (WebInspector.queryParamsObject["isSharedWorker"])
         expression += " + (this.name ? ' (' + this.name + ')' : '')";
-    RuntimeAgent.evaluate.invoke({expression:expression, doNotPauseOnExceptions:true, returnByValue: true}, evalCallback.bind(this));
+    RuntimeAgent.evaluate.invoke({expression:expression, doNotPauseOnExceptionsAndMuteConsole:true, returnByValue: true}, evalCallback.bind(this));
     
     /**
      * @param {?Protocol.Error} error
index fe0f0af..76c6450 100644 (file)
 
 namespace WebCore {
 
+namespace {
+    int muteCount = 0;
+}
+
 Console::Console(Frame* frame)
     : DOMWindowProperty(frame)
 {
@@ -128,8 +132,6 @@ static void printMessageSourceAndLevelPrefix(MessageSource source, MessageLevel
     printf("%s %s:", sourceString, levelString);
 }
 
-void addMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>);
-
 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack)
 {
     addMessage(source, type, level, message, String(), 0, callStack);
@@ -137,6 +139,10 @@ void Console::addMessage(MessageSource source, MessageType type, MessageLevel le
 
 void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<ScriptCallStack> callStack)
 {
+
+    if (muteCount && source != ConsoleAPIMessageSource)
+        return;
+
     Page* page = this->page();
     if (!page)
         return;
@@ -211,6 +217,11 @@ void Console::log(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallSt
     addMessage(LogMessageType, LogMessageLevel, arguments, callStack);
 }
 
+void Console::warn(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
+{
+    addMessage(LogMessageType, WarningMessageLevel, arguments, callStack);
+}
+
 void Console::dir(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
 {
     addMessage(DirMessageType, LogMessageLevel, arguments, callStack);
@@ -331,9 +342,17 @@ void Console::groupEnd()
     InspectorInstrumentation::addMessageToConsole(page(), ConsoleAPIMessageSource, EndGroupMessageType, LogMessageLevel, String(), String(), 0);
 }
 
-void Console::warn(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
+// static
+void Console::mute()
 {
-    addMessage(LogMessageType, WarningMessageLevel, arguments, callStack);
+    muteCount++;
+}
+
+// static
+void Console::unmute()
+{
+    ASSERT(muteCount > 0);
+    muteCount--;
 }
 
 PassRefPtr<MemoryInfo> Console::memory() const
index 89e2955..916794e 100644 (file)
@@ -81,6 +81,9 @@ public:
     void groupCollapsed(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
     void groupEnd();
 
+    static void mute();
+    static void unmute();
+
     static bool shouldPrintExceptions();
     static void setShouldPrintExceptions(bool);