[webkit-changes] [WebKit/WebKit] 80d190: Web Inspector: the frontend should be able to prev...

Devin Rousso noreply at github.com
Tue Mar 19 12:44:33 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 80d190d733833b4730f5acdf7ccd8eb6ef98227d
      https://github.com/WebKit/WebKit/commit/80d190d733833b4730f5acdf7ccd8eb6ef98227d
  Author: Devin Rousso <hi at devinrousso.com>
  Date:   2024-03-19 (Tue, 19 Mar 2024)

  Changed paths:
    A LayoutTests/inspector/console/setConsoleClearAPIEnabled-expected.txt
    A LayoutTests/inspector/console/setConsoleClearAPIEnabled.html
    M Source/JavaScriptCore/inspector/ConsoleMessage.cpp
    M Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp
    M Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h
    M Source/JavaScriptCore/inspector/protocol/Console.json
    M Source/WebCore/inspector/CommandLineAPIHost.cpp
    M Source/WebCore/inspector/CommandLineAPIHost.h
    M Source/WebCore/inspector/CommandLineAPIHost.idl
    M Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
    M Source/WebInspectorUI/UserInterface/Base/Setting.js
    M Source/WebInspectorUI/UserInterface/Controllers/ConsoleManager.js
    M Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js
    M Source/WebInspectorUI/UserInterface/Protocol/Target.js
    M Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js

  Log Message:
  -----------
  Web Inspector: the frontend should be able to prevent the inspected page from clearing the console
https://bugs.webkit.org/show_bug.cgi?id=270753

Reviewed by Patrick Angle.

"malicious" pages can sometimes repeatedly call `console.clear()` to prevent logging from being readable by the developer.

* Source/WebInspectorUI/UserInterface/Base/Setting.js:
* Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Add a checkbox in the Console pane of the Settings Tab to control this.

* Source/WebInspectorUI/UserInterface/Controllers/ConsoleManager.js:
(WI.ConsoleManager):
(WI.ConsoleManager.prototype.initializeTarget): Added.
(WI.ConsoleManager.prototype.messagesCleared):
(WI.ConsoleManager.prototype._setConsoleClearAPIEnabled): Added.
(WI.ConsoleManager.prototype._handleConsoleClearAPIEnabledSettingChanged): Added.
* Source/WebInspectorUI/UserInterface/Protocol/Target.js:
(WI.Target.prototype.initialize):
Notify all `WI.Target` whenever the above checkbox changes (and when Web Inspector is first opened).

* Source/JavaScriptCore/inspector/protocol/Console.json:
* Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h:
* Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp:
(Inspector::InspectorConsoleAgent::clearMessages):
(Inspector::InspectorConsoleAgent::setConsoleClearAPIEnabled): Added.
(Inspector::InspectorConsoleAgent::addMessageToConsole):
(Inspector::InspectorConsoleAgent::addConsoleMessage):
(Inspector::isGroupMessage): Deleted.
Listen for the above checkbox changes and prevent clearing existing `ConsoleMessages` if desired (which also means `Console.messagesCleared` is not sent).

* Source/JavaScriptCore/inspector/ConsoleMessage.cpp:
(Inspector::isGroupMessage): Added.
(Inspector::ConsoleMessage::isEqual const):
Previously, any `console.clear()` would remove all `ConsoleMessage`, meaning that there'd never be a way for it to have a repeat count other than 1.  Now, `console.clear()` might not do that (depending on the above checkbox in the frontend), so make sure the backend treats all `console.clear()` as unique.
Drive-by: do the same for `console.group()`, `console.groupCollapsed()`, and `console.groupEnd()`.

* Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js:
(WI.ConsoleObserver.prototype.messageAdded):
Drive-by: make sure to ignore all `console.clear()` regardless of reason.

* Source/WebCore/inspector/CommandLineAPIHost.idl:
* Source/WebCore/inspector/CommandLineAPIHost.h:
* Source/WebCore/inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::clearConsoleMessages): Deleted.
Drive-by: remove unused code.

* Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js:

* LayoutTests/inspector/console/setConsoleClearAPIEnabled.html: Added.
* LayoutTests/inspector/console/setConsoleClearAPIEnabled-expected.txt: Added.

Canonical link: https://commits.webkit.org/276362@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list