Changeset 246876 in webkit


Ignore:
Timestamp:
Jun 27, 2019 1:25:04 AM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: throw an error if console.count/console.countReset is called with an object that throws an error from toString
https://bugs.webkit.org/show_bug.cgi?id=199252

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

Parse the arguments passed to console.count and console.countReset before sending it to
the ConsoleClient so that an error can be thrown if the first argument doesn't toString
nicely (e.g. without throwing an error).

Generate call stacks for console.countReset to match other console methods. Also do this
for console.time, console.timeLog, and console.timeEnd. Limit the call stack to only
have the top frame, so no unnecessary/extra data is sent to the frontend (right now, only
the call location is displayed).

Rename title to label for console.time, console.timeLog, and console.timeEnd to
better match the spec.

  • runtime/ConsoleClient.h:
  • runtime/ConsoleObject.cpp:

(JSC::valueOrDefaultLabelString):
(JSC::consoleProtoFuncCount):
(JSC::consoleProtoFuncCountReset):
(JSC::consoleProtoFuncTime):
(JSC::consoleProtoFuncTimeLog):
(JSC::consoleProtoFuncTimeEnd):

  • inspector/JSGlobalObjectConsoleClient.h:
  • inspector/JSGlobalObjectConsoleClient.cpp:

(Inspector::JSGlobalObjectConsoleClient::count):
(Inspector::JSGlobalObjectConsoleClient::countReset):
(Inspector::JSGlobalObjectConsoleClient::time):
(Inspector::JSGlobalObjectConsoleClient::timeLog):
(Inspector::JSGlobalObjectConsoleClient::timeEnd):

  • inspector/agents/InspectorConsoleAgent.h:
  • inspector/agents/InspectorConsoleAgent.cpp:

(Inspector::InspectorConsoleAgent::startTiming):
(Inspector::InspectorConsoleAgent::logTiming):
(Inspector::InspectorConsoleAgent::stopTiming):
(Inspector::InspectorConsoleAgent::count):
(Inspector::InspectorConsoleAgent::countReset):
(Inspector::InspectorConsoleAgent::getCounterLabel): Deleted.

  • inspector/ConsoleMessage.h:
  • inspector/ConsoleMessage.cpp:

(Inspector::ConsoleMessage::ConsoleMessage):
Allow ConsoleMessages to be created with both ScriptArguments and a ScriptCallStack.

Source/WebCore:

Parse the arguments passed to console.count and console.countReset before sending it to
the ConsoleClient so that an error can be thrown if the first argument doesn't toString
nicely (e.g. without throwing an error).

Generate call stacks for console.countReset to match other console methods. Also do this
for console.time, console.timeLog, and console.timeEnd. Limit the call stack to only
have the top frame, so no unnecessary/extra data is sent to the frontend (right now, only
the call location is displayed).

Rename title to label for console.time, console.timeLog, and console.timeEnd to
better match the spec.

Updated existing LayoutTests:

  • inspector/console/console-count.html
  • inspector/console/console-api.html

Also covered by existing WPT tests.

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::consoleCount):
(WebCore::InspectorInstrumentation::consoleCountReset):
(WebCore::InspectorInstrumentation::startConsoleTiming):
(WebCore::InspectorInstrumentation::logConsoleTiming):
(WebCore::InspectorInstrumentation::stopConsoleTiming):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::consoleCountImpl):
(WebCore::InspectorInstrumentation::consoleCountResetImpl):
(WebCore::InspectorInstrumentation::startConsoleTimingImpl):
(WebCore::InspectorInstrumentation::logConsoleTimingImpl):
(WebCore::InspectorInstrumentation::stopConsoleTimingImpl):

  • page/PageConsoleClient.h:
  • page/PageConsoleClient.cpp:

(WebCore::PageConsoleClient::count):
(WebCore::PageConsoleClient::countReset):
(WebCore::PageConsoleClient::time):
(WebCore::PageConsoleClient::timeLog):
(WebCore::PageConsoleClient::timeEnd):

  • workers/WorkerConsoleClient.h:
  • workers/WorkerConsoleClient.cpp:

(WebCore::WorkerConsoleClient::count):
(WebCore::WorkerConsoleClient::countReset):
(WebCore::WorkerConsoleClient::time):
(WebCore::WorkerConsoleClient::timeLog):
(WebCore::WorkerConsoleClient::timeEnd):

  • worklets/WorkletConsoleClient.h:
  • worklets/WorkletConsoleClient.cpp:

(WebCore::WorkletConsoleClient::count):
(WebCore::WorkletConsoleClient::countReset):

Source/WebInspectorUI:

Add entries for console.countReset and console.timeLog.

Rename title to label for console.time, console.timeLog, and console.timeEnd to
better match the spec.

  • UserInterface/Models/NativeFunctionParameters.js:

LayoutTests:

  • inspector/console/console-count.html:
  • inspector/console/console-count-expected.txt:
  • inspector/console/console-api-expected.txt:
Location:
trunk
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r246875 r246876  
     12019-06-27  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: throw an error if console.count/console.countReset is called with an object that throws an error from toString
     4        https://bugs.webkit.org/show_bug.cgi?id=199252
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * inspector/console/console-count.html:
     9        * inspector/console/console-count-expected.txt:
     10        * inspector/console/console-api-expected.txt:
     11
    1122019-06-27  Saam Barati  <sbarati@apple.com>
    213
  • trunk/LayoutTests/inspector/console/console-api-expected.txt

    r208009 r246876  
    586586  "_source": "console-api",
    587587  "_level": "debug",
    588   "_messageText": "Global: 1",
     588  "_messageText": "default: 1",
    589589  "_type": "log",
    590590  "_url": null,
     
    600600  "_source": "console-api",
    601601  "_level": "debug",
    602   "_messageText": "Global: 2",
     602  "_messageText": "default: 2",
     603  "_type": "log",
     604  "_url": null,
     605  "_line": 3,
     606  "_column": 14,
     607  "_repeatCount": 1,
     608  "_stackTrace": "<filtered>",
     609  "_request": null
     610}
     611
     612STEP: console.count("default")
     613{
     614  "_source": "console-api",
     615  "_level": "debug",
     616  "_messageText": "default: 3",
    603617  "_type": "log",
    604618  "_url": null,
  • trunk/LayoutTests/inspector/console/console-api.html

    r236766 r246876  
    3535        "console.count()",
    3636        "console.count()",
     37        "console.count(\"default\")",
    3738        "console.count('')",
    3839        "console.count('    ')",
  • trunk/LayoutTests/inspector/console/console-count-expected.txt

    r246850 r246876  
    44== Running test suite: console.count
    55-- Running test case: console.count.NoArguments
    6 Global: 1
    7 Global: 2
    8 Global: 3
    9 Global: 4
    10 Global: 5
    11 Global: 6
    12 Global: 7
    13 Global: 8
    14 Global: 9
    15 Global: 10
    16 Global: 11
    17 Global: 12
    18 Global: 13
    19 Global: 14
    20 Global: 15
    21 Global: 16
     6default: 1
     7default: 2
     8default: 3
     9default: 4
     10default: 5
     11default: 6
     12default: 7
     13default: 8
     14default: 9
     15default: 10
     16default: 11
     17default: 12
     18default: 13
     19default: 14
     20default: 15
     21default: 16
    2222
    2323-- Running test case: console.count.WithLabel
  • trunk/LayoutTests/inspector/console/console-count.html

    r246850 r246876  
    4141    suite.addTestCase({
    4242        name: "console.count.NoArguments",
    43         description: "No arguments increments a shared global counter.",
     43        description: "No arguments uses the default label.",
    4444        test(resolve, reject) {
    4545            let seen = 0;
     
    5656
    5757            InspectorTest.evaluateInPage(`triggerCountNoArguments()`); // 15
    58             InspectorTest.evaluateInPage(`console.count()`); // 1
     58            InspectorTest.evaluateInPage(`console.count("default")`); // 16
    5959        }
    6060    });
  • trunk/Source/JavaScriptCore/ChangeLog

    r246874 r246876  
     12019-06-27  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: throw an error if console.count/console.countReset is called with an object that throws an error from toString
     4        https://bugs.webkit.org/show_bug.cgi?id=199252
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Parse the arguments passed to `console.count` and `console.countReset` before sending it to
     9        the `ConsoleClient` so that an error can be thrown if the first argument doesn't `toString`
     10        nicely (e.g. without throwing an error).
     11
     12        Generate call stacks for `console.countReset` to match other `console` methods. Also do this
     13        for `console.time`, `console.timeLog`, and `console.timeEnd`. Limit the call stack to only
     14        have the top frame, so no unnecessary/extra data is sent to the frontend (right now, only
     15        the call location is displayed).
     16
     17        Rename `title` to `label` for `console.time`, `console.timeLog`, and `console.timeEnd` to
     18        better match the spec.
     19
     20        * runtime/ConsoleClient.h:
     21        * runtime/ConsoleObject.cpp:
     22        (JSC::valueOrDefaultLabelString):
     23        (JSC::consoleProtoFuncCount):
     24        (JSC::consoleProtoFuncCountReset):
     25        (JSC::consoleProtoFuncTime):
     26        (JSC::consoleProtoFuncTimeLog):
     27        (JSC::consoleProtoFuncTimeEnd):
     28
     29        * inspector/JSGlobalObjectConsoleClient.h:
     30        * inspector/JSGlobalObjectConsoleClient.cpp:
     31        (Inspector::JSGlobalObjectConsoleClient::count):
     32        (Inspector::JSGlobalObjectConsoleClient::countReset):
     33        (Inspector::JSGlobalObjectConsoleClient::time):
     34        (Inspector::JSGlobalObjectConsoleClient::timeLog):
     35        (Inspector::JSGlobalObjectConsoleClient::timeEnd):
     36
     37        * inspector/agents/InspectorConsoleAgent.h:
     38        * inspector/agents/InspectorConsoleAgent.cpp:
     39        (Inspector::InspectorConsoleAgent::startTiming):
     40        (Inspector::InspectorConsoleAgent::logTiming):
     41        (Inspector::InspectorConsoleAgent::stopTiming):
     42        (Inspector::InspectorConsoleAgent::count):
     43        (Inspector::InspectorConsoleAgent::countReset):
     44        (Inspector::InspectorConsoleAgent::getCounterLabel): Deleted.
     45
     46        * inspector/ConsoleMessage.h:
     47        * inspector/ConsoleMessage.cpp:
     48        (Inspector::ConsoleMessage::ConsoleMessage):
     49        Allow `ConsoleMessage`s to be created with both `ScriptArguments` and a `ScriptCallStack`.
     50
    1512019-06-27  Fujii Hironori  <Hironori.Fujii@sony.com>
    252
  • trunk/Source/JavaScriptCore/inspector/ConsoleMessage.cpp

    r242992 r246876  
    8383}
    8484
     85ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, Ref<ScriptArguments>&& arguments, Ref<ScriptCallStack>&& callStack, unsigned long requestIdentifier)
     86    : m_source(source)
     87    , m_type(type)
     88    , m_level(level)
     89    , m_message(message)
     90    , m_arguments(WTFMove(arguments))
     91    , m_callStack(WTFMove(callStack))
     92    , m_url()
     93    , m_requestId(IdentifiersFactory::requestId(requestIdentifier))
     94{
     95    const ScriptCallFrame* frame = m_callStack ? m_callStack->firstNonNativeCallFrame() : nullptr;
     96    if (frame) {
     97        m_url = frame->sourceURL();
     98        m_line = frame->lineNumber();
     99        m_column = frame->columnNumber();
     100    }
     101}
     102
    85103ConsoleMessage::ConsoleMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, Ref<ScriptArguments>&& arguments, JSC::ExecState* state, unsigned long requestIdentifier)
    86104    : m_source(source)
  • trunk/Source/JavaScriptCore/inspector/ConsoleMessage.h

    r242992 r246876  
    5656    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& url, unsigned line, unsigned column, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0);
    5757    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref<ScriptCallStack>&&, unsigned long requestIdentifier = 0);
     58    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref<ScriptArguments>&&, Ref<ScriptCallStack>&&, unsigned long requestIdentifier = 0);
    5859    ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& message, Ref<ScriptArguments>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0);
    5960    ConsoleMessage(MessageSource, MessageType, MessageLevel, Vector<JSONLogValue>&&, JSC::ExecState*, unsigned long requestIdentifier = 0);
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp

    r246850 r246876  
    7171}
    7272
    73 void JSGlobalObjectConsoleClient::count(ExecState* exec, Ref<ScriptArguments>&& arguments)
     73void JSGlobalObjectConsoleClient::count(ExecState* exec, const String& label)
    7474{
    75     m_consoleAgent->count(exec, WTFMove(arguments));
     75    m_consoleAgent->count(exec, label);
    7676}
    7777
    78 void JSGlobalObjectConsoleClient::countReset(ExecState* exec, Ref<ScriptArguments>&& arguments)
     78void JSGlobalObjectConsoleClient::countReset(ExecState* exec, const String& label)
    7979{
    80     m_consoleAgent->countReset(exec, WTFMove(arguments));
     80    m_consoleAgent->countReset(exec, label);
    8181}
    8282
     
    154154}
    155155
    156 void JSGlobalObjectConsoleClient::time(ExecState*, const String& title)
     156void JSGlobalObjectConsoleClient::time(ExecState* exec, const String& label)
    157157{
    158     m_consoleAgent->startTiming(title);
     158    m_consoleAgent->startTiming(exec, label);
    159159}
    160160
    161 void JSGlobalObjectConsoleClient::timeLog(ExecState*, const String& title, Ref<ScriptArguments>&& arguments)
     161void JSGlobalObjectConsoleClient::timeLog(ExecState* exec, const String& label, Ref<ScriptArguments>&& arguments)
    162162{
    163     m_consoleAgent->logTiming(title, WTFMove(arguments));
     163    m_consoleAgent->logTiming(exec, label, WTFMove(arguments));
    164164}
    165165
    166 void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& title)
     166void JSGlobalObjectConsoleClient::timeEnd(ExecState* exec, const String& label)
    167167{
    168     m_consoleAgent->stopTiming(title, createScriptCallStackForConsole(exec, 1));
     168    m_consoleAgent->stopTiming(exec, label);
    169169}
    170170
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h

    r246850 r246876  
    5050protected:
    5151    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<ScriptArguments>&&) override;
    52     void count(JSC::ExecState*, Ref<ScriptArguments>&&) override;
    53     void countReset(JSC::ExecState*, Ref<ScriptArguments>&&) override;
     52    void count(JSC::ExecState*, const String& label) override;
     53    void countReset(JSC::ExecState*, const String& label) override;
    5454    void profile(JSC::ExecState*, const String& title) override;
    5555    void profileEnd(JSC::ExecState*, const String& title) override;
    5656    void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
    57     void time(JSC::ExecState*, const String& title) override;
    58     void timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments) override;
    59     void timeEnd(JSC::ExecState*, const String& title) override;
     57    void time(JSC::ExecState*, const String& label) override;
     58    void timeLog(JSC::ExecState*, const String& label, Ref<ScriptArguments>&&) override;
     59    void timeEnd(JSC::ExecState*, const String& label) override;
    6060    void timeStamp(JSC::ExecState*, Ref<ScriptArguments>&&) override;
    6161    void record(JSC::ExecState*, Ref<ScriptArguments>&&) override;
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp

    r246850 r246876  
    127127}
    128128
    129 void InspectorConsoleAgent::startTiming(const String& title)
    130 {
    131     if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
    132         return;
    133 
    134     ASSERT(!title.isNull());
    135     if (title.isNull())
    136         return;
    137 
    138     auto result = m_times.add(title, MonotonicTime::now());
     129void InspectorConsoleAgent::startTiming(JSC::ExecState* exec, const String& label)
     130{
     131    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
     132        return;
     133
     134    ASSERT(!label.isNull());
     135    if (label.isNull())
     136        return;
     137
     138    auto result = m_times.add(label, MonotonicTime::now());
    139139
    140140    if (!result.isNewEntry) {
    141141        // FIXME: Send an enum to the frontend for localization?
    142         String warning = makeString("Timer \"", title, "\" already exists");
    143         addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning));
    144     }
    145 }
    146 
    147 void InspectorConsoleAgent::logTiming(const String& title, Ref<ScriptArguments>&& arguments)
    148 {
    149     if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
    150         return;
    151 
    152     ASSERT(!title.isNull());
    153     if (title.isNull())
    154         return;
    155 
    156     auto it = m_times.find(title);
     142        String warning = makeString("Timer \"", label, "\" already exists");
     143        addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning, createScriptCallStackForConsole(exec, 1)));
     144    }
     145}
     146
     147void InspectorConsoleAgent::logTiming(JSC::ExecState* exec, const String& label, Ref<ScriptArguments>&& arguments)
     148{
     149    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
     150        return;
     151
     152    ASSERT(!label.isNull());
     153    if (label.isNull())
     154        return;
     155
     156    auto callStack = createScriptCallStackForConsole(exec, 1);
     157
     158    auto it = m_times.find(label);
    157159    if (it == m_times.end()) {
    158160        // FIXME: Send an enum to the frontend for localization?
    159         String warning = makeString("Timer \"", title, "\" does not exist");
    160         addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning));
     161        String warning = makeString("Timer \"", label, "\" does not exist");
     162        addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning, WTFMove(callStack)));
    161163        return;
    162164    }
     
    164166    MonotonicTime startTime = it->value;
    165167    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 
    170 void 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);
     168    String message = makeString(label, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms");
     169    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(arguments), WTFMove(callStack)));
     170}
     171
     172void InspectorConsoleAgent::stopTiming(JSC::ExecState* exec, const String& label)
     173{
     174    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
     175        return;
     176
     177    ASSERT(!label.isNull());
     178    if (label.isNull())
     179        return;
     180
     181    auto callStack = createScriptCallStackForConsole(exec, 1);
     182
     183    auto it = m_times.find(label);
    180184    if (it == m_times.end()) {
    181185        // 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));
     186        String warning = makeString("Timer \"", label, "\" does not exist");
     187        addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Warning, warning, WTFMove(callStack)));
    184188        return;
    185189    }
     
    187191    MonotonicTime startTime = it->value;
    188192    Seconds elapsed = MonotonicTime::now() - startTime;
    189     String message = makeString(title, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms");
     193    String message = makeString(label, ": ", FormattedNumber::fixedWidth(elapsed.milliseconds(), 3), "ms");
    190194    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, WTFMove(callStack)));
    191195
     
    209213}
    210214
    211 void InspectorConsoleAgent::getCounterLabel(Ref<ScriptArguments>&& arguments, String& title, String& identifier)
    212 {
    213     if (!arguments->argumentCount()) {
    214         // '@' prefix for engine generated labels.
    215         title = "Global"_s;
    216         identifier = makeString('@', title);
    217     } else {
    218         // '#' prefix for user labels.
    219         arguments->getFirstArgumentAsString(title);
    220         identifier = makeString('#', title);
    221     }
    222 }
    223 
    224 void InspectorConsoleAgent::count(JSC::ExecState* state, Ref<ScriptArguments>&& arguments)
    225 {
    226     if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
    227         return;
    228 
    229     String title;
    230     String identifier;
    231     getCounterLabel(WTFMove(arguments), title, identifier);
    232 
    233     auto result = m_counts.add(identifier, 1);
     215void InspectorConsoleAgent::count(JSC::ExecState* exec, const String& label)
     216{
     217    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
     218        return;
     219
     220    auto result = m_counts.add(label, 1);
    234221    if (!result.isNewEntry)
    235222        result.iterator->value += 1;
     
    237224    // FIXME: Web Inspector should have a better UI for counters, but for now we just log an updated counter value.
    238225
    239     String message = makeString(title, ": ", result.iterator->value);
    240     Ref<ScriptCallStack> callStack = createScriptCallStackForConsole(state);
    241     addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, WTFMove(callStack)));
    242 }
    243 
    244 void InspectorConsoleAgent::countReset(JSC::ExecState*, Ref<ScriptArguments>&& arguments)
    245 {
    246     if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
    247         return;
    248 
    249     String title;
    250     String identifier;
    251     getCounterLabel(WTFMove(arguments), title, identifier);
    252 
    253     auto it = m_counts.find(identifier);
     226    String message = makeString(label, ": ", result.iterator->value);
     227    addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Debug, message, createScriptCallStackForConsole(exec, 1)));
     228}
     229
     230void InspectorConsoleAgent::countReset(JSC::ExecState* exec, const String& label)
     231{
     232    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
     233        return;
     234
     235    auto it = m_counts.find(label);
    254236    if (it == m_counts.end()) {
    255237        // FIXME: Send an enum to the frontend for localization?
    256         String warning = makeString("Counter \"", title, "\" does not exist");
    257         addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Warning, warning));
     238        String warning = makeString("Counter \"", label, "\" does not exist");
     239        addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Log, MessageLevel::Warning, warning, createScriptCallStackForConsole(exec, 1)));
    258240        return;
    259241    }
  • trunk/Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h

    r246850 r246876  
    7171    void addMessageToConsole(std::unique_ptr<ConsoleMessage>);
    7272
    73     void startTiming(const String& title);
    74     void logTiming(const String& title, Ref<ScriptArguments>&&);
    75     void stopTiming(const String& title, Ref<ScriptCallStack>&&);
     73    void startTiming(JSC::ExecState*, const String& label);
     74    void logTiming(JSC::ExecState*, const String& label, Ref<ScriptArguments>&&);
     75    void stopTiming(JSC::ExecState*, const String& label);
    7676    void takeHeapSnapshot(const String& title);
    77     void count(JSC::ExecState*, Ref<ScriptArguments>&&);
    78     void countReset(JSC::ExecState*, Ref<ScriptArguments>&&);
     77    void count(JSC::ExecState*, const String& label);
     78    void countReset(JSC::ExecState*, const String& label);
    7979
    8080    void getLoggingChannels(ErrorString&, RefPtr<JSON::ArrayOf<Protocol::Console::Channel>>&) override;
     
    8282
    8383protected:
    84     void getCounterLabel(Ref<ScriptArguments>&&, String& title, String& identifier);
    8584    void addConsoleMessage(std::unique_ptr<ConsoleMessage>);
    8685
  • trunk/Source/JavaScriptCore/runtime/ConsoleClient.h

    r246850 r246876  
    5656
    5757    virtual void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
    58     virtual void count(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
    59     virtual void countReset(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
     58    virtual void count(ExecState*, const String& label) = 0;
     59    virtual void countReset(ExecState*, const String& label) = 0;
    6060    virtual void profile(ExecState*, const String& title) = 0;
    6161    virtual void profileEnd(ExecState*, const String& title) = 0;
    6262    virtual void takeHeapSnapshot(ExecState*, const String& title) = 0;
    63     virtual void time(ExecState*, const String& title) = 0;
    64     virtual void timeLog(ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) = 0;
    65     virtual void timeEnd(ExecState*, const String& title) = 0;
     63    virtual void time(ExecState*, const String& label) = 0;
     64    virtual void timeLog(ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&) = 0;
     65    virtual void timeEnd(ExecState*, const String& label) = 0;
    6666    virtual void timeStamp(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
    6767    virtual void record(ExecState*, Ref<Inspector::ScriptArguments>&&) = 0;
  • trunk/Source/JavaScriptCore/runtime/ConsoleObject.cpp

    r246850 r246876  
    3434
    3535namespace JSC {
     36
     37static String valueOrDefaultLabelString(ExecState* exec)
     38{
     39    if (exec->argumentCount() < 1)
     40        return "default"_s;
     41
     42    auto value = exec->argument(0);
     43    if (value.isUndefined())
     44        return "default"_s;
     45
     46    return value.toWTFString(exec);
     47}
    3648
    3749STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(ConsoleObject);
     
    220232static EncodedJSValue JSC_HOST_CALL consoleProtoFuncCount(ExecState* exec)
    221233{
    222     ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    223     if (!client)
    224         return JSValue::encode(jsUndefined());
    225 
    226     client->count(exec, Inspector::createScriptArguments(exec, 0));
     234    auto scope = DECLARE_THROW_SCOPE(exec->vm());
     235    auto* client = exec->lexicalGlobalObject()->consoleClient();
     236    if (!client)
     237        return JSValue::encode(jsUndefined());
     238
     239    auto label = valueOrDefaultLabelString(exec);
     240    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     241
     242    client->count(exec, label);
    227243    return JSValue::encode(jsUndefined());
    228244}
     
    230246static EncodedJSValue JSC_HOST_CALL consoleProtoFuncCountReset(ExecState* exec)
    231247{
    232     ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    233     if (!client)
    234         return JSValue::encode(jsUndefined());
    235 
    236     client->countReset(exec, Inspector::createScriptArguments(exec, 0));
     248    auto scope = DECLARE_THROW_SCOPE(exec->vm());
     249    auto* client = exec->lexicalGlobalObject()->consoleClient();
     250    if (!client)
     251        return JSValue::encode(jsUndefined());
     252
     253    auto label = valueOrDefaultLabelString(exec);
     254    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     255
     256    client->countReset(exec, label);
    237257    return JSValue::encode(jsUndefined());
    238258}
     
    301321}
    302322
    303 static String valueOrDefaultLabelString(ExecState* exec, JSValue value)
    304 {
    305     if (value.isUndefined())
    306         return "default"_s;
    307     return value.toWTFString(exec);
    308 }
    309 
    310323static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTime(ExecState* exec)
    311324{
    312     VM& vm = exec->vm();
    313     auto scope = DECLARE_THROW_SCOPE(vm);
    314     ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    315     if (!client)
    316         return JSValue::encode(jsUndefined());
    317 
    318     String title;
    319     if (exec->argumentCount() < 1)
    320         title = "default"_s;
    321     else {
    322         title = valueOrDefaultLabelString(exec, exec->argument(0));
    323         RETURN_IF_EXCEPTION(scope, encodedJSValue());
    324     }
    325 
    326     client->time(exec, title);
     325    auto scope = DECLARE_THROW_SCOPE(exec->vm());
     326    auto* client = exec->lexicalGlobalObject()->consoleClient();
     327    if (!client)
     328        return JSValue::encode(jsUndefined());
     329
     330    auto label = valueOrDefaultLabelString(exec);
     331    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     332
     333    client->time(exec, label);
    327334    return JSValue::encode(jsUndefined());
    328335}
     
    330337static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeLog(ExecState* exec)
    331338{
    332     VM& vm = exec->vm();
    333     auto scope = DECLARE_THROW_SCOPE(vm);
    334     ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    335     if (!client)
    336         return JSValue::encode(jsUndefined());
    337 
    338     String title;
    339     if (exec->argumentCount() < 1)
    340         title =  "default"_s;
    341     else {
    342         title = valueOrDefaultLabelString(exec, exec->argument(0));
    343         RETURN_IF_EXCEPTION(scope, encodedJSValue());
    344     }
    345 
    346     client->timeLog(exec, title, Inspector::createScriptArguments(exec, 1));
     339    auto scope = DECLARE_THROW_SCOPE(exec->vm());
     340    auto* client = exec->lexicalGlobalObject()->consoleClient();
     341    if (!client)
     342        return JSValue::encode(jsUndefined());
     343
     344    auto label = valueOrDefaultLabelString(exec);
     345    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     346
     347    client->timeLog(exec, label, Inspector::createScriptArguments(exec, 1));
    347348    return JSValue::encode(jsUndefined());
    348349}
     
    350351static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState* exec)
    351352{
    352     VM& vm = exec->vm();
    353     auto scope = DECLARE_THROW_SCOPE(vm);
    354     ConsoleClient* client = exec->lexicalGlobalObject()->consoleClient();
    355     if (!client)
    356         return JSValue::encode(jsUndefined());
    357 
    358     String title;
    359     if (exec->argumentCount() < 1)
    360         title =  "default"_s;
    361     else {
    362         title = valueOrDefaultLabelString(exec, exec->argument(0));
    363         RETURN_IF_EXCEPTION(scope, encodedJSValue());
    364     }
    365 
    366     client->timeEnd(exec, title);
     353    auto scope = DECLARE_THROW_SCOPE(exec->vm());
     354    auto* client = exec->lexicalGlobalObject()->consoleClient();
     355    if (!client)
     356        return JSValue::encode(jsUndefined());
     357
     358    auto label = valueOrDefaultLabelString(exec);
     359    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     360
     361    client->timeEnd(exec, label);
    367362    return JSValue::encode(jsUndefined());
    368363}
  • trunk/Source/WebCore/ChangeLog

    r246875 r246876  
     12019-06-27  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: throw an error if console.count/console.countReset is called with an object that throws an error from toString
     4        https://bugs.webkit.org/show_bug.cgi?id=199252
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Parse the arguments passed to `console.count` and `console.countReset` before sending it to
     9        the `ConsoleClient` so that an error can be thrown if the first argument doesn't `toString`
     10        nicely (e.g. without throwing an error).
     11
     12        Generate call stacks for `console.countReset` to match other `console` methods. Also do this
     13        for `console.time`, `console.timeLog`, and `console.timeEnd`. Limit the call stack to only
     14        have the top frame, so no unnecessary/extra data is sent to the frontend (right now, only
     15        the call location is displayed).
     16
     17        Rename `title` to `label` for `console.time`, `console.timeLog`, and `console.timeEnd` to
     18        better match the spec.
     19
     20        Updated existing LayoutTests:
     21         - inspector/console/console-count.html
     22         - inspector/console/console-api.html
     23
     24        Also covered by existing WPT tests.
     25
     26        * inspector/InspectorInstrumentation.h:
     27        (WebCore::InspectorInstrumentation::consoleCount):
     28        (WebCore::InspectorInstrumentation::consoleCountReset):
     29        (WebCore::InspectorInstrumentation::startConsoleTiming):
     30        (WebCore::InspectorInstrumentation::logConsoleTiming):
     31        (WebCore::InspectorInstrumentation::stopConsoleTiming):
     32        * inspector/InspectorInstrumentation.cpp:
     33        (WebCore::InspectorInstrumentation::consoleCountImpl):
     34        (WebCore::InspectorInstrumentation::consoleCountResetImpl):
     35        (WebCore::InspectorInstrumentation::startConsoleTimingImpl):
     36        (WebCore::InspectorInstrumentation::logConsoleTimingImpl):
     37        (WebCore::InspectorInstrumentation::stopConsoleTimingImpl):
     38
     39        * page/PageConsoleClient.h:
     40        * page/PageConsoleClient.cpp:
     41        (WebCore::PageConsoleClient::count):
     42        (WebCore::PageConsoleClient::countReset):
     43        (WebCore::PageConsoleClient::time):
     44        (WebCore::PageConsoleClient::timeLog):
     45        (WebCore::PageConsoleClient::timeEnd):
     46
     47        * workers/WorkerConsoleClient.h:
     48        * workers/WorkerConsoleClient.cpp:
     49        (WebCore::WorkerConsoleClient::count):
     50        (WebCore::WorkerConsoleClient::countReset):
     51        (WebCore::WorkerConsoleClient::time):
     52        (WebCore::WorkerConsoleClient::timeLog):
     53        (WebCore::WorkerConsoleClient::timeEnd):
     54
     55        * worklets/WorkletConsoleClient.h:
     56        * worklets/WorkletConsoleClient.cpp:
     57        (WebCore::WorkletConsoleClient::count):
     58        (WebCore::WorkletConsoleClient::countReset):
     59
    1602019-06-27  Saam Barati  <sbarati@apple.com>
    261
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r246850 r246876  
    852852}
    853853
    854 void InspectorInstrumentation::consoleCountImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, Ref<ScriptArguments>&& arguments)
    855 {
    856     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
    857         consoleAgent->count(state, WTFMove(arguments));
    858 }
    859 
    860 void InspectorInstrumentation::consoleCountResetImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, Ref<ScriptArguments>&& arguments)
    861 {
    862     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
    863         consoleAgent->countReset(state, WTFMove(arguments));
     854void InspectorInstrumentation::consoleCountImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, const String& label)
     855{
     856    if (auto* consoleAgent = instrumentingAgents.webConsoleAgent())
     857        consoleAgent->count(state, label);
     858}
     859
     860void InspectorInstrumentation::consoleCountResetImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* state, const String& label)
     861{
     862    if (auto* consoleAgent = instrumentingAgents.webConsoleAgent())
     863        consoleAgent->countReset(state, label);
    864864}
    865865
     
    870870}
    871871
    872 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& title)
     872void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, JSC::ExecState* exec, const String& label)
    873873{
    874874    if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled())
    875875        return;
    876876
    877     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
    878         timelineAgent->time(frame, title);
    879     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
    880         consoleAgent->startTiming(title);
    881 }
    882 
    883 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title)
     877    if (auto* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
     878        timelineAgent->time(frame, label);
     879    if (auto* consoleAgent = instrumentingAgents.webConsoleAgent())
     880        consoleAgent->startTiming(exec, label);
     881}
     882
     883void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* exec, const String& label)
    884884{
    885885    if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled())
    886886        return;
    887887
    888     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
    889         consoleAgent->startTiming(title);
    890 }
    891 
    892 void InspectorInstrumentation::logConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title, Ref<Inspector::ScriptArguments>&& arguments)
     888    if (auto* consoleAgent = instrumentingAgents.webConsoleAgent())
     889        consoleAgent->startTiming(exec, label);
     890}
     891
     892void InspectorInstrumentation::logConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments)
    893893{
    894894    if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled())
    895895        return;
    896896
    897     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
    898         consoleAgent->logTiming(title, WTFMove(arguments));
    899 }
    900 
    901 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& title, Ref<ScriptCallStack>&& stack)
     897    if (auto* consoleAgent = instrumentingAgents.webConsoleAgent())
     898        consoleAgent->logTiming(exec, label, WTFMove(arguments));
     899}
     900
     901void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, JSC::ExecState* exec, const String& label)
    902902{
    903903    if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled())
    904904        return;
    905905
    906     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
    907         consoleAgent->stopTiming(title, WTFMove(stack));
    908     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
    909         timelineAgent->timeEnd(frame, title);
    910 }
    911 
    912 void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, const String& title, Ref<ScriptCallStack>&& stack)
     906    if (auto* consoleAgent = instrumentingAgents.webConsoleAgent())
     907        consoleAgent->stopTiming(exec, label);
     908    if (auto* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
     909        timelineAgent->timeEnd(frame, label);
     910}
     911
     912void InspectorInstrumentation::stopConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, JSC::ExecState* exec, const String& label)
    913913{
    914914    if (!instrumentingAgents.inspectorEnvironment().developerExtrasEnabled())
    915915        return;
    916916
    917     if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
    918         consoleAgent->stopTiming(title, WTFMove(stack));
     917    if (auto* consoleAgent = instrumentingAgents.webConsoleAgent())
     918        consoleAgent->stopTiming(exec, label);
    919919}
    920920
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r246850 r246876  
    222222    static void addMessageToConsole(WorkerGlobalScope&, std::unique_ptr<Inspector::ConsoleMessage>);
    223223
    224     static void consoleCount(Page&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
    225     static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
    226     static void consoleCountReset(Page&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
    227     static void consoleCountReset(WorkerGlobalScope&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
     224    static void consoleCount(Page&, JSC::ExecState*, const String& label);
     225    static void consoleCount(WorkerGlobalScope&, JSC::ExecState*, const String& label);
     226    static void consoleCountReset(Page&, JSC::ExecState*, const String& label);
     227    static void consoleCountReset(WorkerGlobalScope&, JSC::ExecState*, const String& label);
    228228
    229229    static void takeHeapSnapshot(Frame&, const String& title);
    230     static void startConsoleTiming(Frame&, const String& title);
    231     static void startConsoleTiming(WorkerGlobalScope&, const String& title);
    232     static void logConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptArguments>&&);
    233     static void logConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptArguments>&&);
    234     static void stopConsoleTiming(Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
    235     static void stopConsoleTiming(WorkerGlobalScope&, const String& title, Ref<Inspector::ScriptCallStack>&&);
     230    static void startConsoleTiming(Frame&, JSC::ExecState*, const String& label);
     231    static void startConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label);
     232    static void logConsoleTiming(Frame&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
     233    static void logConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
     234    static void stopConsoleTiming(Frame&, JSC::ExecState*, const String& label);
     235    static void stopConsoleTiming(WorkerGlobalScope&, JSC::ExecState*, const String& label);
    236236    static void consoleTimeStamp(Frame&, Ref<Inspector::ScriptArguments>&&);
    237237    static void startProfiling(Page&, JSC::ExecState*, const String& title);
     
    406406    static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>);
    407407
    408     static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
    409     static void consoleCountResetImpl(InstrumentingAgents&, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&);
     408    static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
     409    static void consoleCountResetImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
    410410    static void takeHeapSnapshotImpl(InstrumentingAgents&, const String& title);
    411     static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title);
    412     static void startConsoleTimingImpl(InstrumentingAgents&, const String& title);
    413     static void logConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptArguments>&&);
    414     static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title, Ref<Inspector::ScriptCallStack>&&);
    415     static void stopConsoleTimingImpl(InstrumentingAgents&, const String& title, Ref<Inspector::ScriptCallStack>&&);
     411    static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label);
     412    static void startConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
     413    static void logConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&);
     414    static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, JSC::ExecState*, const String& label);
     415    static void stopConsoleTimingImpl(InstrumentingAgents&, JSC::ExecState*, const String& label);
    416416    static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, Ref<Inspector::ScriptArguments>&&);
    417417    static void startProfilingImpl(InstrumentingAgents&, JSC::ExecState*, const String& title);
     
    13881388}
    13891389
    1390 inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)
    1391 {
    1392     consoleCountImpl(instrumentingAgentsForPage(page), state, WTFMove(arguments));
    1393 }
    1394 
    1395 inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)
    1396 {
    1397     consoleCountImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, WTFMove(arguments));
    1398 }
    1399 
    1400 inline void InspectorInstrumentation::consoleCountReset(Page& page, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)
    1401 {
    1402     consoleCountResetImpl(instrumentingAgentsForPage(page), state, WTFMove(arguments));
    1403 }
    1404 
    1405 inline void InspectorInstrumentation::consoleCountReset(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, Ref<Inspector::ScriptArguments>&& arguments)
    1406 {
    1407     consoleCountResetImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, WTFMove(arguments));
     1390inline void InspectorInstrumentation::consoleCount(Page& page, JSC::ExecState* state, const String& label)
     1391{
     1392    consoleCountImpl(instrumentingAgentsForPage(page), state, label);
     1393}
     1394
     1395inline void InspectorInstrumentation::consoleCount(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label)
     1396{
     1397    consoleCountImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label);
     1398}
     1399
     1400inline void InspectorInstrumentation::consoleCountReset(Page& page, JSC::ExecState* state, const String& label)
     1401{
     1402    consoleCountResetImpl(instrumentingAgentsForPage(page), state, label);
     1403}
     1404
     1405inline void InspectorInstrumentation::consoleCountReset(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* state, const String& label)
     1406{
     1407    consoleCountResetImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), state, label);
    14081408}
    14091409
     
    14151415}
    14161416
    1417 inline void InspectorInstrumentation::startConsoleTiming(Frame& frame, const String& title)
    1418 {
    1419     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
    1420         startConsoleTimingImpl(*instrumentingAgents, frame, title);
    1421 }
    1422 
    1423 inline void InspectorInstrumentation::startConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title)
    1424 {
    1425     startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title);
    1426 }
    1427 
    1428 inline void InspectorInstrumentation::logConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptArguments>&& arguments)
    1429 {
    1430     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
    1431         logConsoleTimingImpl(*instrumentingAgents, title, WTFMove(arguments));
    1432 }
    1433 
    1434 inline void InspectorInstrumentation::logConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title, Ref<Inspector::ScriptArguments>&& arguments)
    1435 {
    1436     logConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title, WTFMove(arguments));
    1437 }
    1438 
    1439 inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, const String& title, Ref<Inspector::ScriptCallStack>&& stack)
    1440 {
    1441     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
    1442         stopConsoleTimingImpl(*instrumentingAgents, frame, title, WTFMove(stack));
    1443 }
    1444 
    1445 inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, const String& title, Ref<Inspector::ScriptCallStack>&& stack)
    1446 {
    1447     stopConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), title, WTFMove(stack));
     1417inline void InspectorInstrumentation::startConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label)
     1418{
     1419    if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
     1420        startConsoleTimingImpl(*instrumentingAgents, frame, exec, label);
     1421}
     1422
     1423inline void InspectorInstrumentation::startConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label)
     1424{
     1425    startConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label);
     1426}
     1427
     1428inline void InspectorInstrumentation::logConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments)
     1429{
     1430    if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
     1431        logConsoleTimingImpl(*instrumentingAgents, exec, label, WTFMove(arguments));
     1432}
     1433
     1434inline void InspectorInstrumentation::logConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label, Ref<Inspector::ScriptArguments>&& arguments)
     1435{
     1436    logConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label, WTFMove(arguments));
     1437}
     1438
     1439inline void InspectorInstrumentation::stopConsoleTiming(Frame& frame, JSC::ExecState* exec, const String& label)
     1440{
     1441    if (auto* instrumentingAgents = instrumentingAgentsForFrame(frame))
     1442        stopConsoleTimingImpl(*instrumentingAgents, frame, exec, label);
     1443}
     1444
     1445inline void InspectorInstrumentation::stopConsoleTiming(WorkerGlobalScope& workerGlobalScope, JSC::ExecState* exec, const String& label)
     1446{
     1447    stopConsoleTimingImpl(instrumentingAgentsForWorkerGlobalScope(workerGlobalScope), exec, label);
    14481448}
    14491449
  • trunk/Source/WebCore/page/PageConsoleClient.cpp

    r246850 r246876  
    171171}
    172172
    173 void PageConsoleClient::count(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)
    174 {
    175     InspectorInstrumentation::consoleCount(m_page, exec, WTFMove(arguments));
    176 }
    177 
    178 void PageConsoleClient::countReset(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)
    179 {
    180     InspectorInstrumentation::consoleCountReset(m_page, exec, WTFMove(arguments));
     173void PageConsoleClient::count(JSC::ExecState* exec, const String& label)
     174{
     175    InspectorInstrumentation::consoleCount(m_page, exec, label);
     176}
     177
     178void PageConsoleClient::countReset(JSC::ExecState* exec, const String& label)
     179{
     180    InspectorInstrumentation::consoleCountReset(m_page, exec, label);
    181181}
    182182
     
    198198}
    199199
    200 void PageConsoleClient::time(JSC::ExecState*, const String& title)
    201 {
    202     InspectorInstrumentation::startConsoleTiming(m_page.mainFrame(), title);
    203 }
    204 
    205 void PageConsoleClient::timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments)
    206 {
    207     InspectorInstrumentation::logConsoleTiming(m_page.mainFrame(), title, WTFMove(arguments));
    208 }
    209 
    210 void PageConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)
    211 {
    212     InspectorInstrumentation::stopConsoleTiming(m_page.mainFrame(), title, createScriptCallStackForConsole(exec, 1));
     200void PageConsoleClient::time(JSC::ExecState* exec, const String& label)
     201{
     202    InspectorInstrumentation::startConsoleTiming(m_page.mainFrame(), exec, label);
     203}
     204
     205void PageConsoleClient::timeLog(JSC::ExecState* exec, const String& label, Ref<ScriptArguments>&& arguments)
     206{
     207    InspectorInstrumentation::logConsoleTiming(m_page.mainFrame(), exec, label, WTFMove(arguments));
     208}
     209
     210void PageConsoleClient::timeEnd(JSC::ExecState* exec, const String& label)
     211{
     212    InspectorInstrumentation::stopConsoleTiming(m_page.mainFrame(), exec, label);
    213213}
    214214
  • trunk/Source/WebCore/page/PageConsoleClient.h

    r246850 r246876  
    6868protected:
    6969    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
    70     void count(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
    71     void countReset(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
     70    void count(JSC::ExecState*, const String& label) override;
     71    void countReset(JSC::ExecState*, const String& label) override;
    7272    void profile(JSC::ExecState*, const String& title) override;
    7373    void profileEnd(JSC::ExecState*, const String& title) override;
    7474    void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
    75     void time(JSC::ExecState*, const String& title) override;
    76     void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) override;
    77     void timeEnd(JSC::ExecState*, const String& title) override;
     75    void time(JSC::ExecState*, const String& label) override;
     76    void timeLog(JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&) override;
     77    void timeEnd(JSC::ExecState*, const String& label) override;
    7878    void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
    7979    void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
  • trunk/Source/WebCore/workers/WorkerConsoleClient.cpp

    r246850 r246876  
    5151}
    5252
    53 void WorkerConsoleClient::count(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)
     53void WorkerConsoleClient::count(JSC::ExecState* exec, const String& label)
    5454{
    55     InspectorInstrumentation::consoleCount(m_workerGlobalScope, exec, WTFMove(arguments));
     55    InspectorInstrumentation::consoleCount(m_workerGlobalScope, exec, label);
    5656}
    5757
    58 void WorkerConsoleClient::countReset(JSC::ExecState* exec, Ref<ScriptArguments>&& arguments)
     58void WorkerConsoleClient::countReset(JSC::ExecState* exec, const String& label)
    5959{
    60     InspectorInstrumentation::consoleCountReset(m_workerGlobalScope, exec, WTFMove(arguments));
     60    InspectorInstrumentation::consoleCountReset(m_workerGlobalScope, exec, label);
    6161}
    6262
    63 void WorkerConsoleClient::time(JSC::ExecState*, const String& title)
     63void WorkerConsoleClient::time(JSC::ExecState* exec, const String& label)
    6464{
    65     InspectorInstrumentation::startConsoleTiming(m_workerGlobalScope, title);
     65    InspectorInstrumentation::startConsoleTiming(m_workerGlobalScope, exec, label);
    6666}
    6767
    68 void WorkerConsoleClient::timeLog(JSC::ExecState*, const String& title, Ref<ScriptArguments>&& arguments)
     68void WorkerConsoleClient::timeLog(JSC::ExecState* exec, const String& label, Ref<ScriptArguments>&& arguments)
    6969{
    70     InspectorInstrumentation::logConsoleTiming(m_workerGlobalScope, title, WTFMove(arguments));
     70    InspectorInstrumentation::logConsoleTiming(m_workerGlobalScope, exec, label, WTFMove(arguments));
    7171}
    7272
    73 void WorkerConsoleClient::timeEnd(JSC::ExecState* exec, const String& title)
     73void WorkerConsoleClient::timeEnd(JSC::ExecState* exec, const String& label)
    7474{
    75     InspectorInstrumentation::stopConsoleTiming(m_workerGlobalScope, title, createScriptCallStackForConsole(exec, 1));
     75    InspectorInstrumentation::stopConsoleTiming(m_workerGlobalScope, exec, label);
    7676}
    7777
  • trunk/Source/WebCore/workers/WorkerConsoleClient.h

    r246850 r246876  
    4444protected:
    4545    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
    46     void count(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
    47     void countReset(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
     46    void count(JSC::ExecState*, const String& label) override;
     47    void countReset(JSC::ExecState*, const String& label) override;
    4848    void profile(JSC::ExecState*, const String& title) override;
    4949    void profileEnd(JSC::ExecState*, const String& title) override;
    5050    void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
    51     void time(JSC::ExecState*, const String& title) override;
    52     void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) override;
    53     void timeEnd(JSC::ExecState*, const String& title) override;
     51    void time(JSC::ExecState*, const String& label) override;
     52    void timeLog(JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&) override;
     53    void timeEnd(JSC::ExecState*, const String& label) override;
    5454    void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
    5555    void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) override;
  • trunk/Source/WebCore/worklets/WorkletConsoleClient.cpp

    r246850 r246876  
    5353}
    5454
    55 void WorkletConsoleClient::count(JSC::ExecState*, Ref<ScriptArguments>&&) { }
    56 void WorkletConsoleClient::countReset(JSC::ExecState*, Ref<ScriptArguments>&&) { }
     55void WorkletConsoleClient::count(JSC::ExecState*, const String&) { }
     56void WorkletConsoleClient::countReset(JSC::ExecState*, const String&) { }
    5757
    5858void WorkletConsoleClient::time(JSC::ExecState*, const String&) { }
  • trunk/Source/WebCore/worklets/WorkletConsoleClient.h

    r246850 r246876  
    4646private:
    4747    void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;
    48     void count(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;
    49     void countReset(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;
     48    void count(JSC::ExecState*, const String& label) final;
     49    void countReset(JSC::ExecState*, const String& label) final;
    5050    void profile(JSC::ExecState*, const String& title) final;
    5151    void profileEnd(JSC::ExecState*, const String& title) final;
    5252    void takeHeapSnapshot(JSC::ExecState*, const String& title) final;
    53     void time(JSC::ExecState*, const String& title) final;
    54     void timeLog(JSC::ExecState*, const String& title, Ref<Inspector::ScriptArguments>&&) final;
    55     void timeEnd(JSC::ExecState*, const String& title) final;
     53    void time(JSC::ExecState*, const String& label) final;
     54    void timeLog(JSC::ExecState*, const String& label, Ref<Inspector::ScriptArguments>&&) final;
     55    void timeEnd(JSC::ExecState*, const String& label) final;
    5656    void timeStamp(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;
    5757    void record(JSC::ExecState*, Ref<Inspector::ScriptArguments>&&) final;
  • trunk/Source/WebInspectorUI/ChangeLog

    r246866 r246876  
     12019-06-27  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: throw an error if console.count/console.countReset is called with an object that throws an error from toString
     4        https://bugs.webkit.org/show_bug.cgi?id=199252
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        Add entries for `console.countReset` and `console.timeLog`.
     9
     10        Rename `title` to `label` for `console.time`, `console.timeLog`, and `console.timeEnd` to
     11        better match the spec.
     12
     13        * UserInterface/Models/NativeFunctionParameters.js:
     14
    1152019-06-26  Joseph Pecoraro  <pecoraro@apple.com>
    216
  • trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js

    r242992 r246876  
    162162    Console: {
    163163        assert: "condition, [message], [...values]",
    164         count: "[label]",
     164        count: "label = \"default\"",
     165        countReset: "label = \"default\"",
    165166        debug: "message, [...values]",
    166167        dir: "object",
     
    179180        table: "data, [columns]",
    180181        takeHeapSnapshot: "[label]",
    181         time: "name = \"default\"",
    182         timeEnd: "name = \"default\"",
     182        time: "label = \"default\"",
     183        timeLog: "label = \"default\"",
     184        timeEnd: "label = \"default\"",
    183185        timeStamp: "[label]",
    184186        trace: "message, [...values]",
Note: See TracChangeset for help on using the changeset viewer.