Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: LayoutTests/inspector-protocol/cpu-profiler/console-profile.html

Issue 15816002: Remove console.profiles from window.console API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/cpu-profiler/console-profile-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/inspector-protocol/cpu-profiler/console-profile.html
diff --git a/LayoutTests/inspector-protocol/cpu-profiler/console-profile.html b/LayoutTests/inspector-protocol/cpu-profiler/console-profile.html
new file mode 100644
index 0000000000000000000000000000000000000000..e5ff5cb2b697a9cbfd3b24dc2c0bfe05173fa8f9
--- /dev/null
+++ b/LayoutTests/inspector-protocol/cpu-profiler/console-profile.html
@@ -0,0 +1,77 @@
+<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()
+{
+ InspectorTest.fail = function(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.sendCommand("Profiler.getProfileHeaders", {}, didReceiveProfileHeaders);
+ }
+
+ function didReceiveProfileHeaders(messageObject)
+ {
+ var headers = messageObject["result"]["headers"];
+ if (!headers || headers.length !== 2)
+ return InspectorTest.fail("Cannot retrive headers: " + JSON.stringify(messageObject, null, 4));
+ for (var i = 0; i < headers.length; i++) {
+ if (headers[i].title === "inner") {
+ InspectorTest.sendCommand("Profiler.getCPUProfile", { uid: headers[i].uid }, didGetProfile);
+ return;
+ }
+ }
+ InspectorTest.fail("Cannot find 'inner' profile header");
+ }
+
+ function didGetProfile(messageObject)
+ {
+ InspectorTest.log("SUCCESS: retrieved 'inner' profile");
+ var root = messageObject.result.profile.head;
+ if (!findFunctionInProfile(root, "collectProfiles"))
+ return InspectorTest.fail("collectProfiles function not found in the profile: " + JSON.stringify(messageObject, null, 4));
+ InspectorTest.log("SUCCESS: found 'collectProfiles' function in the profile");
+ InspectorTest.sendCommand("Profiler.clearProfiles", {});
+ InspectorTest.completeTest();
+ }
+
+ 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="runTest()">
+<p>
+Tests that console.profile/profileEnd will record CPU profile when inspector front-end is connected.<br>
+</p>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/inspector-protocol/cpu-profiler/console-profile-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698