import { RequestTokenStatus, LogoutRpsStatus, DisconnectStatus, FederatedAuthRequest, FederatedAuthRequestReceiver } from '/gen/third_party/blink/public/mojom/webid/federated_auth_request.mojom.m.js';
function toMojoTokenStatus(status) { return RequestTokenStatus["k" + status];
}
// A mock service for responding to federated auth requests.
export class MockFederatedAuthRequest {
constructor() { this.receiver_ = new FederatedAuthRequestReceiver(this); this.interceptor_ = new MojoInterfaceInterceptor(FederatedAuthRequest.$interfaceName); this.interceptor_.oninterfacerequest = e => { this.receiver_.$.bindHandle(e.handle);
} this.interceptor_.start(); this.token_ = null; this.selected_identity_provider_config_url_ = null; this.status_ = RequestTokenStatus.kError; this.logoutRpsStatus_ = LogoutRpsStatus.kError; this.disconnectStatus_ = DisconnectStatus.kError; this.returnPending_ = false; this.pendingPromiseResolve_ = null;
}
// Causes the subsequent `navigator.credentials.get()` to resolve with the token.
returnToken(selected_identity_provider_config_url, token) { this.status_ = RequestTokenStatus.kSuccess; this.selected_identity_provider_config_url_ = selected_identity_provider_config_url; this.token_ = token; this.returnPending_ = false;
}
// Causes the subsequent `navigator.credentials.get()` to reject with the error.
returnError(error) { if (error == "Success") thrownew Error("Success is not a valid error"); this.status_ = toMojoTokenStatus(error); this.selected_identity_provider_config_url_ = null; this.token_ = null; this.returnPending_ = false;
}
// Causes the subsequent `navigator.credentials.get()` to return a pending promise // that can be cancelled using `cancelTokenRequest()`.
returnPendingPromise() { this.returnPending_ = true;
}
logoutRpsReturn(status) {
let validated = LogoutRpsStatus[status]; if (validated === undefined) thrownew Error("Invalid status: " + status); this.logoutRpsStatus_ = validated;
}
// Causes the subsequent `FederatedCredential.disconnect` to reject with this // status.
disconnectReturn(status) {
let validated = DisconnectStatus[status]; if (validated === undefined) thrownew Error("Invalid status: " + status); this.disconnectStatus_ = validated;
}
// Clean up and reset mock stubs asynchronously, so that the blink side // closes its proxies and notifies JS sensor objects before new test is // started.
await new Promise(resolve => { step_timeout(resolve, 0); });
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.