mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
LibJS+WebContent+js: Bring console.clear() to spec
This is identical to before, since we don't have "group stacks" yet, but clear() now uses ThrowCompletionOr.
This commit is contained in:
parent
834ced82d4
commit
9b78e287b0
Notes:
sideshowbarker
2024-07-17 22:06:57 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/9b78e287b09 Pull-request: https://github.com/SerenityOS/serenity/pull/11382 Reviewed-by: https://github.com/davidot ✅
5 changed files with 9 additions and 7 deletions
|
@ -76,10 +76,14 @@ ThrowCompletionOr<Value> Console::warn()
|
|||
return js_undefined();
|
||||
}
|
||||
|
||||
// 1.1.2. clear(), https://console.spec.whatwg.org/#clear
|
||||
Value Console::clear()
|
||||
{
|
||||
// 1. TODO: Empty the appropriate group stack.
|
||||
|
||||
// 2. If possible for the environment, clear the console. (Otherwise, do nothing.)
|
||||
if (m_client)
|
||||
return m_client->clear();
|
||||
m_client->clear();
|
||||
return js_undefined();
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
ThrowCompletionOr<Vector<Value>> formatter(Vector<Value>& args);
|
||||
virtual ThrowCompletionOr<Value> printer(Console::LogLevel log_level, Vector<Value>&) = 0;
|
||||
|
||||
virtual Value clear() = 0;
|
||||
virtual void clear() = 0;
|
||||
virtual Value trace() = 0;
|
||||
virtual Value assert_() = 0;
|
||||
|
||||
|
|
|
@ -115,10 +115,9 @@ void WebContentConsoleClient::send_messages(i32 start_index)
|
|||
m_client.async_did_get_js_console_messages(start_index, message_types, messages);
|
||||
}
|
||||
|
||||
JS::Value WebContentConsoleClient::clear()
|
||||
void WebContentConsoleClient::clear()
|
||||
{
|
||||
clear_output();
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
JS::Value WebContentConsoleClient::trace()
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
void send_messages(i32 start_index);
|
||||
|
||||
private:
|
||||
virtual JS::Value clear() override;
|
||||
virtual void clear() override;
|
||||
virtual JS::Value trace() override;
|
||||
virtual JS::Value assert_() override;
|
||||
virtual JS::ThrowCompletionOr<JS::Value> printer(JS::Console::LogLevel log_level, Vector<JS::Value>&) override;
|
||||
|
|
|
@ -1122,11 +1122,10 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual JS::Value clear() override
|
||||
virtual void clear() override
|
||||
{
|
||||
js_out("\033[3J\033[H\033[2J");
|
||||
fflush(stdout);
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
virtual JS::Value trace() override
|
||||
|
|
Loading…
Reference in a new issue