script: Initial stubs for Credential Management API (#38839)

Stubs `Credential`, `CredentialContainer`, and `PasswordCredential` and
adds the credentials attribute to navigator.

Testing: WPT
Fixes: Partially #38788

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
This commit is contained in:
Ashwin Naren 2025-09-06 12:48:38 -07:00 committed by GitHub
parent 643ac08cf0
commit 3ac8875697
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 347 additions and 0 deletions

View file

@ -34,6 +34,7 @@ use crate::dom::bindings::utils::to_frozen_array;
#[cfg(feature = "bluetooth")]
use crate::dom::bluetooth::Bluetooth;
use crate::dom::clipboard::Clipboard;
use crate::dom::credentialmanagement::credentialscontainer::CredentialsContainer;
use crate::dom::csp::{GlobalCspReporting, Violation};
use crate::dom::gamepad::Gamepad;
use crate::dom::gamepad::gamepadevent::GamepadEventType;
@ -66,6 +67,7 @@ pub(crate) struct Navigator {
reflector_: Reflector,
#[cfg(feature = "bluetooth")]
bluetooth: MutNullableDom<Bluetooth>,
credentials: MutNullableDom<CredentialsContainer>,
plugins: MutNullableDom<PluginArray>,
mime_types: MutNullableDom<MimeTypeArray>,
service_worker: MutNullableDom<ServiceWorkerContainer>,
@ -90,6 +92,7 @@ impl Navigator {
reflector_: Reflector::new(),
#[cfg(feature = "bluetooth")]
bluetooth: Default::default(),
credentials: Default::default(),
plugins: Default::default(),
mime_types: Default::default(),
service_worker: Default::default(),
@ -229,6 +232,12 @@ impl NavigatorMethods<crate::DomTypeHolder> for Navigator {
.or_init(|| Bluetooth::new(&self.global(), CanGc::note()))
}
// https://www.w3.org/TR/credential-management-1/#framework-credential-management
fn Credentials(&self) -> DomRoot<CredentialsContainer> {
self.credentials
.or_init(|| CredentialsContainer::new(&self.global(), CanGc::note()))
}
// https://html.spec.whatwg.org/multipage/#navigatorlanguage
fn Language(&self) -> DOMString {
navigatorinfo::Language()