Bug 101021 - Web Inspector: add console.clear()
Summary: Web Inspector: add console.clear()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-01 23:58 PDT by Andrey Lushnikov
Modified: 2013-01-16 22:13 PST (History)
12 users (show)

See Also:


Attachments
Patch (11.05 KB, patch)
2012-11-02 01:20 PDT, Andrey Lushnikov
no flags Details | Formatted Diff | Diff
Patch (12.73 KB, patch)
2012-11-02 08:22 PDT, Andrey Lushnikov
no flags Details | Formatted Diff | Diff
Patch (12.82 KB, patch)
2012-11-02 08:54 PDT, Andrey Lushnikov
no flags Details | Formatted Diff | Diff
Patch (14.73 KB, patch)
2012-11-06 01:30 PST, Andrey Lushnikov
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Lushnikov 2012-11-01 23:58:34 PDT
downstream: http://code.google.com/p/chromium/issues/detail?id=158770

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4

Steps to reproduce the problem:
1. Open the Developer Tools
2. Select Console
3. type console.clear()

What is the expected behavior?
To clear the console's log area, through the script.

What went wrong?
Nothing happens

Did this work before? No 

Chrome version: 22.0.1229.94  Channel: stable
OS Version: OS X 10.7.5

I know I can erase it by tying CMD+K, but I like to have a debug for my code, like, show every event triggered when I click some element. What I'd like to do is to have the whole console cleared when I click. console.clear() works on Firebug, but doesn't in Developer Tools.
Comment 1 Andrey Lushnikov 2012-11-02 01:20:10 PDT
Created attachment 172003 [details]
Patch
Comment 2 Pavel Feldman 2012-11-02 01:37:45 PDT
Comment on attachment 172003 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=172003&action=review

> Source/WebCore/inspector/ConsoleMessage.cpp:115
> +    case ClearConsoleMessageType: return TypeBuilder::Console::ConsoleMessage::Type::Clear;

Drop "Console", it's cleaner.

> Source/WebCore/inspector/front-end/ConsoleMessage.js:80
> +                    this._messageElement = document.createTextNode("console.clear()");

I would say "Console was cleared" with gray. You'll need to put it into WebCore/English.lproj/localizedStrings.js

> LayoutTests/inspector/console/console-clear-function-expected.txt:11
> +console.clear()

Sounds like the source location is missing.

> LayoutTests/inspector/console/console-clear-function.html:22
> +    RuntimeAgent.evaluate("console.clear();", function() {

Use named functions (step1)
Comment 3 Andrey Lushnikov 2012-11-02 08:22:02 PDT
Created attachment 172064 [details]
Patch
Comment 4 Vsevolod Vlasov 2012-11-02 08:47:41 PDT
Comment on attachment 172064 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=172064&action=review

> LayoutTests/inspector/console/console-clear-function.html:42
> +Tests that console is cleared via console.clear() method

Please add a link to the bug.
Comment 5 Andrey Lushnikov 2012-11-02 08:54:00 PDT
Created attachment 172071 [details]
Patch
Comment 6 Build Bot 2012-11-02 10:36:02 PDT
Comment on attachment 172071 [details]
Patch

Attachment 172071 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/14703008
Comment 7 Andrey Lushnikov 2012-11-06 01:30:55 PST
Created attachment 172517 [details]
Patch
Comment 8 WebKit Review Bot 2012-11-06 08:14:55 PST
Comment on attachment 172517 [details]
Patch

Clearing flags on attachment: 172517

Committed r133614: <http://trac.webkit.org/changeset/133614>
Comment 9 WebKit Review Bot 2012-11-06 08:15:00 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Brad 2013-01-16 13:47:51 PST
Seriously? It is fixed and closed because it now prints "Console was cleared"? Shouldn't it also, you know, clear the console too? That was the OP's expected behavior, and it does not do that currently.
Comment 11 Pavel Feldman 2013-01-16 22:13:10 PST
(In reply to comment #10)
> Seriously? It is fixed and closed because it now prints "Console was cleared"? Shouldn't it also, you know, clear the console too? That was the OP's expected behavior, and it does not do that currently.

This option has no effect when "Preserve Log upon navigation" is toggled. You could use "clear()" in console to clean it up in such cases.