Web Inspector: throw an error if console.count/console.countReset is called with...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jun 2019 08:25:04 +0000 (08:25 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jun 2019 08:25:04 +0000 (08:25 +0000)
commit8c99da3bdf38459391934063033991c98fc72771
treef422d2a55a4fd5777f650f9ef734d55975e3c14b
parente3a526aa57086ec2d7a85c26090844216cafede1
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 `ConsoleMessage`s 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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246876 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/console/console-api-expected.txt
LayoutTests/inspector/console/console-api.html
LayoutTests/inspector/console/console-count-expected.txt
LayoutTests/inspector/console/console-count.html
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/ConsoleMessage.cpp
Source/JavaScriptCore/inspector/ConsoleMessage.h
Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h
Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h
Source/JavaScriptCore/runtime/ConsoleClient.h
Source/JavaScriptCore/runtime/ConsoleObject.cpp
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/page/PageConsoleClient.cpp
Source/WebCore/page/PageConsoleClient.h
Source/WebCore/workers/WorkerConsoleClient.cpp
Source/WebCore/workers/WorkerConsoleClient.h
Source/WebCore/worklets/WorkletConsoleClient.cpp
Source/WebCore/worklets/WorkletConsoleClient.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js