2010-08-17 Yury Semikhatsky <yurys@chromium.org>
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Aug 2010 15:41:03 +0000 (15:41 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Aug 2010 15:41:03 +0000 (15:41 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: upstream Chromium debugger step tests
        https://bugs.webkit.org/show_bug.cgi?id=44106

        * http/tests/inspector-enabled/console-log-before-frame-navigation.html:
        * http/tests/inspector-enabled/resources/console-log-before-frame-navigation.js: Added.
        (doit.callback):
        (doit):
        (receiveMessage):
        (frontend_dumpConsoleMessages):
        * http/tests/inspector/debugger-test.js:
        (frontend_captureStackTrace):
        * inspector/debugger-step-in-expected.txt: Added.
        * inspector/debugger-step-in.html: Added.
        * inspector/debugger-step-out-expected.txt: Added.
        * inspector/debugger-step-out.html: Added.
        * inspector/debugger-step-over-expected.txt: Added.
        * inspector/debugger-step-over.html: Added.
2010-08-17  Yury Semikhatsky  <yurys@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: upstream Chromium debugger step tests
        https://bugs.webkit.org/show_bug.cgi?id=44106

        Tests: inspector/debugger-step-in.html
               inspector/debugger-step-out.html
               inspector/debugger-step-over.html

        * bindings/js/ScriptDebugServer.cpp:
        (WebCore::ScriptDebugServer::returnEvent): check that debugger is still attached after continue to ensure
        that current call frame is not 0.
2010-08-17  Yury Semikhatsky  <yurys@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: upstream Chromium debugger step tests
        https://bugs.webkit.org/show_bug.cgi?id=44106

        * src/js/Tests.js:

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

13 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/debugger-test.js
LayoutTests/inspector/debugger-step-in-expected.txt [new file with mode: 0644]
LayoutTests/inspector/debugger-step-in.html [new file with mode: 0644]
LayoutTests/inspector/debugger-step-out-expected.txt [new file with mode: 0644]
LayoutTests/inspector/debugger-step-out.html [new file with mode: 0644]
LayoutTests/inspector/debugger-step-over-expected.txt [new file with mode: 0644]
LayoutTests/inspector/debugger-step-over.html [new file with mode: 0644]
LayoutTests/platform/chromium/inspector/debugger-step-in-expected.txt [new file with mode: 0755]
WebCore/ChangeLog
WebCore/bindings/js/ScriptDebugServer.cpp
WebKit/chromium/ChangeLog
WebKit/chromium/src/js/Tests.js

index 2d52cdd..b838e16 100644 (file)
@@ -2,6 +2,28 @@
 
         Reviewed by Pavel Feldman.
 
+        Web Inspector: upstream Chromium debugger step tests
+        https://bugs.webkit.org/show_bug.cgi?id=44106
+
+        * http/tests/inspector-enabled/console-log-before-frame-navigation.html:
+        * http/tests/inspector-enabled/resources/console-log-before-frame-navigation.js: Added.
+        (doit.callback):
+        (doit):
+        (receiveMessage):
+        (frontend_dumpConsoleMessages):
+        * http/tests/inspector/debugger-test.js:
+        (frontend_captureStackTrace):
+        * inspector/debugger-step-in-expected.txt: Added.
+        * inspector/debugger-step-in.html: Added.
+        * inspector/debugger-step-out-expected.txt: Added.
+        * inspector/debugger-step-out.html: Added.
+        * inspector/debugger-step-over-expected.txt: Added.
+        * inspector/debugger-step-over.html: Added.
+
+2010-08-17  Yury Semikhatsky  <yurys@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
         [Qt] Web Inspector: inspector/debugger-pause-on-debugger-statement.html times out on Qt
         https://bugs.webkit.org/show_bug.cgi?id=41142
 
index 2743916..0f87013 100644 (file)
@@ -99,3 +99,15 @@ function frontend_showScriptSource(scriptName, callback)
     var view = scriptsPanel.visibleView;
     frontend_ensureSourceFrameLoaded(view.sourceFrame, callback.bind(null, view));
 };
+
+function frontend_captureStackTrace(callFrames, testController)
+{
+    testController.results.push("Call stack:");
+    for (var i = 0; i < callFrames.length; i++) {
+        var frame = callFrames[i];
+        var scriptOrResource = WebInspector.panels.scripts._sourceIDMap[frame.sourceID];
+        var url = scriptOrResource && WebInspector.displayNameForURL(scriptOrResource.sourceURL || scriptOrResource.url);
+        var s = "    " + i + ") " + frame.functionName + " (" + url + ":" + frame.line + ")";
+        testController.results.push(s);
+    }
+}
diff --git a/LayoutTests/inspector/debugger-step-in-expected.txt b/LayoutTests/inspector/debugger-step-in-expected.txt
new file mode 100644 (file)
index 0000000..78771ae
--- /dev/null
@@ -0,0 +1,19 @@
+Tests "step in" functionality in debugger.
+
+Debugger was enabled.
+Set timer for test function.
+Script execution paused.
+Call stack:
+    0) testFunction (debugger-step-in.html:12)
+Stepping into...
+Script execution paused.
+Call stack:
+    0) testFunction (debugger-step-in.html:13)
+Stepping into...
+Script execution paused.
+Call stack:
+    0) d (debugger-step-in.html:7)
+    1) testFunction (debugger-step-in.html:13)
+Resumed script execution.
+Disabled debugger.
+
diff --git a/LayoutTests/inspector/debugger-step-in.html b/LayoutTests/inspector/debugger-step-in.html
new file mode 100644 (file)
index 0000000..336a6e6
--- /dev/null
@@ -0,0 +1,62 @@
+<html>
+<head>
+<script src="../http/tests/inspector/inspector-test.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
+<script>
+
+function d() {
+    var i = 10;
+}
+
+function testFunction() {
+    debugger;
+    d();
+    notifyDone();
+}
+
+function doit()
+{
+    evaluateInWebInspector("frontend_testStepIn", dumpArray);
+}
+
+function frontend_testStepIn(testController)
+{
+    testController.waitUntilDone();
+
+    WebInspector.showPanel("scripts");
+    frontend_ensureDebuggerEnabled(debuggerWasEnabledCallback);
+
+    function debuggerWasEnabledCallback()
+    {
+        testController.results.push("Debugger was enabled.");
+        frontend_evaluateInConsole("setTimeout(testFunction, 0)", function(result)
+        {
+            testController.results.push("Set timer for test function.");
+        });
+    }
+
+    var stepCount = 0;
+    frontend_addSniffer(WebInspector, "pausedScript", function(callFrames)
+    {
+        testController.results.push("Script execution paused.");
+        frontend_captureStackTrace(callFrames, testController);
+        if (stepCount == 2)
+            frontend_completeDebuggerTest(testController);
+        else {
+            testController.results.push("Stepping into...");
+            document.getElementById("scripts-step-into").click();
+        }
+        stepCount++;
+    }, true);
+}
+
+</script>
+</head>
+
+<body onload="onload()">
+<p>
+Tests "step in" functionality in debugger.
+</p>
+
+</body>
+</html>
diff --git a/LayoutTests/inspector/debugger-step-out-expected.txt b/LayoutTests/inspector/debugger-step-out-expected.txt
new file mode 100644 (file)
index 0000000..1d89894
--- /dev/null
@@ -0,0 +1,15 @@
+Tests "step out" functionality in debugger.
+
+Debugger was enabled.
+Set timer for test function.
+Script execution paused.
+Call stack:
+    0) d (debugger-step-out.html:8)
+    1) testFunction (debugger-step-out.html:12)
+Stepping out...
+Script execution paused.
+Call stack:
+    0) testFunction (debugger-step-out.html:13)
+Resumed script execution.
+Disabled debugger.
+
diff --git a/LayoutTests/inspector/debugger-step-out.html b/LayoutTests/inspector/debugger-step-out.html
new file mode 100644 (file)
index 0000000..02fec1a
--- /dev/null
@@ -0,0 +1,65 @@
+<html>
+<head>
+<script src="../http/tests/inspector/inspector-test.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
+<script>
+
+function d() {
+    debugger;
+}
+
+function testFunction() {
+    d();
+    notifyDone();
+}
+
+function doit()
+{
+    evaluateInWebInspector("frontend_testStepOut", dumpArray);
+}
+
+function frontend_testStepOut(testController)
+{
+    testController.waitUntilDone();
+
+    WebInspector.showPanel("scripts");
+    frontend_ensureDebuggerEnabled(debuggerWasEnabledCallback);
+
+    function debuggerWasEnabledCallback()
+    {
+        testController.results.push("Debugger was enabled.");
+        frontend_evaluateInConsole("setTimeout(testFunction, 0)", function(result)
+        {
+            testController.results.push("Set timer for test function.");
+        });
+    }
+
+    frontend_addSniffer(WebInspector, "pausedScript", function(callFrames)
+    {
+        testController.results.push("Script execution paused.");
+        frontend_captureStackTrace(callFrames, testController);
+        testStepOut();
+    });
+
+    function testStepOut() {
+        frontend_addSniffer(WebInspector, "pausedScript", function(callFrames)
+        {
+            testController.results.push("Script execution paused.");
+            frontend_captureStackTrace(callFrames, testController);
+            frontend_completeDebuggerTest(testController);
+        });
+        testController.results.push("Stepping out...");
+        document.getElementById("scripts-step-out").click();
+    }
+}
+
+</script>
+</head>
+
+<body onload="onload()">
+<p>
+Tests "step out" functionality in debugger.
+</p>
+
+</body>
+</html>
diff --git a/LayoutTests/inspector/debugger-step-over-expected.txt b/LayoutTests/inspector/debugger-step-over-expected.txt
new file mode 100644 (file)
index 0000000..8b70488
--- /dev/null
@@ -0,0 +1,21 @@
+Tests "step over" functionality in debugger.
+
+Debugger was enabled.
+Set timer for test function.
+Script execution paused.
+Call stack:
+    0) d (debugger-step-over.html:12)
+    1) testFunction (debugger-step-over.html:17)
+Stepping over...
+Script execution paused.
+Call stack:
+    0) d (debugger-step-over.html:13)
+    1) testFunction (debugger-step-over.html:17)
+Stepping over...
+Script execution paused.
+Call stack:
+    0) d (debugger-step-over.html:14)
+    1) testFunction (debugger-step-over.html:17)
+Resumed script execution.
+Disabled debugger.
+
diff --git a/LayoutTests/inspector/debugger-step-over.html b/LayoutTests/inspector/debugger-step-over.html
new file mode 100644 (file)
index 0000000..8db4a9f
--- /dev/null
@@ -0,0 +1,66 @@
+<html>
+<head>
+<script src="../http/tests/inspector/inspector-test.js"></script>
+<script src="../http/tests/inspector/debugger-test.js"></script>
+<script>
+
+function f() {
+    var i = 10;
+}
+
+function d() {
+    debugger;
+    f();
+}
+
+function testFunction() {
+    d();
+    notifyDone();
+}
+
+function doit()
+{
+    evaluateInWebInspector("frontend_testStepIn", dumpArray);
+}
+
+function frontend_testStepIn(testController)
+{
+    testController.waitUntilDone();
+
+    WebInspector.showPanel("scripts");
+    frontend_ensureDebuggerEnabled(debuggerWasEnabledCallback);
+
+    function debuggerWasEnabledCallback()
+    {
+        testController.results.push("Debugger was enabled.");
+        frontend_evaluateInConsole("setTimeout(testFunction, 0)", function(result)
+        {
+            testController.results.push("Set timer for test function.");
+        });
+    }
+
+    var stepCount = 0;
+    frontend_addSniffer(WebInspector, "pausedScript", function(callFrames)
+    {
+        testController.results.push("Script execution paused.");
+        frontend_captureStackTrace(callFrames, testController);
+        if (stepCount == 2)
+            frontend_completeDebuggerTest(testController);
+        else {
+            testController.results.push("Stepping over...");
+            document.getElementById("scripts-step-over").click();
+        }
+        stepCount++;
+    }, true);
+}
+
+</script>
+</head>
+
+<body onload="onload()">
+<p>
+Tests "step over" functionality in debugger.
+</p>
+
+</body>
+</html>
diff --git a/LayoutTests/platform/chromium/inspector/debugger-step-in-expected.txt b/LayoutTests/platform/chromium/inspector/debugger-step-in-expected.txt
new file mode 100755 (executable)
index 0000000..72af6e8
--- /dev/null
@@ -0,0 +1,18 @@
+Tests "step in" functionality in debugger.\r
+\r
+Debugger was enabled.\r
+Set timer for test function.\r
+Script execution paused.\r
+Call stack:\r
+    0) testFunction (debugger-step-in.html:12)\r
+Stepping into...\r
+Script execution paused.\r
+Call stack:\r
+    0) testFunction (debugger-step-in.html:13)\r
+Stepping into...\r
+Script execution paused.\r
+Call stack:\r
+    0) d (debugger-step-in.html:8)\r
+    1) testFunction (debugger-step-in.html:13)\r
+Resumed script execution.\r
+Disabled debugger.\r
index 933f72d..b8bae69 100644 (file)
@@ -1,3 +1,18 @@
+2010-08-17  Yury Semikhatsky  <yurys@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: upstream Chromium debugger step tests
+        https://bugs.webkit.org/show_bug.cgi?id=44106
+
+        Tests: inspector/debugger-step-in.html
+               inspector/debugger-step-out.html
+               inspector/debugger-step-over.html
+
+        * bindings/js/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::returnEvent): check that debugger is still attached after continue to ensure
+        that current call frame is not 0.
+
 2010-08-17  Ademar de Souza Reis Jr  <ademar.reis@openbossa.org>
 
         Reviewed by David Levin.
index 8d47b78..cd80de4 100644 (file)
@@ -497,6 +497,10 @@ void ScriptDebugServer::returnEvent(const DebuggerCallFrame& debuggerCallFrame,
     m_currentCallFrame->update(debuggerCallFrame, sourceID, lineNumber);
     pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject()));
 
+    // detach may have been called during pauseIfNeeded
+    if (!m_currentCallFrame)
+        return;
+
     // Treat stepping over a return statement like stepping out.
     if (m_currentCallFrame == m_pauseOnCallFrame)
         m_pauseOnCallFrame = m_currentCallFrame->caller();
index cf62475..1eda449 100644 (file)
@@ -1,3 +1,12 @@
+2010-08-17  Yury Semikhatsky  <yurys@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: upstream Chromium debugger step tests
+        https://bugs.webkit.org/show_bug.cgi?id=44106
+
+        * src/js/Tests.js:
+
 2010-08-17  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r65500.
index d8242e8..41574b4 100644 (file)
@@ -1069,25 +1069,6 @@ TestSuite.prototype._checkSourceFrameWhenLoaded = function(expectations, callbac
 
 
 /**
- * Performs sequence of steps.
- * @param {Array.<Object|Function>} Array [expectations1,action1,expectations2,
- *     action2,...,actionN].
- */
-TestSuite.prototype._performSteps = function(actions)
-{
-    var test = this;
-    var i = 0;
-    function doNextAction() {
-        if (i > 0)
-            actions[i++]();
-        if (i < actions.length - 1)
-            test._waitForScriptPause(actions[i++], doNextAction);
-    }
-    doNextAction();
-};
-
-
-/**
  * Waits until all the scripts are parsed and asynchronously executes the code
  * in the inspected page.
  */
@@ -1128,131 +1109,6 @@ TestSuite.prototype._waitUntilScriptsAreParsed = function(expectedScripts, callb
 
 
 /**
- * Waits until all debugger scripts are parsed and executes "a()" in the
- * inspected page.
- */
-TestSuite.prototype._executeFunctionForStepTest = function()
-{
-    this._executeCodeWhenScriptsAreParsed("a()", ["debugger_step.html", "debugger_step.js"]);
-};
-
-
-/**
- * Tests step over in the debugger.
- */
-TestSuite.prototype.testStepOver = function()
-{
-    this.showPanel("scripts");
-    var test = this;
-
-    this._executeFunctionForStepTest();
-
-    this._performSteps([
-        {
-            functionsOnStack: ["d","a",""],
-            lineNumber: 3,
-            lineText: "    debugger;"
-        },
-        function() {
-            document.getElementById("scripts-step-over").click();
-        },
-        {
-            functionsOnStack: ["d","a",""],
-            lineNumber: 5,
-            lineText: "  var y = fact(10);"
-        },
-        function() {
-            document.getElementById("scripts-step-over").click();
-        },
-        {
-            functionsOnStack: ["d","a",""],
-            lineNumber: 6,
-            lineText: "  return y;"
-        },
-        function() {
-            test.releaseControl();
-        }
-    ]);
-
-    test.takeControl();
-};
-
-
-/**
- * Tests step out in the debugger.
- */
-TestSuite.prototype.testStepOut = function()
-{
-    this.showPanel("scripts");
-    var test = this;
-
-    this._executeFunctionForStepTest();
-
-    this._performSteps([
-        {
-            functionsOnStack: ["d","a",""],
-            lineNumber: 3,
-            lineText: "    debugger;"
-        },
-        function() {
-            document.getElementById("scripts-step-out").click();
-        },
-        {
-            functionsOnStack: ["a",""],
-            lineNumber: 8,
-            lineText: "  printResult(result);"
-        },
-        function() {
-            test.releaseControl();
-        }
-    ]);
-
-    test.takeControl();
-};
-
-
-/**
- * Tests step in in the debugger.
- */
-TestSuite.prototype.testStepIn = function()
-{
-    this.showPanel("scripts");
-    var test = this;
-
-    this._executeFunctionForStepTest();
-
-    this._performSteps([
-        {
-            functionsOnStack: ["d","a",""],
-            lineNumber: 3,
-            lineText: "    debugger;"
-        },
-        function() {
-            document.getElementById("scripts-step-over").click();
-        },
-        {
-            functionsOnStack: ["d","a",""],
-            lineNumber: 5,
-            lineText: "  var y = fact(10);"
-        },
-        function() {
-            document.getElementById("scripts-step-into").click();
-        },
-        {
-            functionsOnStack: ["fact","d","a",""],
-            lineNumber: 10,
-            lineText: "  var r = 1;"
-        },
-        function() {
-            test.releaseControl();
-        }
-    ]);
-
-    test.takeControl();
-};
-
-
-/**
  * Gets a XPathResult matching given xpath.
  * @param {string} xpath
  * @param {number} resultType