Title: [200467] trunk
Revision
200467
Author
[email protected]
Date
2016-05-05 12:01:40 -0700 (Thu, 05 May 2016)

Log Message

Crash if you type "debugger" in the console and continue
https://bugs.webkit.org/show_bug.cgi?id=156924
<rdar://problem/25884189>

Patch by Joseph Pecoraro <[email protected]> on 2016-05-05
Reviewed by Mark Lam.

Source/_javascript_Core:

* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::evaluateOnCallFrame):
Bail with an error when we are not paused.

* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::callFunctionOn):
(Inspector::InspectorRuntimeAgent::getProperties):
(Inspector::InspectorRuntimeAgent::getDisplayableProperties):
(Inspector::InspectorRuntimeAgent::getCollectionEntries):
(Inspector::InspectorRuntimeAgent::saveResult):
Update poor error message.

Source/WebInspectorUI:

* UserInterface/Test/InspectorProtocol.js:
(InspectorProtocol.sendCommand):
Simplify sending a command with no parameters.

LayoutTests:

* inspector/debugger/evaluateOnCallFrame-errors-expected.txt: Added.
* inspector/debugger/evaluateOnCallFrame-errors.html: Added.
* inspector/protocol/backend-dispatcher-argument-errors-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (200466 => 200467)


--- trunk/LayoutTests/ChangeLog	2016-05-05 18:51:50 UTC (rev 200466)
+++ trunk/LayoutTests/ChangeLog	2016-05-05 19:01:40 UTC (rev 200467)
@@ -1,3 +1,15 @@
+2016-05-05  Joseph Pecoraro  <[email protected]>
+
+        Crash if you type "debugger" in the console and continue
+        https://bugs.webkit.org/show_bug.cgi?id=156924
+        <rdar://problem/25884189>
+
+        Reviewed by Mark Lam.
+
+        * inspector/debugger/evaluateOnCallFrame-errors-expected.txt: Added.
+        * inspector/debugger/evaluateOnCallFrame-errors.html: Added.
+        * inspector/protocol/backend-dispatcher-argument-errors-expected.txt:
+
 2016-05-04  Simon Fraser  <[email protected]>
 
         Comments on wired.com are blurry

Added: trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-errors-expected.txt (0 => 200467)


--- trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-errors-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-errors-expected.txt	2016-05-05 19:01:40 UTC (rev 200467)
@@ -0,0 +1,14 @@
+Calling Debugger.evaluateOnCallFrame protocol error cases.
+
+
+== Running test suite: Debugger.evaluateOnCallFrame.errors
+-- Running test case: EvaluateOnCallFrameNotPaused
+PASS: Paused
+PASS: Resumed
+PASS: Should be an error: Not paused
+
+-- Running test case: EvaluateOnCallFrameBadCallFrameIdentifier
+PASS: Paused
+PASS: Should be an error: Could not find InjectedScript for callFrameId
+PASS: Resumed
+

Added: trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-errors.html (0 => 200467)


--- trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-errors.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-errors.html	2016-05-05 19:01:40 UTC (rev 200467)
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function triggerPause() {
+    debugger;
+}
+
+function test()
+{
+    InspectorProtocol.sendCommand("Debugger.enable");
+    InspectorProtocol.sendCommand("Debugger.setBreakpointsActive", {active: true});
+
+    let suite = ProtocolTest.createAsyncSuite("Debugger.evaluateOnCallFrame.errors");
+
+    suite.addTestCase({
+        name: "EvaluateOnCallFrameNotPaused",
+        description: "Triggering evaluate on call frame when not paused should issue an error.",
+        test: (resolve, reject) => {
+            ProtocolTest.evaluateInPage("triggerPause()");
+
+            let callFrameIdentifier;
+
+            InspectorProtocol.eventHandler["Debugger.paused"] = (messageObject) => {
+                ProtocolTest.pass("Paused");
+                InspectorProtocol.sendCommand("Debugger.resume");
+                callFrameIdentifier = messageObject.params.callFrames[0].callFrameId;
+            };
+
+            InspectorProtocol.eventHandler["Debugger.resumed"] = (messageObject) => {
+                ProtocolTest.pass("Resumed");
+                InspectorProtocol.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, _expression_: "this"}, (messageObject) => {
+                    ProtocolTest.expectThat(messageObject.error, `Should be an error: ${messageObject.error ? messageObject.error.message : ""}`);
+                    resolve();
+                });
+            };
+        }
+    });
+
+    suite.addTestCase({
+        name: "EvaluateOnCallFrameBadCallFrameIdentifier",
+        description: "Triggering evaluate on call frame with a bad call frame identifier should issue an error.",
+        test: (resolve, reject) => {
+            ProtocolTest.evaluateInPage("triggerPause()");
+
+            InspectorProtocol.eventHandler["Debugger.paused"] = (messageObject) => {
+                ProtocolTest.pass("Paused");
+
+                InspectorProtocol.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: "BAD-CALL-FRAME-ID", _expression_: "this"}, (messageObject) => {
+                    ProtocolTest.expectThat(messageObject.error, `Should be an error: ${messageObject.error ? messageObject.error.message : ""}`);
+                    InspectorProtocol.sendCommand("Debugger.resume");
+                });
+            };
+
+            InspectorProtocol.eventHandler["Debugger.resumed"] = (messageObject) => {
+                ProtocolTest.pass("Resumed");
+                resolve();
+            };
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Calling Debugger.evaluateOnCallFrame protocol error cases.</p>
+</body>
+</html>

Modified: trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors-expected.txt (200466 => 200467)


--- trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors-expected.txt	2016-05-05 18:51:50 UTC (rev 200466)
+++ trunk/LayoutTests/inspector/protocol/backend-dispatcher-argument-errors-expected.txt	2016-05-05 19:01:40 UTC (rev 200467)
@@ -55,6 +55,6 @@
 PASS: the backend should send a protocol error when receiving an invalid message.
 PASS: the reported error should be "ServerError" (-32000)
 Actual error code: -32000
-Actual error message: Inspected frame has gone
-Actual error data: [{"code":-32000,"message":"Inspected frame has gone"}]
+Actual error message: Could not find InjectedScript for objectId
+Actual error data: [{"code":-32000,"message":"Could not find InjectedScript for objectId"}]
 

Modified: trunk/Source/_javascript_Core/ChangeLog (200466 => 200467)


--- trunk/Source/_javascript_Core/ChangeLog	2016-05-05 18:51:50 UTC (rev 200466)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-05-05 19:01:40 UTC (rev 200467)
@@ -1,3 +1,23 @@
+2016-05-05  Joseph Pecoraro  <[email protected]>
+
+        Crash if you type "debugger" in the console and continue
+        https://bugs.webkit.org/show_bug.cgi?id=156924
+        <rdar://problem/25884189>
+
+        Reviewed by Mark Lam.
+
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::evaluateOnCallFrame):
+        Bail with an error when we are not paused.
+
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::callFunctionOn):
+        (Inspector::InspectorRuntimeAgent::getProperties):
+        (Inspector::InspectorRuntimeAgent::getDisplayableProperties):
+        (Inspector::InspectorRuntimeAgent::getCollectionEntries):
+        (Inspector::InspectorRuntimeAgent::saveResult):
+        Update poor error message.
+
 2016-05-05  Keith Miller  <[email protected]>
 
         Add support for delete by value to the DFG

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (200466 => 200467)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2016-05-05 18:51:50 UTC (rev 200466)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2016-05-05 19:01:40 UTC (rev 200467)
@@ -565,9 +565,14 @@
 
 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, const bool* generatePreview, const bool* saveResult, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown, Inspector::Protocol::OptOutput<int>* savedResultIndex)
 {
+    if (m_currentCallStack.hasNoValue()) {
+        errorString = ASCIILiteral("Not paused");
+        return;
+    }
+
     InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(callFrameId);
     if (injectedScript.hasNoValue()) {
-        errorString = ASCIILiteral("Inspected frame has gone");
+        errorString = ASCIILiteral("Could not find InjectedScript for callFrameId");
         return;
     }
 

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp (200466 => 200467)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp	2016-05-05 18:51:50 UTC (rev 200466)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp	2016-05-05 19:01:40 UTC (rev 200467)
@@ -137,7 +137,7 @@
 {
     InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
     if (injectedScript.hasNoValue()) {
-        errorString = ASCIILiteral("Inspected frame has gone");
+        errorString = ASCIILiteral("Could not find InjectedScript for objectId");
         return;
     }
 
@@ -163,7 +163,7 @@
 {
     InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
     if (injectedScript.hasNoValue()) {
-        errorString = ASCIILiteral("Inspected frame has gone");
+        errorString = ASCIILiteral("Could not find InjectedScript for objectId");
         return;
     }
 
@@ -181,7 +181,7 @@
 {
     InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
     if (injectedScript.hasNoValue()) {
-        errorString = ASCIILiteral("Inspected frame has gone");
+        errorString = ASCIILiteral("Could not find InjectedScript for objectId");
         return;
     }
 
@@ -199,7 +199,7 @@
 {
     InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
     if (injectedScript.hasNoValue()) {
-        errorString = ASCIILiteral("Inspected frame has gone");
+        errorString = ASCIILiteral("Could not find InjectedScript for objectId");
         return;
     }
 
@@ -217,7 +217,7 @@
     if (callArgument.getString(ASCIILiteral("objectId"), objectId)) {
         injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId);
         if (injectedScript.hasNoValue()) {
-            errorString = ASCIILiteral("Inspected frame has gone");
+            errorString = ASCIILiteral("Could not find InjectedScript for objectId");
             return;
         }
     } else {

Modified: trunk/Source/WebInspectorUI/ChangeLog (200466 => 200467)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-05-05 18:51:50 UTC (rev 200466)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-05-05 19:01:40 UTC (rev 200467)
@@ -1,3 +1,15 @@
+2016-05-05  Joseph Pecoraro  <[email protected]>
+
+        Crash if you type "debugger" in the console and continue
+        https://bugs.webkit.org/show_bug.cgi?id=156924
+        <rdar://problem/25884189>
+
+        Reviewed by Mark Lam.
+
+        * UserInterface/Test/InspectorProtocol.js:
+        (InspectorProtocol.sendCommand):
+        Simplify sending a command with no parameters.
+
 2016-05-04  Nikita Vasilyev  <[email protected]>
 
         REGRESSION (r200401): Web Inspector: TypeError: undefined is not an object (evaluating 'messageElement.classList')

Modified: trunk/Source/WebInspectorUI/UserInterface/Test/InspectorProtocol.js (200466 => 200467)


--- trunk/Source/WebInspectorUI/UserInterface/Test/InspectorProtocol.js	2016-05-05 18:51:50 UTC (rev 200466)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/InspectorProtocol.js	2016-05-05 19:01:40 UTC (rev 200467)
@@ -36,6 +36,8 @@
     let method = methodOrObject;
     if (typeof methodOrObject === "object")
         ({method, params, handler} = methodOrObject);
+    else if (!params)
+        params = {};
 
     this._dispatchTable[++this._requestId] = handler;
     let messageObject = {method, params, id: this._requestId};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to