mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +01:00
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:
parent
643ac08cf0
commit
3ac8875697
11 changed files with 347 additions and 0 deletions
73
components/script/dom/credentialmanagement/credential.rs
Normal file
73
components/script/dom/credentialmanagement/credential.rs
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
use std::rc::Rc;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use script_bindings::realms::{AlreadyInRealm, InRealm};
|
||||
use script_bindings::str::{DOMString, USVString};
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::CredentialBinding::CredentialMethods;
|
||||
use crate::dom::bindings::codegen::DomTypeHolder::DomTypeHolder;
|
||||
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::promise::Promise;
|
||||
use crate::dom::window::Window;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
#[dom_struct]
|
||||
pub(crate) struct Credential {
|
||||
reflector_: Reflector,
|
||||
id: USVString,
|
||||
credential_type: DOMString,
|
||||
}
|
||||
|
||||
impl Credential {
|
||||
pub(crate) fn new_inherited(id: USVString, credential_type: DOMString) -> Credential {
|
||||
Credential {
|
||||
reflector_: Reflector::new(),
|
||||
id,
|
||||
credential_type,
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub(crate) fn new(
|
||||
global: &GlobalScope,
|
||||
id: USVString,
|
||||
credential_type: DOMString,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<Credential> {
|
||||
reflect_dom_object(
|
||||
Box::new(Credential::new_inherited(id, credential_type)),
|
||||
global,
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl CredentialMethods<DomTypeHolder> for Credential {
|
||||
// https://www.w3.org/TR/credential-management-1/#dom-credential-id
|
||||
fn Id(&self) -> USVString {
|
||||
self.id.clone()
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#dom-credential-type
|
||||
fn Type(&self) -> DOMString {
|
||||
self.credential_type.clone()
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#dom-credential-isconditionalmediationavailable
|
||||
fn IsConditionalMediationAvailable(_global: &Window) -> Rc<Promise> {
|
||||
let in_realm_proof = AlreadyInRealm::assert::<DomTypeHolder>();
|
||||
// FIXME:(arihant2math) return false
|
||||
Promise::new_in_current_realm(InRealm::Already(&in_realm_proof), CanGc::note())
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/credential-management-1/#dom-credential-willrequestconditionalcreation
|
||||
fn WillRequestConditionalCreation(_global: &Window) -> Rc<Promise> {
|
||||
let in_realm_proof = AlreadyInRealm::assert::<DomTypeHolder>();
|
||||
Promise::new_in_current_realm(InRealm::Already(&in_realm_proof), CanGc::note())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue