Web Inspector: Port some profiler tests to inspector-protocol
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2014 02:50:20 +0000 (02:50 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2014 02:50:20 +0000 (02:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129353

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2014-02-25
Reviewed by Timothy Hatcher.

* inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash-expected.txt: Removed.
* inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash.html: Removed.
* inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector-expected.txt: Removed.
* inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector.html: Removed.
* inspector-protocol/profiler/console-profile-expected.txt: Added.
* inspector-protocol/profiler/console-profile.html: Added.
* inspector-protocol/profiler/console-profileEnd-parameterless-expected.txt: Added.
* inspector-protocol/profiler/console-profileEnd-parameterless.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash-expected.txt [deleted file]
LayoutTests/inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash.html [deleted file]
LayoutTests/inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector-expected.txt [deleted file]
LayoutTests/inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector.html [deleted file]
LayoutTests/inspector-protocol/profiler/console-profile-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/profiler/console-profile.html [new file with mode: 0644]
LayoutTests/inspector-protocol/profiler/console-profileEnd-parameterless-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/profiler/console-profileEnd-parameterless.html [new file with mode: 0644]

index 9fc5364..919cef5 100644 (file)
@@ -1,3 +1,19 @@
+2014-02-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Port some profiler tests to inspector-protocol
+        https://bugs.webkit.org/show_bug.cgi?id=129353
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash-expected.txt: Removed.
+        * inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash.html: Removed.
+        * inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector-expected.txt: Removed.
+        * inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector.html: Removed.
+        * inspector-protocol/profiler/console-profile-expected.txt: Added.
+        * inspector-protocol/profiler/console-profile.html: Added.
+        * inspector-protocol/profiler/console-profileEnd-parameterless-expected.txt: Added.
+        * inspector-protocol/profiler/console-profileEnd-parameterless.html: Added.
+
 2014-02-25  Samuel White  <samuel_white@apple.com>
 
         Add accessibility search predicate support for AXOutlines
diff --git a/LayoutTests/inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash-expected.txt b/LayoutTests/inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash-expected.txt
deleted file mode 100644 (file)
index 197dcf0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Tests that "console.profileEnd()" do not cause crash.
-Bug 105759.
-
-Profiles count: 2
-Titled profile found.
-
diff --git a/LayoutTests/inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash.html b/LayoutTests/inspector-obsolete/profiler/cpu-profiler-parameterless-profile-end-crash.html
deleted file mode 100644 (file)
index 5de6a1b..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<html>
-<head>
-<script>
-
-if (window.testRunner)
-    testRunner.dumpAsText();
-if (window.internals)
-    internals.setJavaScriptProfilingEnabled(true);
-
-function pageFunction()
-{
-    console.profile(); // Untitled
-    console.profile("titled");
-    console.profileEnd();
-    console.profileEnd();
-}
-
-function startTest()
-{
-    pageFunction();
-    printResult();
-    if (window.testRunner)
-        testRunner.notifyDone();
-}
-
-function printResult()
-{
-    var preElement = document.createElement("pre");
-    preElement.appendChild(document.createTextNode("\n"));
-
-    var profiles = console.profiles;
-    preElement.appendChild(document.createTextNode("Profiles count: " + profiles.length + "\n"));
-    for (var i = 0; i < profiles.length; ++i) {
-        if (profiles[i].title === "titled")
-            preElement.appendChild(document.createTextNode("Titled profile found.\n"));
-    }
-    document.getElementById("output").appendChild(preElement);
-}
-
-</script>
-</head>
-<body onload="startTest()">
-<p>
-Tests that "console.profileEnd()" do not cause crash.<br>
-<a href="https://bugs.webkit.org/show_bug.cgi?id=105759">Bug 105759.</a><br>
-<div id="output"></div>
-</p>
-</body>
-</html>
diff --git a/LayoutTests/inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector-expected.txt b/LayoutTests/inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector-expected.txt
deleted file mode 100644 (file)
index 33ef740..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Tests that CPU profiling works.
-Doesn't open Inspector, uses console.profile....
-
-
-Found pageFunction
-
diff --git a/LayoutTests/inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector.html b/LayoutTests/inspector-obsolete/profiler/cpu-profiler-profiling-without-inspector.html
deleted file mode 100644 (file)
index 22e3a99..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<html>
-<head>
-<script>
-
-if (window.testRunner)
-    testRunner.dumpAsText();
-if (window.internals)
-    internals.setJavaScriptProfilingEnabled(true);
-
-function pageFunction()
-{
-    console.profile("outer");
-    console.profile("inner");  // [Chromium] Make sure we capture the current callstack.
-    console.profileEnd("outer");
-    console.profileEnd("inner");
-}
-
-function startTest()
-{
-    pageFunction();
-    printResult();
-    if (window.testRunner)
-        testRunner.notifyDone();
-}
-
-function printResult()
-{
-    var preElement = document.createElement("pre");
-    preElement.appendChild(document.createTextNode("\n"));
-
-    var profiles = console.profiles;
-    for (var i = 0; i < profiles.length; ++i) {
-        var profile = profiles[i];
-        if (profile.title !== "inner")
-            continue;
-        var functionName = "pageFunction";
-        if (findFunctionInProfile(profile.head, functionName))
-            preElement.appendChild(document.createTextNode("Found " + functionName));
-        else {
-            preElement.appendChild(document.createTextNode("!!! Not found " + functionName));
-            preElement.appendChild(document.createTextNode("\n\n"));
-            printProfileNodeWithoutTime(preElement, profile.head, "");
-        }
-        preElement.appendChild(document.createTextNode("\n"));
-    }
-
-    document.getElementById("output").appendChild(preElement);
-}
-
-function printProfileNodeWithoutTime(preElement, node, space)
-{
-    if (!node.visible)
-        return;
-
-    var line = space + node.functionName + " (line " + node.lineNumber + ")\n";
-    preElement.appendChild(document.createTextNode(line));
-
-    var children = node.children();
-    for (var i = 0; i < children.length; ++i)
-        printProfileNodeWithoutTime(preElement, children[i], space + "   ");
-}
-
-function findFunctionInProfile(node, functionName)
-{
-    if (node.functionName === functionName)
-        return true;
-    var children = node.children();
-    for (var i = 0; i < children.length; ++i)
-        if (findFunctionInProfile(children[i], functionName))
-            return true;
-    return false;
-}
-
-</script>
-</head>
-<body onload="startTest()">
-<p>
-Tests that CPU profiling works.<br>
-Doesn't open Inspector, uses <b>console.profile...</b>.
-
-<div id="output"></div>
-</p>
-</body>
-</html>
diff --git a/LayoutTests/inspector-protocol/profiler/console-profile-expected.txt b/LayoutTests/inspector-protocol/profiler/console-profile-expected.txt
new file mode 100644 (file)
index 0000000..a4ca88f
--- /dev/null
@@ -0,0 +1,4 @@
+Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.
+SUCCESS: retrieved 'inner' profile
+SUCCESS: found 'collectProfiles' function in the profile
+
diff --git a/LayoutTests/inspector-protocol/profiler/console-profile.html b/LayoutTests/inspector-protocol/profiler/console-profile.html
new file mode 100644 (file)
index 0000000..4d69da4
--- /dev/null
@@ -0,0 +1,87 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
+<script>
+function collectProfiles()
+{
+    console.profile("outer");
+    console.profile("inner");
+    console.profileEnd("outer");
+    console.profileEnd("inner");
+}
+
+function test()
+{
+    function fail(message)
+    {
+        InspectorTest.log("FAIL: " + message);
+        InspectorTest.completeTest();
+    }
+
+    InspectorTest.sendCommand("Profiler.enable", {});
+    InspectorTest.sendCommand("Runtime.evaluate", {expression: "collectProfiles()"}, didCollectProfiles);
+
+    InspectorTest.eventHandler["Profiler.addProfileHeader"] = function(messageObject)
+    {
+        InspectorTest.log("FAIL: unexpected header = " + JSON.stringify(messageObject, null, 4));
+    }
+
+    function didCollectProfiles(messageObject)
+    {
+        InspectorTest.checkForError(messageObject);
+        InspectorTest.sendCommand("Profiler.getProfileHeaders", {}, didReceiveProfileHeaders);
+    }
+
+    function didReceiveProfileHeaders(messageObject)
+    {
+        InspectorTest.checkForError(messageObject);
+
+        var headers = messageObject["result"]["headers"];
+        if (!headers || headers.length !== 2) {
+            fail("Cannot retrive headers: " + JSON.stringify(messageObject, null, 4));
+            return;
+        }
+
+        for (var i = 0; i < headers.length; i++) {
+            if (headers[i].title === "inner") {
+                InspectorTest.sendCommand("Profiler.getCPUProfile", { uid: headers[i].uid }, didGetProfile);
+                return;
+            }
+        }
+
+        fail("Cannot find 'inner' profile header");
+    }
+
+    function didGetProfile(messageObject)
+    {
+        InspectorTest.checkForError(messageObject);
+        InspectorTest.log("SUCCESS: retrieved 'inner' profile");
+
+        var rootNodes = messageObject.result.profile.rootNodes;
+        if (!findFunctionInProfile(rootNodes, "collectProfiles")) {
+            fail("collectProfiles function not found in the profile: " + JSON.stringify(messageObject, null, 4));
+            return;
+        }
+
+        InspectorTest.log("SUCCESS: found 'collectProfiles' function in the profile");
+        InspectorTest.sendCommand("Profiler.clearProfiles", {});
+        InspectorTest.completeTest();
+    }
+
+    function findFunctionInProfile(rootNodes, functionName)
+    {
+        for (var i = 0; i < rootNodes.length; ++i)
+            if (rootNodes[i].functionName === functionName)
+                return true;
+
+        return false;
+    }
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>
+Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.<br>
+</p>
+</body>
+</html>
diff --git a/LayoutTests/inspector-protocol/profiler/console-profileEnd-parameterless-expected.txt b/LayoutTests/inspector-protocol/profiler/console-profileEnd-parameterless-expected.txt
new file mode 100644 (file)
index 0000000..a346d38
--- /dev/null
@@ -0,0 +1,5 @@
+Tests that "console.profileEnd()" does not cause crash.
+Bug 105759.
+SUCCESS: found 2 profile headers
+SUCCESS: titled profile found
+
diff --git a/LayoutTests/inspector-protocol/profiler/console-profileEnd-parameterless.html b/LayoutTests/inspector-protocol/profiler/console-profileEnd-parameterless.html
new file mode 100644 (file)
index 0000000..3107d93
--- /dev/null
@@ -0,0 +1,66 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
+<script>
+function collectProfiles()
+{
+    console.profile();
+    console.profile("titled");
+    console.profileEnd();
+    console.profileEnd();
+}
+
+function test()
+{
+    function fail(message)
+    {
+        InspectorTest.log("FAIL: " + message);
+        InspectorTest.completeTest();
+    }
+
+    InspectorTest.sendCommand("Profiler.enable", {});
+    InspectorTest.sendCommand("Runtime.evaluate", {expression: "collectProfiles()"}, didCollectProfiles);
+
+    InspectorTest.eventHandler["Profiler.addProfileHeader"] = function(messageObject)
+    {
+        InspectorTest.log("FAIL: unexpected header = " + JSON.stringify(messageObject, null, 4));
+    }
+
+    function didCollectProfiles(messageObject)
+    {
+        InspectorTest.checkForError(messageObject);
+        InspectorTest.sendCommand("Profiler.getProfileHeaders", {}, didReceiveProfileHeaders);
+    }
+
+    function didReceiveProfileHeaders(messageObject)
+    {
+        InspectorTest.checkForError(messageObject);
+
+        var headers = messageObject["result"]["headers"];
+        if (!headers || headers.length !== 2) {
+            fail("Cannot retrive headers: " + JSON.stringify(messageObject, null, 4));
+            return;
+        }
+
+        InspectorTest.log("SUCCESS: found 2 profile headers");
+        for (var i = 0; i < headers.length; i++) {
+            if (headers[i].title === "titled") {
+                InspectorTest.log("SUCCESS: titled profile found");
+                InspectorTest.sendCommand("Profiler.clearProfiles", {});
+                InspectorTest.completeTest();
+                return;
+            }
+        }
+
+        fail("Cannot find titled profile");
+    }
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>
+Tests that "console.profileEnd()" does not cause crash.<br>
+<a href="https://bugs.webkit.org/show_bug.cgi?id=105759">Bug 105759.</a><br>
+</p>
+</body>
+</html>