mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
LibWeb: Add an Internals.headless
attribute
This returns true if the browser is running in headless mode.
This commit is contained in:
parent
e764df15eb
commit
a44b18236c
Notes:
github-actions[bot]
2024-12-10 18:32:51 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/a44b18236cc Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2858 Reviewed-by: https://github.com/trflynn89
5 changed files with 17 additions and 0 deletions
|
@ -239,4 +239,9 @@ void Internals::set_echo_server_port(u16 const port)
|
|||
s_echo_server_port = port;
|
||||
}
|
||||
|
||||
bool Internals::headless()
|
||||
{
|
||||
return internals_page().client().is_headless();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
static u16 get_echo_server_port();
|
||||
static void set_echo_server_port(u16 port);
|
||||
|
||||
bool headless();
|
||||
|
||||
private:
|
||||
explicit Internals(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
|
|
@ -42,4 +42,6 @@ interface Internals {
|
|||
DOMString getComputedRole(Element element);
|
||||
DOMString getComputedLabel(Element element);
|
||||
unsigned short getEchoServerPort();
|
||||
|
||||
readonly attribute boolean headless;
|
||||
};
|
||||
|
|
1
Tests/LibWeb/Text/expected/Internals/headless.txt
Normal file
1
Tests/LibWeb/Text/expected/Internals/headless.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Browser is running headlessly: true
|
7
Tests/LibWeb/Text/input/Internals/headless.html
Normal file
7
Tests/LibWeb/Text/input/Internals/headless.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
println(`Browser is running headlessly: ${internals.headless}`);
|
||||
});
|
||||
</script>
|
Loading…
Reference in a new issue