Title: [246798] trunk
Revision
246798
Author
[email protected]
Date
2019-06-25 11:36:29 -0700 (Tue, 25 Jun 2019)

Log Message

Web Inspector: Implement console.timeLog
https://bugs.webkit.org/show_bug.cgi?id=199184

Reviewed by Devin Rousso.

Source/_javascript_Core:

* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::timeLog):
* inspector/JSGlobalObjectConsoleClient.h:
* inspector/agents/InspectorConsoleAgent.cpp:
(Inspector::InspectorConsoleAgent::logTiming):
(Inspector::InspectorConsoleAgent::stopTiming):
* inspector/agents/InspectorConsoleAgent.h:
* runtime/ConsoleClient.h:
* runtime/ConsoleObject.cpp:
(JSC::ConsoleObject::finishCreation):
(JSC::consoleProtoFuncTimeLog):

Source/WebCore:

Updated existing tests.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::logConsoleTimingImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::logConsoleTiming):
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::timeLog):
* page/PageConsoleClient.h:
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::timeLog):
* workers/WorkerConsoleClient.h:
* worklets/WorkletConsoleClient.cpp:
(WebCore::WorkletConsoleClient::timeLog):
* worklets/WorkletConsoleClient.h:

Source/WebInspectorUI:

* UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype._appendMessageTextAndArguments):
Time messages (like timeLog) do not include their messageText
in their parameters list. So to behave more like normal logs
build a parameter list that includes it at the front.

LayoutTests:

* inspector/console/console-time-expected.txt:
* inspector/console/console-time.html:
Add new timeLog tests.

* js/console-expected.txt:
New timeLog method.

* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
Unskip test.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (246797 => 246798)


--- trunk/LayoutTests/ChangeLog	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/LayoutTests/ChangeLog	2019-06-25 18:36:29 UTC (rev 246798)
@@ -1,3 +1,21 @@
+2019-06-25  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Implement console.timeLog
+        https://bugs.webkit.org/show_bug.cgi?id=199184
+
+        Reviewed by Devin Rousso.
+
+        * inspector/console/console-time-expected.txt:
+        * inspector/console/console-time.html:
+        Add new timeLog tests.
+
+        * js/console-expected.txt:
+        New timeLog method.
+
+        * platform/gtk/TestExpectations:
+        * platform/mac/TestExpectations:
+        Unskip test.
+
 2019-06-25  Fujii Hironori  <[email protected]>
 
         Unreviewed test gardening

Modified: trunk/LayoutTests/inspector/console/console-time-expected.txt (246797 => 246798)


--- trunk/LayoutTests/inspector/console/console-time-expected.txt	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/LayoutTests/inspector/console/console-time-expected.txt	2019-06-25 18:36:29 UTC (rev 246798)
@@ -1,8 +1,8 @@
-Tests for the console.time and console.timeEnd APIs.
+Tests for the console.time, console.timeLog, and console.timeEnd APIs.
 
 
-== Running test suite: console.time and console.timeEnd
--- Running test case: DefaultLabel
+== Running test suite: console.time
+-- Running test case: console.time.DefaultLabel
 PASS: Should receive a Timing type message.
 PASS: Message should contain the 'default' label name somewhere.
 PASS: Should receive a Timing type message.
@@ -9,24 +9,59 @@
 PASS: Message should contain the 'default' label name somewhere.
 PASS: Should receive a Timing type message.
 PASS: Message should contain the 'default' label name somewhere.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'default' label name somewhere.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'default' label name somewhere.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'default' label name somewhere.
 
--- Running test case: UserLabels
+-- Running test case: console.time.UserLabels
 PASS: Should receive a Timing type message.
 PASS: Message should contain the 'my-label' label name somewhere.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'my-label' label name somewhere.
 
--- Running test case: MultipleTimers
+-- Running test case: console.time.MultipleTimers
 PASS: Should receive a Timing type message.
 PASS: Message should contain the 'my-label-2' label name somewhere.
 PASS: Should receive a Timing type message.
 PASS: Message should contain the 'my-label-1' label name somewhere.
 
--- Running test case: WarnWhenExisting
+-- Running test case: console.time.WarnWhenExisting
 PASS: Should receive a Timing type message.
 PASS: Should receive a Warning level message
 PASS: Message should contain the 'default' label name somewhere.
 
--- Running test case: WarnWhenNotExisting
+-- Running test case: console.time.WarnWhenNotExisting
 PASS: Should receive a Timing type message.
 PASS: Should receive a Warning level message.
 PASS: Message should contain the 'default' label name somewhere.
+PASS: Should receive a Timing type message.
+PASS: Should receive a Warning level message.
+PASS: Message should contain the 'default' label name somewhere.
 
+-- Running test case: console.time.TimeLogIncreasing
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'my-timelog-label' label name somewhere.
+PASS: + Initial timer time seen.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'my-timelog-label' label name somewhere.
+PASS: + Timer time should be increasing.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'my-timelog-label' label name somewhere.
+PASS: + Timer time should be increasing.
+PASS: Should receive a Timing type message.
+PASS: Message should contain the 'my-timelog-label' label name somewhere.
+PASS: + Timer time should be increasing.
+
+-- Running test case: console.time.TimeLogArguments
+PASS: Should receive a Timing type message.
+PASS: timeLog should contain no parameters
+PASS: Should receive a Timing type message.
+PASS: timeLog should contain 1 parameters
+PASS: Should receive a Timing type message.
+PASS: timeLog should contain 2 parameters
+PASS: Should receive a Timing type message.
+PASS: timeEnd should contain no parameters
+

Modified: trunk/LayoutTests/inspector/console/console-time.html (246797 => 246798)


--- trunk/LayoutTests/inspector/console/console-time.html	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/LayoutTests/inspector/console/console-time.html	2019-06-25 18:36:29 UTC (rev 246798)
@@ -3,16 +3,22 @@
 <head>
 <script src=""
 <script>
+function sleepTick() {
+    let now = performance.now();
+    let until = now + 10;
+    while (performance.now() < until);
+}
+
 function test()
 {
-    let suite = InspectorTest.createAsyncSuite("console.time and console.timeEnd");
+    let suite = InspectorTest.createAsyncSuite("console.time");
 
     suite.addTestCase({
-        name: "DefaultLabel",
+        name: "console.time.DefaultLabel",
         description: "Test that default label works as expected.",
         test(resolve, reject) {
             let seen = 0;
-            const expected = 3;
+            const expected = 6;
             WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
             function handler(event) {
                 let message = event.data.message;
@@ -24,36 +30,45 @@
                 }
             }
 
-            InspectorTest.evaluateInPage("console.time()");
-            InspectorTest.evaluateInPage("console.timeEnd()");
+            InspectorTest.evaluateInPage(`console.time()`);
+            InspectorTest.evaluateInPage(`console.timeLog()`);
+            InspectorTest.evaluateInPage(`console.timeEnd()`);
 
-            InspectorTest.evaluateInPage("console.time(undefined)");
-            InspectorTest.evaluateInPage("console.timeEnd('default')");
+            InspectorTest.evaluateInPage(`console.time(undefined)`);
+            InspectorTest.evaluateInPage(`console.timeLog('default')`);
+            InspectorTest.evaluateInPage(`console.timeEnd('default')`);
 
-            InspectorTest.evaluateInPage("console.time('default')");
-            InspectorTest.evaluateInPage("console.timeEnd(undefined)");
+            InspectorTest.evaluateInPage(`console.time('default')`);
+            InspectorTest.evaluateInPage(`console.timeLog(undefined)`);
+            InspectorTest.evaluateInPage(`console.timeEnd(undefined)`);
         }
     });
 
     suite.addTestCase({
-        name: "UserLabels",
+        name: "console.time.UserLabels",
         description: "Test that user labels works as expected.",
         test(resolve, reject) {
-            WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.MessageAdded)
-            .then((event) => {
+            let seen = 0;
+            const expected = 2;
+            WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
+            function handler(event) {
                 let message = event.data.message;
                 InspectorTest.expectThat(message.type === WI.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
                 InspectorTest.expectThat(message.messageText.includes("my-label"), "Message should contain the 'my-label' label name somewhere.");
-            })
-            .then(resolve, reject);
+                if (++seen === expected) {
+                    WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
+                    resolve();
+                }
+            }
 
-            InspectorTest.evaluateInPage("console.time('my-label')");
-            InspectorTest.evaluateInPage("console.timeEnd('my-label')");
+            InspectorTest.evaluateInPage(`console.time('my-label')`);
+            InspectorTest.evaluateInPage(`console.timeLog('my-label')`);
+            InspectorTest.evaluateInPage(`console.timeEnd('my-label')`);
         }
     });
 
     suite.addTestCase({
-        name: "MultipleTimers",
+        name: "console.time.MultipleTimers",
         description: "Test that multiple timers running at the same time work as expected.",
         test(resolve, reject) {
             let seen = 0;
@@ -70,15 +85,15 @@
                 }
             }
 
-            InspectorTest.evaluateInPage("console.time('my-label-1')");
-            InspectorTest.evaluateInPage("console.time('my-label-2')");
-            InspectorTest.evaluateInPage("console.timeEnd('my-label-2')");
-            InspectorTest.evaluateInPage("console.timeEnd('my-label-1')");
+            InspectorTest.evaluateInPage(`console.time('my-label-1')`);
+            InspectorTest.evaluateInPage(`console.time('my-label-2')`);
+            InspectorTest.evaluateInPage(`console.timeEnd('my-label-2')`);
+            InspectorTest.evaluateInPage(`console.timeEnd('my-label-1')`);
         }
     });
 
     suite.addTestCase({
-        name: "WarnWhenExisting",
+        name: "console.time.WarnWhenExisting",
         description: "Test for a warning when trying to start an already started timer.",
         test(resolve, reject) {
             WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
@@ -96,34 +111,122 @@
                 }
             }
 
-            InspectorTest.evaluateInPage("console.time()");
-            InspectorTest.evaluateInPage("console.time()"); // Warning
-            InspectorTest.evaluateInPage("console.timeEnd()");
+            InspectorTest.evaluateInPage(`console.time()`);
+            InspectorTest.evaluateInPage(`console.time()`); // Warning
+            InspectorTest.evaluateInPage(`console.timeEnd()`);
         }
     });
 
     suite.addTestCase({
-        name: "WarnWhenNotExisting",
+        name: "console.time.WarnWhenNotExisting",
         description: "Test for a warning when trying to start an already started timer.",
         test(resolve, reject) {
-            WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.MessageAdded)
-            .then((event) => {
+            let seen = 0;
+            const expected = 2;
+            WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
+            function handler(event) {
                 let message = event.data.message;
+                if (message.type === WI.ConsoleMessage.MessageType.Clear)
+                    return;
+
                 InspectorTest.expectThat(message.type === WI.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
                 InspectorTest.expectThat(message.level === WI.ConsoleMessage.MessageLevel.Warning, "Should receive a Warning level message.");
                 InspectorTest.expectThat(message.messageText.includes("default"), "Message should contain the 'default' label name somewhere.");
-            })
-            .then(resolve, reject);
+                if (++seen === expected) {
+                    WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
+                    resolve();
+                }
+            }
 
-            InspectorTest.evaluateInPage("console.timeEnd()");
+            InspectorTest.evaluateInPage(`console.timeLog()`); // Warn
+            InspectorTest.evaluateInPage(`console.clear()`);
+            InspectorTest.evaluateInPage(`console.timeEnd()`); // Warn
         }
     });
 
+    suite.addTestCase({
+        name: "console.time.TimeLogIncreasing",
+        description: "Test for timeLog multiple times with a timer should increase.",
+        test(resolve, reject) {
+            let lastTime = 0;
+            let seen = 0;
+            const expected = 4;
+            WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
+            function handler(event) {
+                let message = event.data.message;
+                InspectorTest.expectThat(message.type === WI.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
+                InspectorTest.expectThat(message.messageText.includes("my-timelog-label"), "Message should contain the 'my-timelog-label' label name somewhere.");
+
+                let match = message.messageText.match(/^my-timelog-label: (\d+(\.\d+)?ms)/)
+                if (match) {
+                    let currentTime = parseFloat(match[1]);
+                    if (lastTime) {
+                        InspectorTest.assert(currentTime > 15, "At least 15 milliseconds should have elapsed since this is for timeLog 2 and later.");
+                        InspectorTest.expectGreaterThan(currentTime, lastTime, "+ Timer time should be increasing.");
+                    } else
+                        InspectorTest.pass("+ Initial timer time seen.");
+                    lastTime = currentTime;
+                }
+
+                if (++seen === expected) {
+                    WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
+                    resolve();
+                }
+            }
+
+            InspectorTest.evaluateInPage(`console.time("my-timelog-label")`);
+            InspectorTest.evaluateInPage(`sleepTick(); console.timeLog("my-timelog-label")`);
+            InspectorTest.evaluateInPage(`sleepTick(); console.timeLog("my-timelog-label")`);
+            InspectorTest.evaluateInPage(`sleepTick(); console.timeLog("my-timelog-label")`);
+            InspectorTest.evaluateInPage(`sleepTick(); console.timeEnd("my-timelog-label")`);
+        }
+    });
+
+    suite.addTestCase({
+        name: "console.time.TimeLogArguments",
+        description: "Test for timeLog with trailing parameters.",
+        test(resolve, reject) {
+            let seen = 0;
+            const expected = 4;
+            WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
+            function handler(event) {
+                let message = event.data.message;
+                InspectorTest.expectThat(message.type === WI.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
+
+                switch (seen) {
+                case 0:
+                    InspectorTest.expectEqual(message.parameters, undefined, "timeLog should contain no parameters");
+                    break;
+                case 1:
+                    InspectorTest.expectEqual(message.parameters.length, 1, "timeLog should contain 1 parameters");
+                    break;
+                case 2:
+                    InspectorTest.expectEqual(message.parameters.length, 2, "timeLog should contain 2 parameters");
+                    break;
+                case 3:
+                    InspectorTest.expectEqual(message.parameters, undefined, "timeEnd should contain no parameters");
+                    break;
+                }
+
+                if (++seen === expected) {
+                    WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
+                    resolve();
+                }
+            }
+
+            InspectorTest.evaluateInPage(`console.time("x")`);
+            InspectorTest.evaluateInPage(`console.timeLog("x")`);
+            InspectorTest.evaluateInPage(`console.timeLog("x", 1)`);
+            InspectorTest.evaluateInPage(`console.timeLog("x", 2, window)`);
+            InspectorTest.evaluateInPage(`console.timeEnd("x")`);
+        }
+    });
+
     suite.runTestCasesAndFinish();
 }
 </script>
 </head>
 <body _onload_="runTest()">
-<p>Tests for the console.time and console.timeEnd APIs.</p>
+<p>Tests for the console.time, console.timeLog, and console.timeEnd APIs.</p>
 </body>
 </html>

Modified: trunk/LayoutTests/js/console-expected.txt (246797 => 246798)


--- trunk/LayoutTests/js/console-expected.txt	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/LayoutTests/js/console-expected.txt	2019-06-25 18:36:29 UTC (rev 246798)
@@ -121,6 +121,13 @@
 PASS descriptor.writable is true
 PASS descriptor.enumerable is true
 
+console.timeLog
+PASS typeof console.timeLog is "function"
+PASS console.timeLog.length is 0
+PASS descriptor.configurable is true
+PASS descriptor.writable is true
+PASS descriptor.enumerable is true
+
 console.timeEnd
 PASS typeof console.timeEnd is "function"
 PASS console.timeEnd.length is 0

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (246797 => 246798)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2019-06-25 18:36:29 UTC (rev 246798)
@@ -2135,8 +2135,6 @@
 webkit.org/b/197498 imported/w3c/web-platform-tests/web-animations/interfaces/Animation/ready.html [ Failure Pass ]
 webkit.org/b/197498 imported/w3c/web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html [ Failure Pass ]
 
-webkit.org/b/197499 inspector/console/console-time.html [ Failure Pass ]
-
 webkit.org/b/197500 legacy-animation-engine/compositing/repaint/become-overlay-composited-layer.html [ Failure Pass ]
 
 webkit.org/b/197501 fast/images/animated-webp.html [ ImageOnlyFailure Pass ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (246797 => 246798)


--- trunk/LayoutTests/platform/mac/TestExpectations	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2019-06-25 18:36:29 UTC (rev 246798)
@@ -1089,7 +1089,6 @@
 webkit.org/b/143719 inspector/console/console-api.html [ Pass Timeout ]
 webkit.org/b/156078 inspector/console/heapSnapshot.html [ Pass Timeout ]
 webkit.org/b/182620 inspector/console/clearMessages.html [ Pass Timeout ]
-webkit.org/b/158006 inspector/console/console-time.html [ Pass Failure ]
 webkit.org/b/183880 [ Debug ] inspector/console/messageAdded-from-named-evaluations.html [ Slow ]
 webkit.org/b/156634 inspector/formatting/formatting-_javascript_.html [ Pass Timeout ]
 webkit.org/b/158948 inspector/timeline [ Pass Timeout ]

Modified: trunk/Source/_javascript_Core/ChangeLog (246797 => 246798)


--- trunk/Source/_javascript_Core/ChangeLog	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-06-25 18:36:29 UTC (rev 246798)
@@ -1,3 +1,22 @@
+2019-06-25  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Implement console.timeLog
+        https://bugs.webkit.org/show_bug.cgi?id=199184
+
+        Reviewed by Devin Rousso.
+
+        * inspector/JSGlobalObjectConsoleClient.cpp:
+        (Inspector::JSGlobalObjectConsoleClient::timeLog):
+        * inspector/JSGlobalObjectConsoleClient.h:
+        * inspector/agents/InspectorConsoleAgent.cpp:
+        (Inspector::InspectorConsoleAgent::logTiming):
+        (Inspector::InspectorConsoleAgent::stopTiming):
+        * inspector/agents/InspectorConsoleAgent.h:
+        * runtime/ConsoleClient.h:
+        * runtime/ConsoleObject.cpp:
+        (JSC::ConsoleObject::finishCreation):
+        (JSC::consoleProtoFuncTimeLog):
+
 2019-06-25  Michael Catanzaro  <[email protected]>
 
         REGRESSION(r245586): static assertion failed: Match result and EncodedMatchResult should be the same size

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp (246797 => 246798)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp	2019-06-25 18:36:29 UTC (rev 246798)
@@ -153,6 +153,11 @@
     m_consoleAgent->startTiming(title);
 }
 
+void JSGlobalObjectConsoleClient::timeLog(ExecState*, const String& title, Ref<ScriptArguments>&& arguments)
+{
+    m_consoleAgent->logTiming(title, WTFMove(arguments));
+}
+
 void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& title)
 {
     m_consoleAgent->stopTiming(title, createScriptCallStackForConsole(exec, 1));

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h (246797 => 246798)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h	2019-06-25 18:36:29 UTC (rev 246798)
@@ -54,6 +54,7 @@
     void profileEnd(JSC::ExecState*, const String& title) override;
     void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
     void time(JSC::ExecState*, const String& title) override;
+    void timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments) override;
     void timeEnd(JSC::ExecState*, const String& title) override;
     void timeStamp(JSC::ExecState*, Ref<ScriptArguments>&&) override;
     void record(JSC::ExecState*, Ref<ScriptArguments>&&) override;

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp (246797 => 246798)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp	2019-06-25 18:36:29 UTC (rev 246798)
@@ -144,6 +144,29 @@
     }
 }
 
+void InspectorConsoleAgent::logTiming(const String& title, Ref<ScriptArguments>&& arguments)
+{
+    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
+        return;
+
+    ASSERT(!title.isNull());
+    if (title.isNull())
+        return;
+
+    auto it = m_times.find(title);
+    if (it == m_times.end()) {
+        // FIXME: Send an enum to the frontend for localization?
+        String warning = makeString("Timer \"", title, "\" does not exist");
+        addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning));
+        return;
+    }
+
+    MonotonicTime startTime = it->value;
+    Seconds elapsed = MonotonicTime::now() - startTime;
+    String message = makeString(title, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms");
+    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(arguments)));
+}
+
 void InspectorConsoleAgent::stopTiming(const String& title, Ref<ScriptCallStack>&& callStack)
 {
     if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
@@ -162,11 +185,11 @@
     }
 
     MonotonicTime startTime = it->value;
-    m_times.remove(it);
-
     Seconds elapsed = MonotonicTime::now() - startTime;
     String message = makeString(title, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms");
     addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(callStack)));
+
+    m_times.remove(it);
 }
 
 void InspectorConsoleAgent::takeHeapSnapshot(const String& title)

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.h (246797 => 246798)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.h	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.h	2019-06-25 18:36:29 UTC (rev 246798)
@@ -71,6 +71,7 @@
     void addMessageToConsole(std::unique_ptr<ConsoleMessage>);
 
     void startTiming(const String& title);
+    void logTiming(const String& title, Ref<ScriptArguments>&&);
     void stopTiming(const String& title, Ref<ScriptCallStack>&&);
     void takeHeapSnapshot(const String& title);
     void count(JSC::ExecState*, Ref<ScriptArguments>&&);

Modified: trunk/Source/_javascript_Core/runtime/ConsoleClient.h (246797 => 246798)


--- trunk/Source/_javascript_Core/runtime/ConsoleClient.h	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/_javascript_Core/runtime/ConsoleClient.h	2019-06-25 18:36:29 UTC (rev 246798)
@@ -60,6 +60,7 @@
     virtual void profileEnd(ExecState*, const String& title) = 0;
     virtual void takeHeapSnapshot(ExecState*, const String& title) = 0;
     virtual void time(ExecState*, const String& title) = 0;
+    virtual void timeLog(ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) = 0;
     virtual void timeEnd(ExecState*, const String& title) = 0;
     virtual void timeStamp(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
     virtual void record(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;

Modified: trunk/Source/_javascript_Core/runtime/ConsoleObject.cpp (246797 => 246798)


--- trunk/Source/_javascript_Core/runtime/ConsoleObject.cpp	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/_javascript_Core/runtime/ConsoleObject.cpp	2019-06-25 18:36:29 UTC (rev 246798)
@@ -52,6 +52,7 @@
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncProfileEnd(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTakeHeapSnapshot(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTime(ExecState*);
+static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeLog(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeStamp(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncGroup(ExecState*);
@@ -92,6 +93,7 @@
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("profile", consoleProtoFuncProfile, static_cast<unsigned>(PropertyAttribute::None), 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("profileEnd", consoleProtoFuncProfileEnd, static_cast<unsigned>(PropertyAttribute::None), 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("time", consoleProtoFuncTime, static_cast<unsigned>(PropertyAttribute::None), 0);
+    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("timeLog", consoleProtoFuncTimeLog, static_cast<unsigned>(PropertyAttribute::None), 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("timeEnd", consoleProtoFuncTimeEnd, static_cast<unsigned>(PropertyAttribute::None), 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("timeStamp", consoleProtoFuncTimeStamp, static_cast<unsigned>(PropertyAttribute::None), 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("takeHeapSnapshot", consoleProtoFuncTakeHeapSnapshot, static_cast<unsigned>(PropertyAttribute::None), 0);
@@ -313,6 +315,26 @@
     return JSValue::encode(jsUndefined());
 }
 
+static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeLog(ExecState* exec)
+{
+    VM& vm = exec->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
+    if (!client)
+        return JSValue::encode(jsUndefined());
+
+    String title;
+    if (exec->argumentCount() < 1)
+        title =  "default"_s;
+    else {
+        title = valueOrDefaultLabelString(exec, exec->argument(0));
+        RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    }
+
+    client->timeLog(exec, title, Inspector::createScriptArguments(exec, 1));
+    return JSValue::encode(jsUndefined());
+}
+
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState* exec)
 {
     VM& vm = exec->vm();

Modified: trunk/Source/WebCore/ChangeLog (246797 => 246798)


--- trunk/Source/WebCore/ChangeLog	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebCore/ChangeLog	2019-06-25 18:36:29 UTC (rev 246798)
@@ -1,3 +1,26 @@
+2019-06-25  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Implement console.timeLog
+        https://bugs.webkit.org/show_bug.cgi?id=199184
+
+        Reviewed by Devin Rousso.
+
+        Updated existing tests.
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::logConsoleTimingImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::logConsoleTiming):
+        * page/PageConsoleClient.cpp:
+        (WebCore::PageConsoleClient::timeLog):
+        * page/PageConsoleClient.h:
+        * workers/WorkerConsoleClient.cpp:
+        (WebCore::WorkerConsoleClient::timeLog):
+        * workers/WorkerConsoleClient.h:
+        * worklets/WorkletConsoleClient.cpp:
+        (WebCore::WorkletConsoleClient::timeLog):
+        * worklets/WorkletConsoleClient.h:
+
 2019-06-25  Michael Catanzaro  <[email protected]>
 
         Add user agent quirk for bankofamerica.com

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (246797 => 246798)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2019-06-25 18:36:29 UTC (rev 246798)
@@ -886,6 +886,15 @@
         consoleAgent->startTiming(title);
 }
 
+void InspectorInstrumentation::logConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title, Ref<Inspector::ScriptArguments>&& arguments)
+{
+    if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled())
+        return;
+
+    if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
+        consoleAgent->logTiming(title, WTFMove(arguments));
+}
+
 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& title, Ref<ScriptCallStack>&& stack)
 {
     if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled())

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (246797 => 246798)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2019-06-25 18:36:29 UTC (rev 246798)
@@ -226,6 +226,8 @@
     static void takeHeapSnapshot(Frame&, const String& title);
     static void startConsoleTiming(Frame&, const String& title);
     static void startConsoleTiming(WorkerGlobalScope&, const String& title);
+    static void logConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptArguments>&&);
+    static void logConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptArguments>&&);
     static void stopConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
     static void stopConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptCallStack>&&);
     static void consoleTimeStamp(Frame&, Ref<Inspector::ScriptArguments>&&);
@@ -404,6 +406,7 @@
     static void takeHeapSnapshotImpl(InstrumentingAgents&, const String& title);
     static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title);
     static void startConsoleTimingImpl(InstrumentingAgents&, const String& title);
+    static void logConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptArguments>&&);
     static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
     static void stopConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptCallStack>&&);
     static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&);
@@ -1408,6 +1411,17 @@
     startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title);
 }
 
+inline void InspectorInstrumentation::logConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptArguments>&& arguments)
+{
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
+        logConsoleTimingImpl(*instrumentingAgents, title, WTFMove(arguments));
+}
+
+inline void InspectorInstrumentation::logConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title, Ref<Inspector::ScriptArguments>&& arguments)
+{
+    logConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title, WTFMove(arguments));
+}
+
 inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptCallStack>&& stack)
 {
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))

Modified: trunk/Source/WebCore/page/PageConsoleClient.cpp (246797 => 246798)


--- trunk/Source/WebCore/page/PageConsoleClient.cpp	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebCore/page/PageConsoleClient.cpp	2019-06-25 18:36:29 UTC (rev 246798)
@@ -197,6 +197,11 @@
     InspectorInstrumentation::startConsoleTiming(m_page.mainFrame(), title);
 }
 
+void PageConsoleClient::timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments)
+{
+    InspectorInstrumentation::logConsoleTiming(m_page.mainFrame(), title, WTFMove(arguments));
+}
+
 void PageConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)
 {
     InspectorInstrumentation::stopConsoleTiming(m_page.mainFrame(), title, createScriptCallStackForConsole(exec, 1));

Modified: trunk/Source/WebCore/page/PageConsoleClient.h (246797 => 246798)


--- trunk/Source/WebCore/page/PageConsoleClient.h	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebCore/page/PageConsoleClient.h	2019-06-25 18:36:29 UTC (rev 246798)
@@ -72,6 +72,7 @@
     void profileEnd(JSC::ExecState*, const String& title) override;
     void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
     void time(JSC::ExecState*, const String& title) override;
+    void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) override;
     void timeEnd(JSC::ExecState*, const String& title) override;
     void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
     void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;

Modified: trunk/Source/WebCore/workers/WorkerConsoleClient.cpp (246797 => 246798)


--- trunk/Source/WebCore/workers/WorkerConsoleClient.cpp	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebCore/workers/WorkerConsoleClient.cpp	2019-06-25 18:36:29 UTC (rev 246798)
@@ -60,6 +60,11 @@
     InspectorInstrumentation::startConsoleTiming(m_workerGlobalScope, title);
 }
 
+void WorkerConsoleClient::timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments)
+{
+    InspectorInstrumentation::logConsoleTiming(m_workerGlobalScope, title, WTFMove(arguments));
+}
+
 void WorkerConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)
 {
     InspectorInstrumentation::stopConsoleTiming(m_workerGlobalScope, title, createScriptCallStackForConsole(exec, 1));

Modified: trunk/Source/WebCore/workers/WorkerConsoleClient.h (246797 => 246798)


--- trunk/Source/WebCore/workers/WorkerConsoleClient.h	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebCore/workers/WorkerConsoleClient.h	2019-06-25 18:36:29 UTC (rev 246798)
@@ -48,6 +48,7 @@
     void profileEnd(JSC::ExecState*, const String& title) override;
     void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
     void time(JSC::ExecState*, const String& title) override;
+    void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) override;
     void timeEnd(JSC::ExecState*, const String& title) override;
     void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
     void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;

Modified: trunk/Source/WebCore/worklets/WorkletConsoleClient.cpp (246797 => 246798)


--- trunk/Source/WebCore/worklets/WorkletConsoleClient.cpp	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebCore/worklets/WorkletConsoleClient.cpp	2019-06-25 18:36:29 UTC (rev 246798)
@@ -55,6 +55,7 @@
 void WorkletConsoleClient::count(JSC::ExecState*, Ref<ScriptArguments>&&) { }
 
 void WorkletConsoleClient::time(JSC::ExecState*, const String&) { }
+void WorkletConsoleClient::timeLog(JSC::ExecState*, const String&, Ref<ScriptArguments>&&) { }
 void WorkletConsoleClient::timeEnd(JSC::ExecState*, const String&) { }
 
 void WorkletConsoleClient::profile(JSC::ExecState*, const String&) { }

Modified: trunk/Source/WebCore/worklets/WorkletConsoleClient.h (246797 => 246798)


--- trunk/Source/WebCore/worklets/WorkletConsoleClient.h	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebCore/worklets/WorkletConsoleClient.h	2019-06-25 18:36:29 UTC (rev 246798)
@@ -50,6 +50,7 @@
     void profileEnd(JSC::ExecState*, const String& title) final;
     void takeHeapSnapshot(JSC::ExecState*, const String& title) final;
     void time(JSC::ExecState*, const String& title) final;
+    void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) final;
     void timeEnd(JSC::ExecState*, const String& title) final;
     void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;
     void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;

Modified: trunk/Source/WebInspectorUI/ChangeLog (246797 => 246798)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-06-25 18:36:29 UTC (rev 246798)
@@ -1,3 +1,16 @@
+2019-06-25  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Implement console.timeLog
+        https://bugs.webkit.org/show_bug.cgi?id=199184
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Views/ConsoleMessageView.js:
+        (WI.ConsoleMessageView.prototype._appendMessageTextAndArguments):
+        Time messages (like timeLog) do not include their messageText
+        in their parameters list. So to behave more like normal logs
+        build a parameter list that includes it at the front.
+
 2019-06-23  Matt Baker  <[email protected]>
 
         Web Inspector: REGRESSION (r246684): Dark Mode: dashboard buttons should have no background

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js (246797 => 246798)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2019-06-25 18:09:32 UTC (rev 246797)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js	2019-06-25 18:36:29 UTC (rev 246798)
@@ -288,6 +288,14 @@
                 this._extraParameters = null;
                 break;
 
+            case WI.ConsoleMessage.MessageType.Timing: {
+                let args = [this._message.messageText];
+                if (this._extraParameters)
+                    args = args.concat(this._extraParameters);
+                this._appendFormattedArguments(element, args);
+                break;
+            }
+
             case WI.ConsoleMessage.MessageType.Image: {
                 let img = element.appendChild(document.createElement("img"));
                 img.classList.add("console-image", "show-grid");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to