mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:17:35 +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:
parent
68006f3e16
commit
a982e0380e
3 changed files with 24 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
|
||||||
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -8,6 +9,9 @@
|
||||||
#include <LibJS/Runtime/Realm.h>
|
#include <LibJS/Runtime/Realm.h>
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/HTML/Navigator.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 {
|
namespace Web::HTML {
|
||||||
|
|
||||||
|
@ -24,4 +28,14 @@ Navigator::Navigator(JS::Realm& realm)
|
||||||
|
|
||||||
Navigator::~Navigator() = default;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ public:
|
||||||
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-pdfviewerenabled
|
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-pdfviewerenabled
|
||||||
bool pdf_viewer_enabled() const { return false; }
|
bool pdf_viewer_enabled() const { return false; }
|
||||||
|
|
||||||
|
bool webdriver() const;
|
||||||
|
|
||||||
virtual ~Navigator() override;
|
virtual ~Navigator() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -9,8 +9,8 @@ interface Navigator {
|
||||||
// objects implementing this interface also implement the interfaces given below
|
// objects implementing this interface also implement the interfaces given below
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: As NavigatorContentUtils, NavigatorCookies, and NavigatorPlugins are not used in WorkerNavigator,
|
// NOTE: As NavigatorContentUtils, NavigatorCookies, NavigatorPlugins, and NavigatorAutomationInformation
|
||||||
// we define them here.
|
// are not used in WorkerNavigator, we define them here.
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/system-state.html#navigatorcontentutils
|
// https://html.spec.whatwg.org/multipage/system-state.html#navigatorcontentutils
|
||||||
interface mixin NavigatorContentUtils {
|
interface mixin NavigatorContentUtils {
|
||||||
|
@ -31,6 +31,11 @@ interface mixin NavigatorPlugins {
|
||||||
readonly attribute boolean pdfViewerEnabled;
|
readonly attribute boolean pdfViewerEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://w3c.github.io/webdriver/#dom-navigatorautomationinformation
|
||||||
|
interface mixin NavigatorAutomationInformation {
|
||||||
|
readonly attribute boolean webdriver;
|
||||||
|
};
|
||||||
|
|
||||||
Navigator includes NavigatorID;
|
Navigator includes NavigatorID;
|
||||||
Navigator includes NavigatorLanguage;
|
Navigator includes NavigatorLanguage;
|
||||||
Navigator includes NavigatorOnLine;
|
Navigator includes NavigatorOnLine;
|
||||||
|
@ -38,4 +43,4 @@ Navigator includes NavigatorContentUtils;
|
||||||
Navigator includes NavigatorCookies;
|
Navigator includes NavigatorCookies;
|
||||||
Navigator includes NavigatorPlugins;
|
Navigator includes NavigatorPlugins;
|
||||||
Navigator includes NavigatorConcurrentHardware;
|
Navigator includes NavigatorConcurrentHardware;
|
||||||
|
Navigator includes NavigatorAutomationInformation;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue