1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00

LibWeb: Implement navigator.webdriver

This is defined via the NavigatorAutomationInformation interface mixin
from the WebDriver spec: https://w3c.github.io/webdriver/#interface
This commit is contained in:
Linus Groh 2022-10-12 23:52:58 +02:00 committed by Andreas Kling
parent 68006f3e16
commit a982e0380e
3 changed files with 24 additions and 3 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -8,6 +9,9 @@
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/Navigator.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Page/Page.h>
namespace Web::HTML {
@ -24,4 +28,14 @@ Navigator::Navigator(JS::Realm& realm)
Navigator::~Navigator() = default;
// https://w3c.github.io/webdriver/#dfn-webdriver
bool Navigator::webdriver() const
{
// Returns true if webdriver-active flag is set, false otherwise.
// NOTE: The NavigatorAutomationInformation interface should not be exposed on WorkerNavigator.
auto const& window = verify_cast<HTML::Window>(HTML::current_global_object());
return window.page()->is_webdriver_active();
}
}