mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +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
5 changed files with 9 additions and 7 deletions
|
@ -76,10 +76,14 @@ ThrowCompletionOr<Value> Console::warn()
|
||||||
return js_undefined();
|
return js_undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1.1.2. clear(), https://console.spec.whatwg.org/#clear
|
||||||
Value Console::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)
|
if (m_client)
|
||||||
return m_client->clear();
|
m_client->clear();
|
||||||
return js_undefined();
|
return js_undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ public:
|
||||||
ThrowCompletionOr<Vector<Value>> formatter(Vector<Value>& args);
|
ThrowCompletionOr<Vector<Value>> formatter(Vector<Value>& args);
|
||||||
virtual ThrowCompletionOr<Value> printer(Console::LogLevel log_level, Vector<Value>&) = 0;
|
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 trace() = 0;
|
||||||
virtual Value assert_() = 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);
|
m_client.async_did_get_js_console_messages(start_index, message_types, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value WebContentConsoleClient::clear()
|
void WebContentConsoleClient::clear()
|
||||||
{
|
{
|
||||||
clear_output();
|
clear_output();
|
||||||
return JS::js_undefined();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::Value WebContentConsoleClient::trace()
|
JS::Value WebContentConsoleClient::trace()
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
void send_messages(i32 start_index);
|
void send_messages(i32 start_index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual JS::Value clear() override;
|
virtual void clear() override;
|
||||||
virtual JS::Value trace() override;
|
virtual JS::Value trace() override;
|
||||||
virtual JS::Value assert_() override;
|
virtual JS::Value assert_() override;
|
||||||
virtual JS::ThrowCompletionOr<JS::Value> printer(JS::Console::LogLevel log_level, Vector<JS::Value>&) 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");
|
js_out("\033[3J\033[H\033[2J");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return JS::js_undefined();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual JS::Value trace() override
|
virtual JS::Value trace() override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue