Changeset 246798 in webkit


Ignore:
Timestamp:
Jun 25, 2019 11:36:29 AM (5 years ago)
Author:
Joseph Pecoraro
Message:

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

Reviewed by Devin Rousso.

Source/JavaScriptCore:

  • 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.

Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r246788 r246798  
     12019-06-25  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Implement console.timeLog
     4        https://bugs.webkit.org/show_bug.cgi?id=199184
     5
     6        Reviewed by Devin Rousso.
     7
     8        * inspector/console/console-time-expected.txt:
     9        * inspector/console/console-time.html:
     10        Add new timeLog tests.
     11
     12        * js/console-expected.txt:
     13        New timeLog method.
     14
     15        * platform/gtk/TestExpectations:
     16        * platform/mac/TestExpectations:
     17        Unskip test.
     18
    1192019-06-25  Fujii Hironori  <Hironori.Fujii@sony.com>
    220
  • trunk/LayoutTests/inspector/console/console-time-expected.txt

    r200400 r246798  
    1 Tests for the console.time and console.timeEnd APIs.
     1Tests for the console.time, console.timeLog, and console.timeEnd APIs.
    22
    33
    4 == Running test suite: console.time and console.timeEnd
    5 -- Running test case: DefaultLabel
     4== Running test suite: console.time
     5-- Running test case: console.time.DefaultLabel
     6PASS: Should receive a Timing type message.
     7PASS: Message should contain the 'default' label name somewhere.
     8PASS: Should receive a Timing type message.
     9PASS: Message should contain the 'default' label name somewhere.
     10PASS: Should receive a Timing type message.
     11PASS: Message should contain the 'default' label name somewhere.
    612PASS: Should receive a Timing type message.
    713PASS: Message should contain the 'default' label name somewhere.
     
    1117PASS: Message should contain the 'default' label name somewhere.
    1218
    13 -- Running test case: UserLabels
     19-- Running test case: console.time.UserLabels
     20PASS: Should receive a Timing type message.
     21PASS: Message should contain the 'my-label' label name somewhere.
    1422PASS: Should receive a Timing type message.
    1523PASS: Message should contain the 'my-label' label name somewhere.
    1624
    17 -- Running test case: MultipleTimers
     25-- Running test case: console.time.MultipleTimers
    1826PASS: Should receive a Timing type message.
    1927PASS: Message should contain the 'my-label-2' label name somewhere.
     
    2129PASS: Message should contain the 'my-label-1' label name somewhere.
    2230
    23 -- Running test case: WarnWhenExisting
     31-- Running test case: console.time.WarnWhenExisting
    2432PASS: Should receive a Timing type message.
    2533PASS: Should receive a Warning level message
    2634PASS: Message should contain the 'default' label name somewhere.
    2735
    28 -- Running test case: WarnWhenNotExisting
     36-- Running test case: console.time.WarnWhenNotExisting
     37PASS: Should receive a Timing type message.
     38PASS: Should receive a Warning level message.
     39PASS: Message should contain the 'default' label name somewhere.
    2940PASS: Should receive a Timing type message.
    3041PASS: Should receive a Warning level message.
    3142PASS: Message should contain the 'default' label name somewhere.
    3243
     44-- Running test case: console.time.TimeLogIncreasing
     45PASS: Should receive a Timing type message.
     46PASS: Message should contain the 'my-timelog-label' label name somewhere.
     47PASS: + Initial timer time seen.
     48PASS: Should receive a Timing type message.
     49PASS: Message should contain the 'my-timelog-label' label name somewhere.
     50PASS: + Timer time should be increasing.
     51PASS: Should receive a Timing type message.
     52PASS: Message should contain the 'my-timelog-label' label name somewhere.
     53PASS: + Timer time should be increasing.
     54PASS: Should receive a Timing type message.
     55PASS: Message should contain the 'my-timelog-label' label name somewhere.
     56PASS: + Timer time should be increasing.
     57
     58-- Running test case: console.time.TimeLogArguments
     59PASS: Should receive a Timing type message.
     60PASS: timeLog should contain no parameters
     61PASS: Should receive a Timing type message.
     62PASS: timeLog should contain 1 parameters
     63PASS: Should receive a Timing type message.
     64PASS: timeLog should contain 2 parameters
     65PASS: Should receive a Timing type message.
     66PASS: timeEnd should contain no parameters
     67
  • trunk/LayoutTests/inspector/console/console-time.html

    r236766 r246798  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script>
     6function sleepTick() {
     7    let now = performance.now();
     8    let until = now + 10;
     9    while (performance.now() < until);
     10}
     11
    612function test()
    713{
    8     let suite = InspectorTest.createAsyncSuite("console.time and console.timeEnd");
    9 
    10     suite.addTestCase({
    11         name: "DefaultLabel",
     14    let suite = InspectorTest.createAsyncSuite("console.time");
     15
     16    suite.addTestCase({
     17        name: "console.time.DefaultLabel",
    1218        description: "Test that default label works as expected.",
    1319        test(resolve, reject) {
    1420            let seen = 0;
    15             const expected = 3;
     21            const expected = 6;
    1622            WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
    1723            function handler(event) {
     
    2531            }
    2632
    27             InspectorTest.evaluateInPage("console.time()");
    28             InspectorTest.evaluateInPage("console.timeEnd()");
    29 
    30             InspectorTest.evaluateInPage("console.time(undefined)");
    31             InspectorTest.evaluateInPage("console.timeEnd('default')");
    32 
    33             InspectorTest.evaluateInPage("console.time('default')");
    34             InspectorTest.evaluateInPage("console.timeEnd(undefined)");
    35         }
    36     });
    37 
    38     suite.addTestCase({
    39         name: "UserLabels",
     33            InspectorTest.evaluateInPage(`console.time()`);
     34            InspectorTest.evaluateInPage(`console.timeLog()`);
     35            InspectorTest.evaluateInPage(`console.timeEnd()`);
     36
     37            InspectorTest.evaluateInPage(`console.time(undefined)`);
     38            InspectorTest.evaluateInPage(`console.timeLog('default')`);
     39            InspectorTest.evaluateInPage(`console.timeEnd('default')`);
     40
     41            InspectorTest.evaluateInPage(`console.time('default')`);
     42            InspectorTest.evaluateInPage(`console.timeLog(undefined)`);
     43            InspectorTest.evaluateInPage(`console.timeEnd(undefined)`);
     44        }
     45    });
     46
     47    suite.addTestCase({
     48        name: "console.time.UserLabels",
    4049        description: "Test that user labels works as expected.",
    4150        test(resolve, reject) {
    42             WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.MessageAdded)
    43             .then((event) => {
     51            let seen = 0;
     52            const expected = 2;
     53            WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
     54            function handler(event) {
    4455                let message = event.data.message;
    4556                InspectorTest.expectThat(message.type === WI.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
    4657                InspectorTest.expectThat(message.messageText.includes("my-label"), "Message should contain the 'my-label' label name somewhere.");
    47             })
    48             .then(resolve, reject);
    49 
    50             InspectorTest.evaluateInPage("console.time('my-label')");
    51             InspectorTest.evaluateInPage("console.timeEnd('my-label')");
    52         }
    53     });
    54 
    55     suite.addTestCase({
    56         name: "MultipleTimers",
     58                if (++seen === expected) {
     59                    WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
     60                    resolve();
     61                }
     62            }
     63
     64            InspectorTest.evaluateInPage(`console.time('my-label')`);
     65            InspectorTest.evaluateInPage(`console.timeLog('my-label')`);
     66            InspectorTest.evaluateInPage(`console.timeEnd('my-label')`);
     67        }
     68    });
     69
     70    suite.addTestCase({
     71        name: "console.time.MultipleTimers",
    5772        description: "Test that multiple timers running at the same time work as expected.",
    5873        test(resolve, reject) {
     
    7186            }
    7287
    73             InspectorTest.evaluateInPage("console.time('my-label-1')");
    74             InspectorTest.evaluateInPage("console.time('my-label-2')");
    75             InspectorTest.evaluateInPage("console.timeEnd('my-label-2')");
    76             InspectorTest.evaluateInPage("console.timeEnd('my-label-1')");
    77         }
    78     });
    79 
    80     suite.addTestCase({
    81         name: "WarnWhenExisting",
     88            InspectorTest.evaluateInPage(`console.time('my-label-1')`);
     89            InspectorTest.evaluateInPage(`console.time('my-label-2')`);
     90            InspectorTest.evaluateInPage(`console.timeEnd('my-label-2')`);
     91            InspectorTest.evaluateInPage(`console.timeEnd('my-label-1')`);
     92        }
     93    });
     94
     95    suite.addTestCase({
     96        name: "console.time.WarnWhenExisting",
    8297        description: "Test for a warning when trying to start an already started timer.",
    8398        test(resolve, reject) {
     
    97112            }
    98113
    99             InspectorTest.evaluateInPage("console.time()");
    100             InspectorTest.evaluateInPage("console.time()"); // Warning
    101             InspectorTest.evaluateInPage("console.timeEnd()");
    102         }
    103     });
    104 
    105     suite.addTestCase({
    106         name: "WarnWhenNotExisting",
     114            InspectorTest.evaluateInPage(`console.time()`);
     115            InspectorTest.evaluateInPage(`console.time()`); // Warning
     116            InspectorTest.evaluateInPage(`console.timeEnd()`);
     117        }
     118    });
     119
     120    suite.addTestCase({
     121        name: "console.time.WarnWhenNotExisting",
    107122        description: "Test for a warning when trying to start an already started timer.",
    108123        test(resolve, reject) {
    109             WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.MessageAdded)
    110             .then((event) => {
    111                 let message = event.data.message;
     124            let seen = 0;
     125            const expected = 2;
     126            WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
     127            function handler(event) {
     128                let message = event.data.message;
     129                if (message.type === WI.ConsoleMessage.MessageType.Clear)
     130                    return;
     131
    112132                InspectorTest.expectThat(message.type === WI.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
    113133                InspectorTest.expectThat(message.level === WI.ConsoleMessage.MessageLevel.Warning, "Should receive a Warning level message.");
    114134                InspectorTest.expectThat(message.messageText.includes("default"), "Message should contain the 'default' label name somewhere.");
    115             })
    116             .then(resolve, reject);
    117 
    118             InspectorTest.evaluateInPage("console.timeEnd()");
     135                if (++seen === expected) {
     136                    WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
     137                    resolve();
     138                }
     139            }
     140
     141            InspectorTest.evaluateInPage(`console.timeLog()`); // Warn
     142            InspectorTest.evaluateInPage(`console.clear()`);
     143            InspectorTest.evaluateInPage(`console.timeEnd()`); // Warn
     144        }
     145    });
     146
     147    suite.addTestCase({
     148        name: "console.time.TimeLogIncreasing",
     149        description: "Test for timeLog multiple times with a timer should increase.",
     150        test(resolve, reject) {
     151            let lastTime = 0;
     152            let seen = 0;
     153            const expected = 4;
     154            WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
     155            function handler(event) {
     156                let message = event.data.message;
     157                InspectorTest.expectThat(message.type === WI.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
     158                InspectorTest.expectThat(message.messageText.includes("my-timelog-label"), "Message should contain the 'my-timelog-label' label name somewhere.");
     159
     160                let match = message.messageText.match(/^my-timelog-label: (\d+(\.\d+)?ms)/)
     161                if (match) {
     162                    let currentTime = parseFloat(match[1]);
     163                    if (lastTime) {
     164                        InspectorTest.assert(currentTime > 15, "At least 15 milliseconds should have elapsed since this is for timeLog 2 and later.");
     165                        InspectorTest.expectGreaterThan(currentTime, lastTime, "+ Timer time should be increasing.");
     166                    } else
     167                        InspectorTest.pass("+ Initial timer time seen.");
     168                    lastTime = currentTime;
     169                }
     170
     171                if (++seen === expected) {
     172                    WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
     173                    resolve();
     174                }
     175            }
     176
     177            InspectorTest.evaluateInPage(`console.time("my-timelog-label")`);
     178            InspectorTest.evaluateInPage(`sleepTick(); console.timeLog("my-timelog-label")`);
     179            InspectorTest.evaluateInPage(`sleepTick(); console.timeLog("my-timelog-label")`);
     180            InspectorTest.evaluateInPage(`sleepTick(); console.timeLog("my-timelog-label")`);
     181            InspectorTest.evaluateInPage(`sleepTick(); console.timeEnd("my-timelog-label")`);
     182        }
     183    });
     184
     185    suite.addTestCase({
     186        name: "console.time.TimeLogArguments",
     187        description: "Test for timeLog with trailing parameters.",
     188        test(resolve, reject) {
     189            let seen = 0;
     190            const expected = 4;
     191            WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
     192            function handler(event) {
     193                let message = event.data.message;
     194                InspectorTest.expectThat(message.type === WI.ConsoleMessage.MessageType.Timing, "Should receive a Timing type message.");
     195
     196                switch (seen) {
     197                case 0:
     198                    InspectorTest.expectEqual(message.parameters, undefined, "timeLog should contain no parameters");
     199                    break;
     200                case 1:
     201                    InspectorTest.expectEqual(message.parameters.length, 1, "timeLog should contain 1 parameters");
     202                    break;
     203                case 2:
     204                    InspectorTest.expectEqual(message.parameters.length, 2, "timeLog should contain 2 parameters");
     205                    break;
     206                case 3:
     207                    InspectorTest.expectEqual(message.parameters, undefined, "timeEnd should contain no parameters");
     208                    break;
     209                }
     210
     211                if (++seen === expected) {
     212                    WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, handler);
     213                    resolve();
     214                }
     215            }
     216
     217            InspectorTest.evaluateInPage(`console.time("x")`);
     218            InspectorTest.evaluateInPage(`console.timeLog("x")`);
     219            InspectorTest.evaluateInPage(`console.timeLog("x", 1)`);
     220            InspectorTest.evaluateInPage(`console.timeLog("x", 2, window)`);
     221            InspectorTest.evaluateInPage(`console.timeEnd("x")`);
    119222        }
    120223    });
     
    125228</head>
    126229<body onload="runTest()">
    127 <p>Tests for the console.time and console.timeEnd APIs.</p>
     230<p>Tests for the console.time, console.timeLog, and console.timeEnd APIs.</p>
    128231</body>
    129232</html>
  • trunk/LayoutTests/js/console-expected.txt

    r242992 r246798  
    122122PASS descriptor.enumerable is true
    123123
     124console.timeLog
     125PASS typeof console.timeLog is "function"
     126PASS console.timeLog.length is 0
     127PASS descriptor.configurable is true
     128PASS descriptor.writable is true
     129PASS descriptor.enumerable is true
     130
    124131console.timeEnd
    125132PASS typeof console.timeEnd is "function"
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r246676 r246798  
    21362136webkit.org/b/197498 imported/w3c/web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html [ Failure Pass ]
    21372137
    2138 webkit.org/b/197499 inspector/console/console-time.html [ Failure Pass ]
    2139 
    21402138webkit.org/b/197500 legacy-animation-engine/compositing/repaint/become-overlay-composited-layer.html [ Failure Pass ]
    21412139
  • trunk/LayoutTests/platform/mac/TestExpectations

    r246753 r246798  
    10901090webkit.org/b/156078 inspector/console/heapSnapshot.html [ Pass Timeout ]
    10911091webkit.org/b/182620 inspector/console/clearMessages.html [ Pass Timeout ]
    1092 webkit.org/b/158006 inspector/console/console-time.html [ Pass Failure ]
    10931092webkit.org/b/183880 [ Debug ] inspector/console/messageAdded-from-named-evaluations.html [ Slow ]
    10941093webkit.org/b/156634 inspector/formatting/formatting-javascript.html [ Pass Timeout ]
  • trunk/Source/JavaScriptCore/ChangeLog

    r246792 r246798  
     12019-06-25  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Implement console.timeLog
     4        https://bugs.webkit.org/show_bug.cgi?id=199184
     5
     6        Reviewed by Devin Rousso.
     7
     8        * inspector/JSGlobalObjectConsoleClient.cpp:
     9        (Inspector::JSGlobalObjectConsoleClient::timeLog):
     10        * inspector/JSGlobalObjectConsoleClient.h:
     11        * inspector/agents/InspectorConsoleAgent.cpp:
     12        (Inspector::InspectorConsoleAgent::logTiming):
     13        (Inspector::InspectorConsoleAgent::stopTiming):
     14        * inspector/agents/InspectorConsoleAgent.h:
     15        * runtime/ConsoleClient.h:
     16        * runtime/ConsoleObject.cpp:
     17        (JSC::ConsoleObject::finishCreation):
     18        (JSC::consoleProtoFuncTimeLog):
     19
    1202019-06-25  Michael Catanzaro  <mcatanzaro@igalia.com>
    221
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp

    r244195 r246798  
    154154}
    155155
     156void JSGlobalObjectConsoleClient::timeLog(ExecState*, const String& title, Ref<ScriptArguments>&& arguments)
     157{
     158    m_consoleAgent->logTiming(title, WTFMove(arguments));
     159}
     160
    156161void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& title)
    157162{
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h

    r243192 r246798  
    5555    void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
    5656    void time(JSC::ExecState*, const String& title) override;
     57    void timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments) override;
    5758    void timeEnd(JSC::ExecState*, const String& title) override;
    5859    void timeStamp(JSC::ExecState*, Ref<ScriptArguments>&&) override;
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp

    r243663 r246798  
    145145}
    146146
    147 void InspectorConsoleAgent::stopTiming(const String& title, Ref<ScriptCallStack>&& callStack)
     147void InspectorConsoleAgent::logTiming(const String& title, Ref<ScriptArguments>&& arguments)
    148148{
    149149    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
     
    163163
    164164    MonotonicTime startTime = it->value;
    165     m_times.remove(it);
    166 
     165    Seconds elapsed = MonotonicTime::now() - startTime;
     166    String message = makeString(title, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms");
     167    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(arguments)));
     168}
     169
     170void InspectorConsoleAgent::stopTiming(const String& title, Ref<ScriptCallStack>&& callStack)
     171{
     172    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
     173        return;
     174
     175    ASSERT(!title.isNull());
     176    if (title.isNull())
     177        return;
     178
     179    auto it = m_times.find(title);
     180    if (it == m_times.end()) {
     181        // FIXME: Send an enum to the frontend for localization?
     182        String warning = makeString("Timer \"", title, "\" does not exist");
     183        addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning));
     184        return;
     185    }
     186
     187    MonotonicTime startTime = it->value;
    167188    Seconds elapsed = MonotonicTime::now() - startTime;
    168189    String message = makeString(title, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms");
    169190    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(callStack)));
     191
     192    m_times.remove(it);
    170193}
    171194
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h

    r243150 r246798  
    7272
    7373    void startTiming(const String& title);
     74    void logTiming(const String& title, Ref<ScriptArguments>&&);
    7475    void stopTiming(const String& title, Ref<ScriptCallStack>&&);
    7576    void takeHeapSnapshot(const String& title);
  • trunk/Source/JavaScriptCore/runtime/ConsoleClient.h

    r242992 r246798  
    6161    virtual void takeHeapSnapshot(ExecState*, const String& title) = 0;
    6262    virtual void time(ExecState*, const String& title) = 0;
     63    virtual void timeLog(ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) = 0;
    6364    virtual void timeEnd(ExecState*, const String& title) = 0;
    6465    virtual void timeStamp(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
  • trunk/Source/JavaScriptCore/runtime/ConsoleObject.cpp

    r242992 r246798  
    5353static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTakeHeapSnapshot(ExecState*);
    5454static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTime(ExecState*);
     55static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeLog(ExecState*);
    5556static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState*);
    5657static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeStamp(ExecState*);
     
    9394    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("profileEnd", consoleProtoFuncProfileEnd, static_cast<unsigned>(PropertyAttribute::None), 0);
    9495    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("time", consoleProtoFuncTime, static_cast<unsigned>(PropertyAttribute::None), 0);
     96    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("timeLog", consoleProtoFuncTimeLog, static_cast<unsigned>(PropertyAttribute::None), 0);
    9597    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("timeEnd", consoleProtoFuncTimeEnd, static_cast<unsigned>(PropertyAttribute::None), 0);
    9698    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("timeStamp", consoleProtoFuncTimeStamp, static_cast<unsigned>(PropertyAttribute::None), 0);
     
    314316}
    315317
    316 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState* exec)
     318static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeLog(ExecState* exec)
    317319{
    318320    VM& vm = exec->vm();
     
    330332    }
    331333
     334    client->timeLog(exec, title, Inspector::createScriptArguments(exec, 1));
     335    return JSValue::encode(jsUndefined());
     336}
     337
     338static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState* exec)
     339{
     340    VM& vm = exec->vm();
     341    auto scope = DECLARE_THROW_SCOPE(vm);
     342    ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
     343    if (!client)
     344        return JSValue::encode(jsUndefined());
     345
     346    String title;
     347    if (exec->argumentCount() < 1)
     348        title =  "default"_s;
     349    else {
     350        title = valueOrDefaultLabelString(exec, exec->argument(0));
     351        RETURN_IF_EXCEPTION(scope, encodedJSValue());
     352    }
     353
    332354    client->timeEnd(exec, title);
    333355    return JSValue::encode(jsUndefined());
  • trunk/Source/WebCore/ChangeLog

    r246791 r246798  
     12019-06-25  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Implement console.timeLog
     4        https://bugs.webkit.org/show_bug.cgi?id=199184
     5
     6        Reviewed by Devin Rousso.
     7
     8        Updated existing tests.
     9
     10        * inspector/InspectorInstrumentation.cpp:
     11        (WebCore::InspectorInstrumentation::logConsoleTimingImpl):
     12        * inspector/InspectorInstrumentation.h:
     13        (WebCore::InspectorInstrumentation::logConsoleTiming):
     14        * page/PageConsoleClient.cpp:
     15        (WebCore::PageConsoleClient::timeLog):
     16        * page/PageConsoleClient.h:
     17        * workers/WorkerConsoleClient.cpp:
     18        (WebCore::WorkerConsoleClient::timeLog):
     19        * workers/WorkerConsoleClient.h:
     20        * worklets/WorkletConsoleClient.cpp:
     21        (WebCore::WorkletConsoleClient::timeLog):
     22        * worklets/WorkletConsoleClient.h:
     23
    1242019-06-25  Michael Catanzaro  <mcatanzaro@igalia.com>
    225
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r246490 r246798  
    887887}
    888888
     889void InspectorInstrumentation::logConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title, Ref<Inspector::ScriptArguments>&& arguments)
     890{
     891    if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled())
     892        return;
     893
     894    if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
     895        consoleAgent->logTiming(title, WTFMove(arguments));
     896}
     897
    889898void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& title, Ref<ScriptCallStack>&& stack)
    890899{
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r246490 r246798  
    227227    static void startConsoleTiming(Frame&, const String& title);
    228228    static void startConsoleTiming(WorkerGlobalScope&, const String& title);
     229    static void logConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptArguments>&&);
     230    static void logConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptArguments>&&);
    229231    static void stopConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
    230232    static void stopConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptCallStack>&&);
     
    405407    static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title);
    406408    static void startConsoleTimingImpl(InstrumentingAgents&, const String& title);
     409    static void logConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptArguments>&&);
    407410    static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
    408411    static void stopConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptCallStack>&&);
     
    14091412}
    14101413
     1414inline void InspectorInstrumentation::logConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptArguments>&& arguments)
     1415{
     1416    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
     1417        logConsoleTimingImpl(*instrumentingAgents, title, WTFMove(arguments));
     1418}
     1419
     1420inline void InspectorInstrumentation::logConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title, Ref<Inspector::ScriptArguments>&& arguments)
     1421{
     1422    logConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title, WTFMove(arguments));
     1423}
     1424
    14111425inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptCallStack>&& stack)
    14121426{
  • trunk/Source/WebCore/page/PageConsoleClient.cpp

    r244908 r246798  
    198198}
    199199
     200void PageConsoleClient::timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments)
     201{
     202    InspectorInstrumentation::logConsoleTiming(m_page.mainFrame(), title, WTFMove(arguments));
     203}
     204
    200205void PageConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)
    201206{
  • trunk/Source/WebCore/page/PageConsoleClient.h

    r242992 r246798  
    7373    void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
    7474    void time(JSC::ExecState*, const String& title) override;
     75    void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) override;
    7576    void timeEnd(JSC::ExecState*, const String& title) override;
    7677    void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
  • trunk/Source/WebCore/workers/WorkerConsoleClient.cpp

    r242992 r246798  
    6161}
    6262
     63void WorkerConsoleClient::timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments)
     64{
     65    InspectorInstrumentation::logConsoleTiming(m_workerGlobalScope, title, WTFMove(arguments));
     66}
     67
    6368void WorkerConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)
    6469{
  • trunk/Source/WebCore/workers/WorkerConsoleClient.h

    r242992 r246798  
    4949    void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
    5050    void time(JSC::ExecState*, const String& title) override;
     51    void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) override;
    5152    void timeEnd(JSC::ExecState*, const String& title) override;
    5253    void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
  • trunk/Source/WebCore/worklets/WorkletConsoleClient.cpp

    r242992 r246798  
    5656
    5757void WorkletConsoleClient::time(JSC::ExecState*, const String&) { }
     58void WorkletConsoleClient::timeLog(JSC::ExecState*, const String&, Ref<ScriptArguments>&&) { }
    5859void WorkletConsoleClient::timeEnd(JSC::ExecState*, const String&) { }
    5960
  • trunk/Source/WebCore/worklets/WorkletConsoleClient.h

    r242992 r246798  
    5151    void takeHeapSnapshot(JSC::ExecState*, const String& title) final;
    5252    void time(JSC::ExecState*, const String& title) final;
     53    void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) final;
    5354    void timeEnd(JSC::ExecState*, const String& title) final;
    5455    void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;
  • trunk/Source/WebInspectorUI/ChangeLog

    r246724 r246798  
     12019-06-25  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Implement console.timeLog
     4        https://bugs.webkit.org/show_bug.cgi?id=199184
     5
     6        Reviewed by Devin Rousso.
     7
     8        * UserInterface/Views/ConsoleMessageView.js:
     9        (WI.ConsoleMessageView.prototype._appendMessageTextAndArguments):
     10        Time messages (like timeLog) do not include their messageText
     11        in their parameters list. So to behave more like normal logs
     12        build a parameter list that includes it at the front.
     13
    1142019-06-23  Matt Baker  <mattbaker@apple.com>
    215
  • trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js

    r245165 r246798  
    289289                break;
    290290
     291            case WI.ConsoleMessage.MessageType.Timing: {
     292                let args = [this._message.messageText];
     293                if (this._extraParameters)
     294                    args = args.concat(this._extraParameters);
     295                this._appendFormattedArguments(element, args);
     296                break;
     297            }
     298
    291299            case WI.ConsoleMessage.MessageType.Image: {
    292300                let img = element.appendChild(document.createElement("img"));
Note: See TracChangeset for help on using the changeset viewer.