Web Inspector: InspectorFrontendAPIDispatcher should not ignore all exceptions
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Dec 2020 21:06:17 +0000 (21:06 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Dec 2020 21:06:17 +0000 (21:06 +0000)
commit7e684dd39460ec5afc2a5bcedbda821b86d9a125
tree3ce0fa520c41f0e1400e8c308b127d06ac178019
parent6c517580d6ff09f2c3939cb91101bb8601dcdf93
Web Inspector: InspectorFrontendAPIDispatcher should not ignore all exceptions
https://bugs.webkit.org/show_bug.cgi?id=219378

Reviewed by Devin Rousso.

Source/WebCore:

Covered by existing Web Inspector layout tests.

* bindings/js/ScriptController.h: Make evaluateInWorld public and exported.

* inspector/InspectorFrontendAPIDispatcher.h:
* inspector/InspectorFrontendAPIDispatcher.cpp:
(WebCore::InspectorFrontendAPIDispatcher::evaluateOrQueueExpression):
(WebCore::InspectorFrontendAPIDispatcher::evaluateExpression):
Evaluate and pass along the result whether it's a value or exception.

* inspector/InspectorFrontendClientLocal.h:
* inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::evaluationResultToBoolean):
(WebCore::InspectorFrontendClientLocal::isDebuggingEnabled):
(WebCore::InspectorFrontendClientLocal::isTimelineProfilingEnabled):
(WebCore::InspectorFrontendClientLocal::isProfilingJavaScript):
Refactor the common code to take an EvaluationResult and figure out if the value is true or falsy.

* platform/Logging.h: Add an Inspector logging channel, for logging errors.

Source/WebKit:

The underlying method used for frontend expression evaluations is
ScriptController::evaluateIgnoringExceptions. This method calls
evaluateInWorld and returns nullopt if an exception happens.

Switch to using evaluateInWorld directly and using the existing ValueOrException
type from in WebCore. Change our EvaluationResult type to use ValueOrException
in place of JSC::JSValue. ValueOrException is Expected<JSC::JSValue, ExceptionDetails>
so this is exposing more error information in addition to the JSC::JSValue.

* Platform/Logging.h: Add 'Inspector' log channel for WebKit.framework.

* WebProcess/Inspector/WebInspectorUIExtensionController.cpp:
(WebKit::WebInspectorUIExtensionController::WebInspectorUIExtensionController):
(WebKit::WebInspectorUIExtensionController::~WebInspectorUIExtensionController):
Remove unnecessary debugging code that was accidentally left in/commented out.

* WebProcess/Inspector/WebInspectorUIExtensionController.h:
(WebKit::WebInspectorUIExtensionController::parseInspectorExtensionErrorFromResult): Deleted.
(WebKit::WebInspectorUIExtensionController::parseInspectorExtensionErrorFromEvaluationResult): Added.
(WebKit::WebInspectorUIExtensionController::registerExtension):
(WebKit::WebInspectorUIExtensionController::unregisterExtension):
Adapt to using the new result type. Use the InspectorExtensionID type where possible.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270453 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/ScriptController.h
Source/WebCore/inspector/InspectorFrontendAPIDispatcher.cpp
Source/WebCore/inspector/InspectorFrontendAPIDispatcher.h
Source/WebCore/inspector/InspectorFrontendClientLocal.cpp
Source/WebCore/inspector/InspectorFrontendClientLocal.h
Source/WebCore/platform/Logging.h
Source/WebKit/ChangeLog
Source/WebKit/Platform/Logging.h
Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp
Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h