mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
[deps] Autofill: Update prettier to v3 (#7014)
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
This commit is contained in:
parent
4ff5f38e89
commit
28de9439be
@ -48,7 +48,7 @@ const decorator = componentWrapperDecorator(
|
|||||||
},
|
},
|
||||||
({ globals }) => {
|
({ globals }) => {
|
||||||
return { theme: `${globals["theme"]}` };
|
return { theme: `${globals["theme"]}` };
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const preview: Preview = {
|
const preview: Preview = {
|
||||||
|
@ -171,7 +171,7 @@ function distSafariApp(cb, subBuildPath) {
|
|||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
return cb;
|
return cb;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ function safariCopyAssets(source, dest) {
|
|||||||
.on("error", reject)
|
.on("error", reject)
|
||||||
.pipe(gulpif("safari/Info.plist", replace("0.0.1", manifest.version)))
|
.pipe(gulpif("safari/Info.plist", replace("0.0.1", manifest.version)))
|
||||||
.pipe(
|
.pipe(
|
||||||
gulpif("safari/Info.plist", replace("0.0.2", process.env.BUILD_NUMBER || manifest.version))
|
gulpif("safari/Info.plist", replace("0.0.2", process.env.BUILD_NUMBER || manifest.version)),
|
||||||
)
|
)
|
||||||
.pipe(gulpif("desktop.xcodeproj/project.pbxproj", replace("../../../build", "../safari/app")))
|
.pipe(gulpif("desktop.xcodeproj/project.pbxproj", replace("../../../build", "../safari/app")))
|
||||||
.pipe(gulp.dest(dest))
|
.pipe(gulp.dest(dest))
|
||||||
@ -208,8 +208,8 @@ async function safariCopyBuild(source, dest) {
|
|||||||
delete manifest.optional_permissions;
|
delete manifest.optional_permissions;
|
||||||
manifest.permissions.push("nativeMessaging");
|
manifest.permissions.push("nativeMessaging");
|
||||||
return manifest;
|
return manifest;
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.pipe(gulp.dest(dest))
|
.pipe(gulp.dest(dest))
|
||||||
.on("end", resolve);
|
.on("end", resolve);
|
||||||
|
@ -18,12 +18,12 @@ export type OrganizationServiceInitOptions = OrganizationServiceFactoryOptions &
|
|||||||
|
|
||||||
export function organizationServiceFactory(
|
export function organizationServiceFactory(
|
||||||
cache: { organizationService?: AbstractOrganizationService } & CachedServices,
|
cache: { organizationService?: AbstractOrganizationService } & CachedServices,
|
||||||
opts: OrganizationServiceInitOptions
|
opts: OrganizationServiceInitOptions,
|
||||||
): Promise<AbstractOrganizationService> {
|
): Promise<AbstractOrganizationService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
"organizationService",
|
"organizationService",
|
||||||
opts,
|
opts,
|
||||||
async () => new BrowserOrganizationService(await stateServiceFactory(cache, opts))
|
async () => new BrowserOrganizationService(await stateServiceFactory(cache, opts)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ export type PolicyServiceInitOptions = PolicyServiceFactoryOptions &
|
|||||||
|
|
||||||
export function policyServiceFactory(
|
export function policyServiceFactory(
|
||||||
cache: { policyService?: AbstractPolicyService } & CachedServices,
|
cache: { policyService?: AbstractPolicyService } & CachedServices,
|
||||||
opts: PolicyServiceInitOptions
|
opts: PolicyServiceInitOptions,
|
||||||
): Promise<AbstractPolicyService> {
|
): Promise<AbstractPolicyService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -33,7 +33,7 @@ export function policyServiceFactory(
|
|||||||
async () =>
|
async () =>
|
||||||
new BrowserPolicyService(
|
new BrowserPolicyService(
|
||||||
await stateServiceFactory(cache, opts),
|
await stateServiceFactory(cache, opts),
|
||||||
await organizationServiceFactory(cache, opts)
|
await organizationServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ export class BrowserPolicyService extends PolicyService {
|
|||||||
if (activated === undefined) {
|
if (activated === undefined) {
|
||||||
this.stateService.setActivateAutoFillOnPageLoadFromPolicy(!autofillEnabled);
|
this.stateService.setActivateAutoFillOnPageLoadFromPolicy(!autofillEnabled);
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ export type AccountServiceInitOptions = AccountServiceFactoryOptions &
|
|||||||
|
|
||||||
export function accountServiceFactory(
|
export function accountServiceFactory(
|
||||||
cache: { accountService?: AccountService } & CachedServices,
|
cache: { accountService?: AccountService } & CachedServices,
|
||||||
opts: AccountServiceInitOptions
|
opts: AccountServiceInitOptions,
|
||||||
): Promise<AccountService> {
|
): Promise<AccountService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -38,7 +38,7 @@ export function accountServiceFactory(
|
|||||||
new AccountServiceImplementation(
|
new AccountServiceImplementation(
|
||||||
await messagingServiceFactory(cache, opts),
|
await messagingServiceFactory(cache, opts),
|
||||||
await logServiceFactory(cache, opts),
|
await logServiceFactory(cache, opts),
|
||||||
await globalStateProviderFactory(cache, opts)
|
await globalStateProviderFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@ export type AuthRequestCryptoServiceInitOptions = AuthRequestCryptoServiceFactor
|
|||||||
|
|
||||||
export function authRequestCryptoServiceFactory(
|
export function authRequestCryptoServiceFactory(
|
||||||
cache: { authRequestCryptoService?: AuthRequestCryptoServiceAbstraction } & CachedServices,
|
cache: { authRequestCryptoService?: AuthRequestCryptoServiceAbstraction } & CachedServices,
|
||||||
opts: AuthRequestCryptoServiceInitOptions
|
opts: AuthRequestCryptoServiceInitOptions,
|
||||||
): Promise<AuthRequestCryptoServiceAbstraction> {
|
): Promise<AuthRequestCryptoServiceAbstraction> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
"authRequestCryptoService",
|
"authRequestCryptoService",
|
||||||
opts,
|
opts,
|
||||||
async () => new AuthRequestCryptoServiceImplementation(await cryptoServiceFactory(cache, opts))
|
async () => new AuthRequestCryptoServiceImplementation(await cryptoServiceFactory(cache, opts)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ export type AuthServiceInitOptions = AuthServiceFactoyOptions &
|
|||||||
|
|
||||||
export function authServiceFactory(
|
export function authServiceFactory(
|
||||||
cache: { authService?: AbstractAuthService } & CachedServices,
|
cache: { authService?: AbstractAuthService } & CachedServices,
|
||||||
opts: AuthServiceInitOptions
|
opts: AuthServiceInitOptions,
|
||||||
): Promise<AbstractAuthService> {
|
): Promise<AbstractAuthService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -113,7 +113,7 @@ export function authServiceFactory(
|
|||||||
await passwordStrengthServiceFactory(cache, opts),
|
await passwordStrengthServiceFactory(cache, opts),
|
||||||
await policyServiceFactory(cache, opts),
|
await policyServiceFactory(cache, opts),
|
||||||
await deviceTrustCryptoServiceFactory(cache, opts),
|
await deviceTrustCryptoServiceFactory(cache, opts),
|
||||||
await authRequestCryptoServiceFactory(cache, opts)
|
await authRequestCryptoServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ export type DeviceTrustCryptoServiceInitOptions = DeviceTrustCryptoServiceFactor
|
|||||||
|
|
||||||
export function deviceTrustCryptoServiceFactory(
|
export function deviceTrustCryptoServiceFactory(
|
||||||
cache: { deviceTrustCryptoService?: DeviceTrustCryptoServiceAbstraction } & CachedServices,
|
cache: { deviceTrustCryptoService?: DeviceTrustCryptoServiceAbstraction } & CachedServices,
|
||||||
opts: DeviceTrustCryptoServiceInitOptions
|
opts: DeviceTrustCryptoServiceInitOptions,
|
||||||
): Promise<DeviceTrustCryptoServiceAbstraction> {
|
): Promise<DeviceTrustCryptoServiceAbstraction> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -68,7 +68,7 @@ export function deviceTrustCryptoServiceFactory(
|
|||||||
await appIdServiceFactory(cache, opts),
|
await appIdServiceFactory(cache, opts),
|
||||||
await devicesApiServiceFactory(cache, opts),
|
await devicesApiServiceFactory(cache, opts),
|
||||||
await i18nServiceFactory(cache, opts),
|
await i18nServiceFactory(cache, opts),
|
||||||
await platformUtilsServiceFactory(cache, opts)
|
await platformUtilsServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ export type KeyConnectorServiceInitOptions = KeyConnectorServiceFactoryOptions &
|
|||||||
|
|
||||||
export function keyConnectorServiceFactory(
|
export function keyConnectorServiceFactory(
|
||||||
cache: { keyConnectorService?: AbstractKeyConnectorService } & CachedServices,
|
cache: { keyConnectorService?: AbstractKeyConnectorService } & CachedServices,
|
||||||
opts: KeyConnectorServiceInitOptions
|
opts: KeyConnectorServiceInitOptions,
|
||||||
): Promise<AbstractKeyConnectorService> {
|
): Promise<AbstractKeyConnectorService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -65,7 +65,7 @@ export function keyConnectorServiceFactory(
|
|||||||
await logServiceFactory(cache, opts),
|
await logServiceFactory(cache, opts),
|
||||||
await organizationServiceFactory(cache, opts),
|
await organizationServiceFactory(cache, opts),
|
||||||
await cryptoFunctionServiceFactory(cache, opts),
|
await cryptoFunctionServiceFactory(cache, opts),
|
||||||
opts.keyConnectorServiceOptions.logoutCallback
|
opts.keyConnectorServiceOptions.logoutCallback,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@ export type TokenServiceInitOptions = TokenServiceFactoryOptions & StateServiceI
|
|||||||
|
|
||||||
export function tokenServiceFactory(
|
export function tokenServiceFactory(
|
||||||
cache: { tokenService?: AbstractTokenService } & CachedServices,
|
cache: { tokenService?: AbstractTokenService } & CachedServices,
|
||||||
opts: TokenServiceInitOptions
|
opts: TokenServiceInitOptions,
|
||||||
): Promise<AbstractTokenService> {
|
): Promise<AbstractTokenService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
"tokenService",
|
"tokenService",
|
||||||
opts,
|
opts,
|
||||||
async () => new TokenService(await stateServiceFactory(cache, opts))
|
async () => new TokenService(await stateServiceFactory(cache, opts)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export type TwoFactorServiceInitOptions = TwoFactorServiceFactoryOptions &
|
|||||||
|
|
||||||
export async function twoFactorServiceFactory(
|
export async function twoFactorServiceFactory(
|
||||||
cache: { twoFactorService?: AbstractTwoFactorService } & CachedServices,
|
cache: { twoFactorService?: AbstractTwoFactorService } & CachedServices,
|
||||||
opts: TwoFactorServiceInitOptions
|
opts: TwoFactorServiceInitOptions,
|
||||||
): Promise<AbstractTwoFactorService> {
|
): Promise<AbstractTwoFactorService> {
|
||||||
const service = await factory(
|
const service = await factory(
|
||||||
cache,
|
cache,
|
||||||
@ -32,8 +32,8 @@ export async function twoFactorServiceFactory(
|
|||||||
async () =>
|
async () =>
|
||||||
new TwoFactorService(
|
new TwoFactorService(
|
||||||
await i18nServiceFactory(cache, opts),
|
await i18nServiceFactory(cache, opts),
|
||||||
await platformUtilsServiceFactory(cache, opts)
|
await platformUtilsServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
service.init();
|
service.init();
|
||||||
return service;
|
return service;
|
||||||
|
@ -18,12 +18,12 @@ export type UserVerificationApiServiceInitOptions = UserVerificationApiServiceFa
|
|||||||
|
|
||||||
export function userVerificationApiServiceFactory(
|
export function userVerificationApiServiceFactory(
|
||||||
cache: { userVerificationApiService?: UserVerificationApiServiceAbstraction } & CachedServices,
|
cache: { userVerificationApiService?: UserVerificationApiServiceAbstraction } & CachedServices,
|
||||||
opts: UserVerificationApiServiceInitOptions
|
opts: UserVerificationApiServiceInitOptions,
|
||||||
): Promise<UserVerificationApiServiceAbstraction> {
|
): Promise<UserVerificationApiServiceAbstraction> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
"userVerificationApiService",
|
"userVerificationApiService",
|
||||||
opts,
|
opts,
|
||||||
async () => new UserVerificationApiService(await apiServiceFactory(cache, opts))
|
async () => new UserVerificationApiService(await apiServiceFactory(cache, opts)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export type UserVerificationServiceInitOptions = UserVerificationServiceFactoryO
|
|||||||
|
|
||||||
export function userVerificationServiceFactory(
|
export function userVerificationServiceFactory(
|
||||||
cache: { userVerificationService?: AbstractUserVerificationService } & CachedServices,
|
cache: { userVerificationService?: AbstractUserVerificationService } & CachedServices,
|
||||||
opts: UserVerificationServiceInitOptions
|
opts: UserVerificationServiceInitOptions,
|
||||||
): Promise<AbstractUserVerificationService> {
|
): Promise<AbstractUserVerificationService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -45,7 +45,7 @@ export function userVerificationServiceFactory(
|
|||||||
await stateServiceFactory(cache, opts),
|
await stateServiceFactory(cache, opts),
|
||||||
await cryptoServiceFactory(cache, opts),
|
await cryptoServiceFactory(cache, opts),
|
||||||
await i18nServiceFactory(cache, opts),
|
await i18nServiceFactory(cache, opts),
|
||||||
await userVerificationApiServiceFactory(cache, opts)
|
await userVerificationApiServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import { BrowserRouterService } from "../../platform/popup/services/browser-rout
|
|||||||
*/
|
*/
|
||||||
export const fido2AuthGuard: CanActivateFn = async (
|
export const fido2AuthGuard: CanActivateFn = async (
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot
|
state: RouterStateSnapshot,
|
||||||
) => {
|
) => {
|
||||||
const routerService = inject(BrowserRouterService);
|
const routerService = inject(BrowserRouterService);
|
||||||
const authService = inject(AuthService);
|
const authService = inject(AuthService);
|
||||||
|
@ -11,7 +11,7 @@ export class AccountSwitcherComponent {
|
|||||||
constructor(
|
constructor(
|
||||||
private accountSwitcherService: AccountSwitcherService,
|
private accountSwitcherService: AccountSwitcherService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private routerService: BrowserRouterService
|
private routerService: BrowserRouterService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
get accountOptions$() {
|
get accountOptions$() {
|
||||||
|
@ -10,7 +10,10 @@ import { Utils } from "@bitwarden/common/platform/misc/utils";
|
|||||||
templateUrl: "current-account.component.html",
|
templateUrl: "current-account.component.html",
|
||||||
})
|
})
|
||||||
export class CurrentAccountComponent {
|
export class CurrentAccountComponent {
|
||||||
constructor(private accountService: AccountService, private router: Router) {}
|
constructor(
|
||||||
|
private accountService: AccountService,
|
||||||
|
private router: Router,
|
||||||
|
) {}
|
||||||
|
|
||||||
get currentAccount$() {
|
get currentAccount$() {
|
||||||
return this.accountService.activeAccount$;
|
return this.accountService.activeAccount$;
|
||||||
@ -20,7 +23,7 @@ export class CurrentAccountComponent {
|
|||||||
return this.currentAccount$.pipe(
|
return this.currentAccount$.pipe(
|
||||||
map((a) => {
|
map((a) => {
|
||||||
return Utils.isNullOrWhitespace(a.name) ? a.email : a.name;
|
return Utils.isNullOrWhitespace(a.name) ? a.email : a.name;
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ export class EnvironmentComponent extends BaseEnvironmentComponent implements On
|
|||||||
public environmentService: BrowserEnvironmentService,
|
public environmentService: BrowserEnvironmentService,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
modalService: ModalService
|
modalService: ModalService,
|
||||||
) {
|
) {
|
||||||
super(platformUtilsService, environmentService, i18nService, modalService);
|
super(platformUtilsService, environmentService, i18nService, modalService);
|
||||||
this.showCustom = true;
|
this.showCustom = true;
|
||||||
|
@ -20,7 +20,7 @@ export class HintComponent extends BaseHintComponent {
|
|||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
logService: LogService,
|
logService: LogService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
loginService: LoginService
|
loginService: LoginService,
|
||||||
) {
|
) {
|
||||||
super(router, i18nService, apiService, platformUtilsService, logService, loginService);
|
super(router, i18nService, apiService, platformUtilsService, logService, loginService);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ export class HomeComponent implements OnInit, OnDestroy {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private loginService: LoginService
|
private loginService: LoginService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
@ -73,7 +73,7 @@ export class HomeComponent implements OnInit, OnDestroy {
|
|||||||
this.platformUtilsService.showToast(
|
this.platformUtilsService.showToast(
|
||||||
"error",
|
"error",
|
||||||
this.i18nService.t("errorOccured"),
|
this.i18nService.t("errorOccured"),
|
||||||
this.i18nService.t("invalidEmail")
|
this.i18nService.t("invalidEmail"),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
: ("yourVaultIsLocked" | i18n)
|
: ("yourVaultIsLocked" | i18n)
|
||||||
}}
|
}}
|
||||||
</p>
|
</p>
|
||||||
{{ "loggedInAsOn" | i18n : email : webVaultHostname }}
|
{{ "loggedInAsOn" | i18n: email : webVaultHostname }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box" *ngIf="biometricLock">
|
<div class="box" *ngIf="biometricLock">
|
||||||
|
@ -56,7 +56,7 @@ export class LockComponent extends BaseLockComponent {
|
|||||||
dialogService: DialogService,
|
dialogService: DialogService,
|
||||||
deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
||||||
userVerificationService: UserVerificationService,
|
userVerificationService: UserVerificationService,
|
||||||
private routerService: BrowserRouterService
|
private routerService: BrowserRouterService,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
router,
|
router,
|
||||||
@ -76,7 +76,7 @@ export class LockComponent extends BaseLockComponent {
|
|||||||
passwordStrengthService,
|
passwordStrengthService,
|
||||||
dialogService,
|
dialogService,
|
||||||
deviceTrustCryptoService,
|
deviceTrustCryptoService,
|
||||||
userVerificationService
|
userVerificationService,
|
||||||
);
|
);
|
||||||
this.successRoute = "/tabs/current";
|
this.successRoute = "/tabs/current";
|
||||||
this.isInitialLockScreen = (window as any).previousPopupUrl == null;
|
this.isInitialLockScreen = (window as any).previousPopupUrl == null;
|
||||||
|
@ -48,7 +48,7 @@ export class LoginViaAuthRequestComponent
|
|||||||
syncService: SyncService,
|
syncService: SyncService,
|
||||||
deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
||||||
authReqCryptoService: AuthRequestCryptoServiceAbstraction,
|
authReqCryptoService: AuthRequestCryptoServiceAbstraction,
|
||||||
private location: Location
|
private location: Location,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
router,
|
router,
|
||||||
@ -67,7 +67,7 @@ export class LoginViaAuthRequestComponent
|
|||||||
stateService,
|
stateService,
|
||||||
loginService,
|
loginService,
|
||||||
deviceTrustCryptoService,
|
deviceTrustCryptoService,
|
||||||
authReqCryptoService
|
authReqCryptoService,
|
||||||
);
|
);
|
||||||
super.onSuccessfulLogin = async () => {
|
super.onSuccessfulLogin = async () => {
|
||||||
await syncService.fullSync(true);
|
await syncService.fullSync(true);
|
||||||
|
@ -45,7 +45,7 @@ export class LoginComponent extends BaseLoginComponent {
|
|||||||
formValidationErrorService: FormValidationErrorsService,
|
formValidationErrorService: FormValidationErrorsService,
|
||||||
route: ActivatedRoute,
|
route: ActivatedRoute,
|
||||||
loginService: LoginService,
|
loginService: LoginService,
|
||||||
webAuthnLoginService: WebAuthnLoginServiceAbstraction
|
webAuthnLoginService: WebAuthnLoginServiceAbstraction,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
devicesApiService,
|
devicesApiService,
|
||||||
@ -64,7 +64,7 @@ export class LoginComponent extends BaseLoginComponent {
|
|||||||
formValidationErrorService,
|
formValidationErrorService,
|
||||||
route,
|
route,
|
||||||
loginService,
|
loginService,
|
||||||
webAuthnLoginService
|
webAuthnLoginService,
|
||||||
);
|
);
|
||||||
super.onSuccessfulLogin = async () => {
|
super.onSuccessfulLogin = async () => {
|
||||||
await syncService.fullSync(true);
|
await syncService.fullSync(true);
|
||||||
@ -123,7 +123,7 @@ export class LoginComponent extends BaseLoginComponent {
|
|||||||
"&codeChallenge=" +
|
"&codeChallenge=" +
|
||||||
codeChallenge +
|
codeChallenge +
|
||||||
"&email=" +
|
"&email=" +
|
||||||
encodeURIComponent(this.formGroup.controls.email.value)
|
encodeURIComponent(this.formGroup.controls.email.value),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ export class RegisterComponent extends BaseRegisterComponent {
|
|||||||
environmentService: EnvironmentService,
|
environmentService: EnvironmentService,
|
||||||
logService: LogService,
|
logService: LogService,
|
||||||
auditService: AuditService,
|
auditService: AuditService,
|
||||||
dialogService: DialogService
|
dialogService: DialogService,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
formValidationErrorService,
|
formValidationErrorService,
|
||||||
@ -54,7 +54,7 @@ export class RegisterComponent extends BaseRegisterComponent {
|
|||||||
environmentService,
|
environmentService,
|
||||||
logService,
|
logService,
|
||||||
auditService,
|
auditService,
|
||||||
dialogService
|
dialogService,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-content">
|
<div class="box-content">
|
||||||
<div class="box-content-row" appBoxRow>
|
<div class="box-content-row" appBoxRow>
|
||||||
<p>{{ "convertOrganizationEncryptionDesc" | i18n : organization.name }}</p>
|
<p>{{ "convertOrganizationEncryptionDesc" | i18n: organization.name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-content-row">
|
<div class="box-content-row">
|
||||||
<button
|
<button
|
||||||
|
@ -26,7 +26,7 @@ describe("AccountSwitcherService", () => {
|
|||||||
accountSwitcherService = new AccountSwitcherService(
|
accountSwitcherService = new AccountSwitcherService(
|
||||||
accountService,
|
accountService,
|
||||||
stateService,
|
stateService,
|
||||||
messagingService
|
messagingService,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ describe("AccountSwitcherService", () => {
|
|||||||
activeAccountSubject.next(Object.assign(user1AccountInfo, { id: "1" as UserId }));
|
activeAccountSubject.next(Object.assign(user1AccountInfo, { id: "1" as UserId }));
|
||||||
|
|
||||||
const accounts = await firstValueFrom(
|
const accounts = await firstValueFrom(
|
||||||
accountSwitcherService.accountOptions$.pipe(timeout(20))
|
accountSwitcherService.accountOptions$.pipe(timeout(20)),
|
||||||
);
|
);
|
||||||
expect(accounts).toHaveLength(2);
|
expect(accounts).toHaveLength(2);
|
||||||
expect(accounts[0].id).toBe("1");
|
expect(accounts[0].id).toBe("1");
|
||||||
@ -68,7 +68,7 @@ describe("AccountSwitcherService", () => {
|
|||||||
}
|
}
|
||||||
accountsSubject.next(seedAccounts);
|
accountsSubject.next(seedAccounts);
|
||||||
activeAccountSubject.next(
|
activeAccountSubject.next(
|
||||||
Object.assign(seedAccounts["1" as UserId], { id: "1" as UserId })
|
Object.assign(seedAccounts["1" as UserId], { id: "1" as UserId }),
|
||||||
);
|
);
|
||||||
|
|
||||||
const accounts = await firstValueFrom(accountSwitcherService.accountOptions$);
|
const accounts = await firstValueFrom(accountSwitcherService.accountOptions$);
|
||||||
@ -77,7 +77,7 @@ describe("AccountSwitcherService", () => {
|
|||||||
accounts.forEach((account) => {
|
accounts.forEach((account) => {
|
||||||
expect(account.id).not.toBe("addAccount");
|
expect(account.id).not.toBe("addAccount");
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ describe("AccountSwitcherService", () => {
|
|||||||
"switchAccount",
|
"switchAccount",
|
||||||
matches((payload) => {
|
matches((payload) => {
|
||||||
return payload.userId === "1";
|
return payload.userId === "1";
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@ export class AccountSwitcherService {
|
|||||||
constructor(
|
constructor(
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private messagingService: MessagingService
|
private messagingService: MessagingService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
get accountOptions$() {
|
get accountOptions$() {
|
||||||
@ -31,7 +31,7 @@ export class AccountSwitcherService {
|
|||||||
id: id,
|
id: id,
|
||||||
isSelected: id === activeAccount?.id,
|
isSelected: id === activeAccount?.id,
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!hasMaxAccounts) {
|
if (!hasMaxAccounts) {
|
||||||
@ -43,7 +43,7 @@ export class AccountSwitcherService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
|
|||||||
route: ActivatedRoute,
|
route: ActivatedRoute,
|
||||||
organizationApiService: OrganizationApiServiceAbstraction,
|
organizationApiService: OrganizationApiServiceAbstraction,
|
||||||
organizationUserService: OrganizationUserService,
|
organizationUserService: OrganizationUserService,
|
||||||
dialogService: DialogService
|
dialogService: DialogService,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
i18nService,
|
i18nService,
|
||||||
@ -53,7 +53,7 @@ export class SetPasswordComponent extends BaseSetPasswordComponent {
|
|||||||
stateService,
|
stateService,
|
||||||
organizationApiService,
|
organizationApiService,
|
||||||
organizationUserService,
|
organizationUserService,
|
||||||
dialogService
|
dialogService,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ export class SsoComponent extends BaseSsoComponent {
|
|||||||
environmentService: EnvironmentService,
|
environmentService: EnvironmentService,
|
||||||
logService: LogService,
|
logService: LogService,
|
||||||
configService: ConfigServiceAbstraction,
|
configService: ConfigServiceAbstraction,
|
||||||
@Inject(WINDOW) private win: Window
|
@Inject(WINDOW) private win: Window,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
authService,
|
authService,
|
||||||
@ -51,7 +51,7 @@ export class SsoComponent extends BaseSsoComponent {
|
|||||||
environmentService,
|
environmentService,
|
||||||
passwordGenerationService,
|
passwordGenerationService,
|
||||||
logService,
|
logService,
|
||||||
configService
|
configService,
|
||||||
);
|
);
|
||||||
|
|
||||||
const url = this.environmentService.getWebVaultUrl();
|
const url = this.environmentService.getWebVaultUrl();
|
||||||
|
@ -16,7 +16,7 @@ export class TwoFactorOptionsComponent extends BaseTwoFactorOptionsComponent {
|
|||||||
router: Router,
|
router: Router,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
private activatedRoute: ActivatedRoute
|
private activatedRoute: ActivatedRoute,
|
||||||
) {
|
) {
|
||||||
super(twoFactorService, router, i18nService, platformUtilsService, window);
|
super(twoFactorService, router, i18nService, platformUtilsService, window);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
{{ "enterVerificationCodeApp" | i18n }}
|
{{ "enterVerificationCodeApp" | i18n }}
|
||||||
</span>
|
</span>
|
||||||
<span *ngIf="selectedProviderType === providerType.Email">
|
<span *ngIf="selectedProviderType === providerType.Email">
|
||||||
{{ "enterVerificationCodeEmail" | i18n : twoFactorEmail }}
|
{{ "enterVerificationCodeEmail" | i18n: twoFactorEmail }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="box first">
|
<div class="box first">
|
||||||
|
@ -51,7 +51,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
|||||||
loginService: LoginService,
|
loginService: LoginService,
|
||||||
configService: ConfigServiceAbstraction,
|
configService: ConfigServiceAbstraction,
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
@Inject(WINDOW) protected win: Window
|
@Inject(WINDOW) protected win: Window,
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
authService,
|
authService,
|
||||||
@ -67,7 +67,7 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
|||||||
twoFactorService,
|
twoFactorService,
|
||||||
appIdService,
|
appIdService,
|
||||||
loginService,
|
loginService,
|
||||||
configService
|
configService,
|
||||||
);
|
);
|
||||||
super.onSuccessfulLogin = async () => {
|
super.onSuccessfulLogin = async () => {
|
||||||
syncService.fullSync(true);
|
syncService.fullSync(true);
|
||||||
|
@ -103,7 +103,7 @@ describe("AuthPopoutWindow", () => {
|
|||||||
|
|
||||||
expect(openPopoutSpy).toHaveBeenCalledWith(
|
expect(openPopoutSpy).toHaveBeenCalledWith(
|
||||||
"popup/index.html#/2fa;webAuthnResponse=data;remember=remember",
|
"popup/index.html#/2fa;webAuthnResponse=data;remember=remember",
|
||||||
{ singleActionKey: AuthPopoutType.twoFactorAuth }
|
{ singleActionKey: AuthPopoutType.twoFactorAuth },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -47,7 +47,7 @@ async function closeUnlockPopout() {
|
|||||||
async function openSsoAuthResultPopout(resultData: { code: string; state: string }) {
|
async function openSsoAuthResultPopout(resultData: { code: string; state: string }) {
|
||||||
const { code, state } = resultData;
|
const { code, state } = resultData;
|
||||||
const authResultUrl = `popup/index.html#/sso?code=${encodeURIComponent(
|
const authResultUrl = `popup/index.html#/sso?code=${encodeURIComponent(
|
||||||
code
|
code,
|
||||||
)}&state=${encodeURIComponent(state)}`;
|
)}&state=${encodeURIComponent(state)}`;
|
||||||
|
|
||||||
await BrowserPopupUtils.openPopout(authResultUrl, {
|
await BrowserPopupUtils.openPopout(authResultUrl, {
|
||||||
|
@ -15,14 +15,14 @@ export default class ContextMenusBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.contextMenus.onClicked.addListener((info, tab) =>
|
this.contextMenus.onClicked.addListener((info, tab) =>
|
||||||
this.contextMenuClickedHandler.run(info, tab)
|
this.contextMenuClickedHandler.run(info, tab),
|
||||||
);
|
);
|
||||||
|
|
||||||
BrowserApi.messageListener(
|
BrowserApi.messageListener(
|
||||||
"contextmenus.background",
|
"contextmenus.background",
|
||||||
(
|
(
|
||||||
msg: { command: string; data: LockedVaultPendingNotificationsItem },
|
msg: { command: string; data: LockedVaultPendingNotificationsItem },
|
||||||
sender: chrome.runtime.MessageSender
|
sender: chrome.runtime.MessageSender,
|
||||||
) => {
|
) => {
|
||||||
if (msg.command === "unlockCompleted" && msg.data.target === "contextmenus.background") {
|
if (msg.command === "unlockCompleted" && msg.data.target === "contextmenus.background") {
|
||||||
this.contextMenuClickedHandler
|
this.contextMenuClickedHandler
|
||||||
@ -31,7 +31,7 @@ export default class ContextMenusBackground {
|
|||||||
BrowserApi.tabSendMessageData(sender.tab, "closeNotificationBar");
|
BrowserApi.tabSendMessageData(sender.tab, "closeNotificationBar");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ describe("NotificationBackground", () => {
|
|||||||
policyService,
|
policyService,
|
||||||
folderService,
|
folderService,
|
||||||
stateService,
|
stateService,
|
||||||
environmentService
|
environmentService,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ export default class NotificationBackground {
|
|||||||
private policyService: PolicyService,
|
private policyService: PolicyService,
|
||||||
private folderService: FolderService,
|
private folderService: FolderService,
|
||||||
private stateService: BrowserStateService,
|
private stateService: BrowserStateService,
|
||||||
private environmentService: EnvironmentService
|
private environmentService: EnvironmentService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
@ -52,7 +52,7 @@ export default class NotificationBackground {
|
|||||||
"notification.background",
|
"notification.background",
|
||||||
(msg: any, sender: chrome.runtime.MessageSender) => {
|
(msg: any, sender: chrome.runtime.MessageSender) => {
|
||||||
this.processMessage(msg, sender);
|
this.processMessage(msg, sender);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.cleanupNotificationQueue();
|
this.cleanupNotificationQueue();
|
||||||
@ -97,7 +97,7 @@ export default class NotificationBackground {
|
|||||||
await BrowserApi.tabSendMessageData(
|
await BrowserApi.tabSendMessageData(
|
||||||
sender.tab,
|
sender.tab,
|
||||||
"addToLockedVaultPendingNotifications",
|
"addToLockedVaultPendingNotifications",
|
||||||
retryMessage
|
retryMessage,
|
||||||
);
|
);
|
||||||
await openUnlockPopout(sender.tab);
|
await openUnlockPopout(sender.tab);
|
||||||
return;
|
return;
|
||||||
@ -259,7 +259,7 @@ export default class NotificationBackground {
|
|||||||
|
|
||||||
const ciphers = await this.cipherService.getAllDecryptedForUrl(loginInfo.url);
|
const ciphers = await this.cipherService.getAllDecryptedForUrl(loginInfo.url);
|
||||||
const usernameMatches = ciphers.filter(
|
const usernameMatches = ciphers.filter(
|
||||||
(c) => c.login.username != null && c.login.username.toLowerCase() === normalizedUsername
|
(c) => c.login.username != null && c.login.username.toLowerCase() === normalizedUsername,
|
||||||
);
|
);
|
||||||
if (usernameMatches.length === 0) {
|
if (usernameMatches.length === 0) {
|
||||||
if (disabledAddLogin) {
|
if (disabledAddLogin) {
|
||||||
@ -284,7 +284,7 @@ export default class NotificationBackground {
|
|||||||
loginDomain: string,
|
loginDomain: string,
|
||||||
loginInfo: AddLoginRuntimeMessage,
|
loginInfo: AddLoginRuntimeMessage,
|
||||||
tab: chrome.tabs.Tab,
|
tab: chrome.tabs.Tab,
|
||||||
isVaultLocked = false
|
isVaultLocked = false,
|
||||||
) {
|
) {
|
||||||
// remove any old messages for this tab
|
// remove any old messages for this tab
|
||||||
this.removeTabFromNotificationQueue(tab);
|
this.removeTabFromNotificationQueue(tab);
|
||||||
@ -317,7 +317,7 @@ export default class NotificationBackground {
|
|||||||
const ciphers = await this.cipherService.getAllDecryptedForUrl(changeData.url);
|
const ciphers = await this.cipherService.getAllDecryptedForUrl(changeData.url);
|
||||||
if (changeData.currentPassword != null) {
|
if (changeData.currentPassword != null) {
|
||||||
const passwordMatches = ciphers.filter(
|
const passwordMatches = ciphers.filter(
|
||||||
(c) => c.login.password === changeData.currentPassword
|
(c) => c.login.password === changeData.currentPassword,
|
||||||
);
|
);
|
||||||
if (passwordMatches.length === 1) {
|
if (passwordMatches.length === 1) {
|
||||||
id = passwordMatches[0].id;
|
id = passwordMatches[0].id;
|
||||||
@ -339,7 +339,7 @@ export default class NotificationBackground {
|
|||||||
*/
|
*/
|
||||||
private async unlockVault(
|
private async unlockVault(
|
||||||
message: { data?: { skipNotification?: boolean } },
|
message: { data?: { skipNotification?: boolean } },
|
||||||
tab: chrome.tabs.Tab
|
tab: chrome.tabs.Tab,
|
||||||
) {
|
) {
|
||||||
if (message.data?.skipNotification) {
|
if (message.data?.skipNotification) {
|
||||||
return;
|
return;
|
||||||
@ -363,7 +363,7 @@ export default class NotificationBackground {
|
|||||||
loginDomain: string,
|
loginDomain: string,
|
||||||
newPassword: string,
|
newPassword: string,
|
||||||
tab: chrome.tabs.Tab,
|
tab: chrome.tabs.Tab,
|
||||||
isVaultLocked = false
|
isVaultLocked = false,
|
||||||
) {
|
) {
|
||||||
// remove any old messages for this tab
|
// remove any old messages for this tab
|
||||||
this.removeTabFromNotificationQueue(tab);
|
this.removeTabFromNotificationQueue(tab);
|
||||||
@ -421,7 +421,7 @@ export default class NotificationBackground {
|
|||||||
const allCiphers = await this.cipherService.getAllDecryptedForUrl(queueMessage.uri);
|
const allCiphers = await this.cipherService.getAllDecryptedForUrl(queueMessage.uri);
|
||||||
const existingCipher = allCiphers.find(
|
const existingCipher = allCiphers.find(
|
||||||
(c) =>
|
(c) =>
|
||||||
c.login.username != null && c.login.username.toLowerCase() === queueMessage.username
|
c.login.username != null && c.login.username.toLowerCase() === queueMessage.username,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (existingCipher != null) {
|
if (existingCipher != null) {
|
||||||
@ -449,7 +449,7 @@ export default class NotificationBackground {
|
|||||||
cipherView: CipherView,
|
cipherView: CipherView,
|
||||||
newPassword: string,
|
newPassword: string,
|
||||||
edit: boolean,
|
edit: boolean,
|
||||||
tab: chrome.tabs.Tab
|
tab: chrome.tabs.Tab,
|
||||||
) {
|
) {
|
||||||
cipherView.login.password = newPassword;
|
cipherView.login.password = newPassword;
|
||||||
|
|
||||||
@ -525,13 +525,13 @@ export default class NotificationBackground {
|
|||||||
|
|
||||||
private async removeIndividualVault(): Promise<boolean> {
|
private async removeIndividualVault(): Promise<boolean> {
|
||||||
return await firstValueFrom(
|
return await firstValueFrom(
|
||||||
this.policyService.policyAppliesToActiveUser$(PolicyType.PersonalOwnership)
|
this.policyService.policyAppliesToActiveUser$(PolicyType.PersonalOwnership),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleUnlockCompleted(
|
private async handleUnlockCompleted(
|
||||||
messageData: LockedVaultPendingNotificationsItem,
|
messageData: LockedVaultPendingNotificationsItem,
|
||||||
sender: chrome.runtime.MessageSender
|
sender: chrome.runtime.MessageSender,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (messageData.commandToRetry.msg.command === "autofill_login") {
|
if (messageData.commandToRetry.msg.command === "autofill_login") {
|
||||||
await BrowserApi.tabSendMessageData(sender.tab, "closeNotificationBar");
|
await BrowserApi.tabSendMessageData(sender.tab, "closeNotificationBar");
|
||||||
@ -543,7 +543,7 @@ export default class NotificationBackground {
|
|||||||
|
|
||||||
await this.processMessage(
|
await this.processMessage(
|
||||||
messageData.commandToRetry.msg.command,
|
messageData.commandToRetry.msg.command,
|
||||||
messageData.commandToRetry.sender
|
messageData.commandToRetry.sender,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ describe("OverlayBackground", () => {
|
|||||||
environmentService,
|
environmentService,
|
||||||
settingsService,
|
settingsService,
|
||||||
stateService,
|
stateService,
|
||||||
i18nService
|
i18nService,
|
||||||
);
|
);
|
||||||
overlayBackground.init();
|
overlayBackground.init();
|
||||||
});
|
});
|
||||||
@ -163,7 +163,7 @@ describe("OverlayBackground", () => {
|
|||||||
new Map([
|
new Map([
|
||||||
["overlay-cipher-0", cipher2],
|
["overlay-cipher-0", cipher2],
|
||||||
["overlay-cipher-1", cipher1],
|
["overlay-cipher-1", cipher1],
|
||||||
])
|
]),
|
||||||
);
|
);
|
||||||
expect(overlayBackground["getOverlayCipherData"]).toHaveBeenCalled();
|
expect(overlayBackground["getOverlayCipherData"]).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -219,7 +219,7 @@ describe("OverlayBackground", () => {
|
|||||||
expect(BrowserApi.tabSendMessageData).toHaveBeenCalledWith(
|
expect(BrowserApi.tabSendMessageData).toHaveBeenCalledWith(
|
||||||
tab,
|
tab,
|
||||||
"updateIsOverlayCiphersPopulated",
|
"updateIsOverlayCiphersPopulated",
|
||||||
{ isOverlayCiphersPopulated: true }
|
{ isOverlayCiphersPopulated: true },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -489,7 +489,7 @@ describe("OverlayBackground", () => {
|
|||||||
const returnValue = overlayBackground["handleExtensionMessage"](
|
const returnValue = overlayBackground["handleExtensionMessage"](
|
||||||
message,
|
message,
|
||||||
sender,
|
sender,
|
||||||
sendResponse
|
sendResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(returnValue).toBe(undefined);
|
expect(returnValue).toBe(undefined);
|
||||||
@ -507,7 +507,7 @@ describe("OverlayBackground", () => {
|
|||||||
const returnValue = overlayBackground["handleExtensionMessage"](
|
const returnValue = overlayBackground["handleExtensionMessage"](
|
||||||
message,
|
message,
|
||||||
sender,
|
sender,
|
||||||
sendResponse
|
sendResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(returnValue).toBe(undefined);
|
expect(returnValue).toBe(undefined);
|
||||||
@ -526,7 +526,7 @@ describe("OverlayBackground", () => {
|
|||||||
const returnValue = overlayBackground["handleExtensionMessage"](
|
const returnValue = overlayBackground["handleExtensionMessage"](
|
||||||
message,
|
message,
|
||||||
sender,
|
sender,
|
||||||
sendResponse
|
sendResponse,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(returnValue).toBe(true);
|
expect(returnValue).toBe(true);
|
||||||
@ -555,7 +555,7 @@ describe("OverlayBackground", () => {
|
|||||||
isFocusingFieldElement: false,
|
isFocusingFieldElement: false,
|
||||||
isOpeningFullOverlay: false,
|
isOpeningFullOverlay: false,
|
||||||
authStatus: AuthenticationStatus.Unlocked,
|
authStatus: AuthenticationStatus.Unlocked,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -614,7 +614,7 @@ describe("OverlayBackground", () => {
|
|||||||
password: "password",
|
password: "password",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sender
|
sender,
|
||||||
);
|
);
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
@ -635,7 +635,7 @@ describe("OverlayBackground", () => {
|
|||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(overlayBackground["overlayVisibility"]).toBe(
|
expect(overlayBackground["overlayVisibility"]).toBe(
|
||||||
AutofillOverlayVisibility.OnFieldFocus
|
AutofillOverlayVisibility.OnFieldFocus,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ describe("OverlayBackground", () => {
|
|||||||
sendExtensionRuntimeMessage(
|
sendExtensionRuntimeMessage(
|
||||||
{ command: "getAutofillOverlayVisibility" },
|
{ command: "getAutofillOverlayVisibility" },
|
||||||
undefined,
|
undefined,
|
||||||
sendMessageSpy
|
sendMessageSpy,
|
||||||
);
|
);
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
@ -851,7 +851,7 @@ describe("OverlayBackground", () => {
|
|||||||
it("stores the page details provided by the message by the tab id of the sender", () => {
|
it("stores the page details provided by the message by the tab id of the sender", () => {
|
||||||
sendExtensionRuntimeMessage(
|
sendExtensionRuntimeMessage(
|
||||||
{ command: "collectPageDetailsResponse", details: pageDetails1 },
|
{ command: "collectPageDetailsResponse", details: pageDetails1 },
|
||||||
sender
|
sender,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(overlayBackground["pageDetailsForTab"][sender.tab.id]).toStrictEqual([
|
expect(overlayBackground["pageDetailsForTab"][sender.tab.id]).toStrictEqual([
|
||||||
@ -870,7 +870,7 @@ describe("OverlayBackground", () => {
|
|||||||
|
|
||||||
sendExtensionRuntimeMessage(
|
sendExtensionRuntimeMessage(
|
||||||
{ command: "collectPageDetailsResponse", details: pageDetails2 },
|
{ command: "collectPageDetailsResponse", details: pageDetails2 },
|
||||||
sender
|
sender,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(overlayBackground["pageDetailsForTab"][sender.tab.id]).toStrictEqual([
|
expect(overlayBackground["pageDetailsForTab"][sender.tab.id]).toStrictEqual([
|
||||||
@ -930,7 +930,7 @@ describe("OverlayBackground", () => {
|
|||||||
isFocusingFieldElement: true,
|
isFocusingFieldElement: true,
|
||||||
isOpeningFullOverlay: false,
|
isOpeningFullOverlay: false,
|
||||||
authStatus: AuthenticationStatus.Unlocked,
|
authStatus: AuthenticationStatus.Unlocked,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1096,7 +1096,7 @@ describe("OverlayBackground", () => {
|
|||||||
expect(BrowserApi.tabSendMessageData).toHaveBeenCalledWith(
|
expect(BrowserApi.tabSendMessageData).toHaveBeenCalledWith(
|
||||||
buttonPortSpy.sender.tab,
|
buttonPortSpy.sender.tab,
|
||||||
"redirectOverlayFocusOut",
|
"redirectOverlayFocusOut",
|
||||||
{ direction: RedirectFocusDirection.Next }
|
{ direction: RedirectFocusDirection.Next },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1142,11 +1142,11 @@ describe("OverlayBackground", () => {
|
|||||||
sender: listPortSpy.sender,
|
sender: listPortSpy.sender,
|
||||||
},
|
},
|
||||||
target: "overlay.background",
|
target: "overlay.background",
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
expect(overlayBackground["openUnlockPopout"]).toHaveBeenCalledWith(
|
expect(overlayBackground["openUnlockPopout"]).toHaveBeenCalledWith(
|
||||||
listPortSpy.sender.tab,
|
listPortSpy.sender.tab,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1160,7 +1160,7 @@ describe("OverlayBackground", () => {
|
|||||||
getLoginCiphersSpy = jest.spyOn(overlayBackground["overlayLoginCiphers"], "get");
|
getLoginCiphersSpy = jest.spyOn(overlayBackground["overlayLoginCiphers"], "get");
|
||||||
isPasswordRepromptRequiredSpy = jest.spyOn(
|
isPasswordRepromptRequiredSpy = jest.spyOn(
|
||||||
overlayBackground["autofillService"],
|
overlayBackground["autofillService"],
|
||||||
"isPasswordRepromptRequired"
|
"isPasswordRepromptRequired",
|
||||||
);
|
);
|
||||||
doAutoFillSpy = jest.spyOn(overlayBackground["autofillService"], "doAutoFill");
|
doAutoFillSpy = jest.spyOn(overlayBackground["autofillService"], "doAutoFill");
|
||||||
});
|
});
|
||||||
@ -1192,7 +1192,7 @@ describe("OverlayBackground", () => {
|
|||||||
expect(getLoginCiphersSpy).toHaveBeenCalled();
|
expect(getLoginCiphersSpy).toHaveBeenCalled();
|
||||||
expect(isPasswordRepromptRequiredSpy).toHaveBeenCalledWith(
|
expect(isPasswordRepromptRequiredSpy).toHaveBeenCalledWith(
|
||||||
cipher,
|
cipher,
|
||||||
listPortSpy.sender.tab
|
listPortSpy.sender.tab,
|
||||||
);
|
);
|
||||||
expect(doAutoFillSpy).not.toHaveBeenCalled();
|
expect(doAutoFillSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -1216,7 +1216,7 @@ describe("OverlayBackground", () => {
|
|||||||
|
|
||||||
expect(isPasswordRepromptRequiredSpy).toHaveBeenCalledWith(
|
expect(isPasswordRepromptRequiredSpy).toHaveBeenCalledWith(
|
||||||
cipher2,
|
cipher2,
|
||||||
listPortSpy.sender.tab
|
listPortSpy.sender.tab,
|
||||||
);
|
);
|
||||||
expect(doAutoFillSpy).toHaveBeenCalledWith({
|
expect(doAutoFillSpy).toHaveBeenCalledWith({
|
||||||
tab: listPortSpy.sender.tab,
|
tab: listPortSpy.sender.tab,
|
||||||
@ -1230,7 +1230,7 @@ describe("OverlayBackground", () => {
|
|||||||
["overlay-cipher-2", cipher2],
|
["overlay-cipher-2", cipher2],
|
||||||
["overlay-cipher-1", cipher1],
|
["overlay-cipher-1", cipher1],
|
||||||
["overlay-cipher-3", cipher3],
|
["overlay-cipher-3", cipher3],
|
||||||
]).entries()
|
]).entries(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1289,7 +1289,7 @@ describe("OverlayBackground", () => {
|
|||||||
{
|
{
|
||||||
cipherId: cipher.id,
|
cipherId: cipher.id,
|
||||||
action: SHOW_AUTOFILL_BUTTON,
|
action: SHOW_AUTOFILL_BUTTON,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1302,7 +1302,7 @@ describe("OverlayBackground", () => {
|
|||||||
};
|
};
|
||||||
const redirectOverlayFocusOutSpy = jest.spyOn(
|
const redirectOverlayFocusOutSpy = jest.spyOn(
|
||||||
overlayBackground as any,
|
overlayBackground as any,
|
||||||
"redirectOverlayFocusOut"
|
"redirectOverlayFocusOut",
|
||||||
);
|
);
|
||||||
|
|
||||||
sendPortMessage(listPortSpy, message);
|
sendPortMessage(listPortSpy, message);
|
||||||
|
@ -88,7 +88,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private settingsService: SettingsService,
|
private settingsService: SettingsService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private i18nService: I18nService
|
private i18nService: I18nService,
|
||||||
) {
|
) {
|
||||||
this.iconsServerUrl = this.environmentService.getIconsUrl();
|
this.iconsServerUrl = this.environmentService.getIconsUrl();
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
|
|
||||||
this.overlayLoginCiphers = new Map();
|
this.overlayLoginCiphers = new Map();
|
||||||
const ciphersViews = (await this.cipherService.getAllDecryptedForUrl(currentTab.url)).sort(
|
const ciphersViews = (await this.cipherService.getAllDecryptedForUrl(currentTab.url)).sort(
|
||||||
(a, b) => this.cipherService.sortCiphersByLastUsedThenName(a, b)
|
(a, b) => this.cipherService.sortCiphersByLastUsedThenName(a, b),
|
||||||
);
|
);
|
||||||
for (let cipherIndex = 0; cipherIndex < ciphersViews.length; cipherIndex++) {
|
for (let cipherIndex = 0; cipherIndex < ciphersViews.length; cipherIndex++) {
|
||||||
this.overlayLoginCiphers.set(`overlay-cipher-${cipherIndex}`, ciphersViews[cipherIndex]);
|
this.overlayLoginCiphers.set(`overlay-cipher-${cipherIndex}`, ciphersViews[cipherIndex]);
|
||||||
@ -189,7 +189,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*/
|
*/
|
||||||
private storePageDetails(
|
private storePageDetails(
|
||||||
message: OverlayBackgroundExtensionMessage,
|
message: OverlayBackgroundExtensionMessage,
|
||||||
sender: chrome.runtime.MessageSender
|
sender: chrome.runtime.MessageSender,
|
||||||
) {
|
) {
|
||||||
const pageDetails = {
|
const pageDetails = {
|
||||||
frameId: sender.frameId,
|
frameId: sender.frameId,
|
||||||
@ -214,7 +214,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*/
|
*/
|
||||||
private async fillSelectedOverlayListItem(
|
private async fillSelectedOverlayListItem(
|
||||||
{ overlayCipherId }: OverlayPortMessage,
|
{ overlayCipherId }: OverlayPortMessage,
|
||||||
{ sender }: chrome.runtime.Port
|
{ sender }: chrome.runtime.Port,
|
||||||
) {
|
) {
|
||||||
if (!overlayCipherId) {
|
if (!overlayCipherId) {
|
||||||
return;
|
return;
|
||||||
@ -528,7 +528,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
await BrowserApi.tabSendMessageData(
|
await BrowserApi.tabSendMessageData(
|
||||||
sender.tab,
|
sender.tab,
|
||||||
"addToLockedVaultPendingNotifications",
|
"addToLockedVaultPendingNotifications",
|
||||||
retryMessage
|
retryMessage,
|
||||||
);
|
);
|
||||||
await this.openUnlockPopout(sender.tab, true);
|
await this.openUnlockPopout(sender.tab, true);
|
||||||
}
|
}
|
||||||
@ -541,7 +541,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*/
|
*/
|
||||||
private async viewSelectedCipher(
|
private async viewSelectedCipher(
|
||||||
{ overlayCipherId }: OverlayPortMessage,
|
{ overlayCipherId }: OverlayPortMessage,
|
||||||
{ sender }: chrome.runtime.Port
|
{ sender }: chrome.runtime.Port,
|
||||||
) {
|
) {
|
||||||
const cipher = this.overlayLoginCiphers.get(overlayCipherId);
|
const cipher = this.overlayLoginCiphers.get(overlayCipherId);
|
||||||
if (!cipher) {
|
if (!cipher) {
|
||||||
@ -609,7 +609,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*/
|
*/
|
||||||
private redirectOverlayFocusOut(
|
private redirectOverlayFocusOut(
|
||||||
{ direction }: OverlayPortMessage,
|
{ direction }: OverlayPortMessage,
|
||||||
{ sender }: chrome.runtime.Port
|
{ sender }: chrome.runtime.Port,
|
||||||
) {
|
) {
|
||||||
if (!direction) {
|
if (!direction) {
|
||||||
return;
|
return;
|
||||||
@ -637,7 +637,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*/
|
*/
|
||||||
private async addNewVaultItem(
|
private async addNewVaultItem(
|
||||||
{ login }: OverlayAddNewItemMessage,
|
{ login }: OverlayAddNewItemMessage,
|
||||||
sender: chrome.runtime.MessageSender
|
sender: chrome.runtime.MessageSender,
|
||||||
) {
|
) {
|
||||||
if (!login) {
|
if (!login) {
|
||||||
return;
|
return;
|
||||||
@ -683,7 +683,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
private handleExtensionMessage = (
|
private handleExtensionMessage = (
|
||||||
message: OverlayBackgroundExtensionMessage,
|
message: OverlayBackgroundExtensionMessage,
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
sendResponse: (response?: any) => void
|
sendResponse: (response?: any) => void,
|
||||||
) => {
|
) => {
|
||||||
const handler: CallableFunction | undefined = this.extensionMessageHandlers[message?.command];
|
const handler: CallableFunction | undefined = this.extensionMessageHandlers[message?.command];
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
@ -742,7 +742,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*/
|
*/
|
||||||
private handleOverlayElementPortMessage = (
|
private handleOverlayElementPortMessage = (
|
||||||
message: OverlayBackgroundExtensionMessage,
|
message: OverlayBackgroundExtensionMessage,
|
||||||
port: chrome.runtime.Port
|
port: chrome.runtime.Port,
|
||||||
) => {
|
) => {
|
||||||
const command = message?.command;
|
const command = message?.command;
|
||||||
let handler: CallableFunction | undefined;
|
let handler: CallableFunction | undefined;
|
||||||
|
@ -47,7 +47,7 @@ export type AutoFillServiceInitOptions = AutoFillServiceOptions &
|
|||||||
|
|
||||||
export function autofillServiceFactory(
|
export function autofillServiceFactory(
|
||||||
cache: { autofillService?: AbstractAutoFillService } & CachedServices,
|
cache: { autofillService?: AbstractAutoFillService } & CachedServices,
|
||||||
opts: AutoFillServiceInitOptions
|
opts: AutoFillServiceInitOptions,
|
||||||
): Promise<AbstractAutoFillService> {
|
): Promise<AbstractAutoFillService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -61,7 +61,7 @@ export function autofillServiceFactory(
|
|||||||
await eventCollectionServiceFactory(cache, opts),
|
await eventCollectionServiceFactory(cache, opts),
|
||||||
await logServiceFactory(cache, opts),
|
await logServiceFactory(cache, opts),
|
||||||
await settingsServiceFactory(cache, opts),
|
await settingsServiceFactory(cache, opts),
|
||||||
await userVerificationServiceFactory(cache, opts)
|
await userVerificationServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,13 @@ describe("TabsBackground", () => {
|
|||||||
it("sets up a window on focusChanged listener", () => {
|
it("sets up a window on focusChanged listener", () => {
|
||||||
const handleWindowOnFocusChangedSpy = jest.spyOn(
|
const handleWindowOnFocusChangedSpy = jest.spyOn(
|
||||||
tabsBackgorund as any,
|
tabsBackgorund as any,
|
||||||
"handleWindowOnFocusChanged"
|
"handleWindowOnFocusChanged",
|
||||||
);
|
);
|
||||||
|
|
||||||
tabsBackgorund.init();
|
tabsBackgorund.init();
|
||||||
|
|
||||||
expect(chrome.windows.onFocusChanged.addListener).toHaveBeenCalledWith(
|
expect(chrome.windows.onFocusChanged.addListener).toHaveBeenCalledWith(
|
||||||
handleWindowOnFocusChangedSpy
|
handleWindowOnFocusChangedSpy,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ export default class TabsBackground {
|
|||||||
constructor(
|
constructor(
|
||||||
private main: MainBackground,
|
private main: MainBackground,
|
||||||
private notificationBackground: NotificationBackground,
|
private notificationBackground: NotificationBackground,
|
||||||
private overlayBackground: OverlayBackground
|
private overlayBackground: OverlayBackground,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private focusedWindowId: number;
|
private focusedWindowId: number;
|
||||||
@ -74,7 +74,7 @@ export default class TabsBackground {
|
|||||||
private handleTabOnUpdated = async (
|
private handleTabOnUpdated = async (
|
||||||
tabId: number,
|
tabId: number,
|
||||||
changeInfo: chrome.tabs.TabChangeInfo,
|
changeInfo: chrome.tabs.TabChangeInfo,
|
||||||
tab: chrome.tabs.Tab
|
tab: chrome.tabs.Tab,
|
||||||
) => {
|
) => {
|
||||||
const removePageDetailsStatus = new Set(["loading", "unloaded"]);
|
const removePageDetailsStatus = new Set(["loading", "unloaded"]);
|
||||||
if (removePageDetailsStatus.has(changeInfo.status)) {
|
if (removePageDetailsStatus.has(changeInfo.status)) {
|
||||||
|
@ -120,19 +120,19 @@ describe("CipherContextMenuHandler", () => {
|
|||||||
expect(mainContextMenuHandler.loadOptions).toHaveBeenCalledWith(
|
expect(mainContextMenuHandler.loadOptions).toHaveBeenCalledWith(
|
||||||
"Test Cipher (Test Username)",
|
"Test Cipher (Test Username)",
|
||||||
"5",
|
"5",
|
||||||
loginCipher
|
loginCipher,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mainContextMenuHandler.loadOptions).toHaveBeenCalledWith(
|
expect(mainContextMenuHandler.loadOptions).toHaveBeenCalledWith(
|
||||||
"Test Reprompt Cipher (Test Username)",
|
"Test Reprompt Cipher (Test Username)",
|
||||||
"6",
|
"6",
|
||||||
repromptLoginCipher
|
repromptLoginCipher,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mainContextMenuHandler.loadOptions).toHaveBeenCalledWith(
|
expect(mainContextMenuHandler.loadOptions).toHaveBeenCalledWith(
|
||||||
"Test Card Cipher",
|
"Test Card Cipher",
|
||||||
"7",
|
"7",
|
||||||
cardCipher
|
cardCipher,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -38,7 +38,7 @@ export class CipherContextMenuHandler {
|
|||||||
constructor(
|
constructor(
|
||||||
private mainContextMenuHandler: MainContextMenuHandler,
|
private mainContextMenuHandler: MainContextMenuHandler,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private cipherService: CipherService
|
private cipherService: CipherService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
static async create(cachedServices: CachedServices) {
|
static async create(cachedServices: CachedServices) {
|
||||||
@ -74,7 +74,7 @@ export class CipherContextMenuHandler {
|
|||||||
return new CipherContextMenuHandler(
|
return new CipherContextMenuHandler(
|
||||||
await MainContextMenuHandler.mv3Create(cachedServices),
|
await MainContextMenuHandler.mv3Create(cachedServices),
|
||||||
await authServiceFactory(cachedServices, serviceOptions),
|
await authServiceFactory(cachedServices, serviceOptions),
|
||||||
await cipherServiceFactory(cachedServices, serviceOptions)
|
await cipherServiceFactory(cachedServices, serviceOptions),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ export class CipherContextMenuHandler {
|
|||||||
|
|
||||||
static async tabsOnActivatedListener(
|
static async tabsOnActivatedListener(
|
||||||
activeInfo: chrome.tabs.TabActiveInfo,
|
activeInfo: chrome.tabs.TabActiveInfo,
|
||||||
serviceCache: CachedServices
|
serviceCache: CachedServices,
|
||||||
) {
|
) {
|
||||||
const cipherContextMenuHandler = await CipherContextMenuHandler.create(serviceCache);
|
const cipherContextMenuHandler = await CipherContextMenuHandler.create(serviceCache);
|
||||||
const tab = await BrowserApi.getTab(activeInfo.tabId);
|
const tab = await BrowserApi.getTab(activeInfo.tabId);
|
||||||
@ -96,7 +96,7 @@ export class CipherContextMenuHandler {
|
|||||||
static async tabsOnReplacedListener(
|
static async tabsOnReplacedListener(
|
||||||
addedTabId: number,
|
addedTabId: number,
|
||||||
removedTabId: number,
|
removedTabId: number,
|
||||||
serviceCache: CachedServices
|
serviceCache: CachedServices,
|
||||||
) {
|
) {
|
||||||
const cipherContextMenuHandler = await CipherContextMenuHandler.create(serviceCache);
|
const cipherContextMenuHandler = await CipherContextMenuHandler.create(serviceCache);
|
||||||
const tab = await BrowserApi.getTab(addedTabId);
|
const tab = await BrowserApi.getTab(addedTabId);
|
||||||
@ -107,7 +107,7 @@ export class CipherContextMenuHandler {
|
|||||||
tabId: number,
|
tabId: number,
|
||||||
changeInfo: chrome.tabs.TabChangeInfo,
|
changeInfo: chrome.tabs.TabChangeInfo,
|
||||||
tab: chrome.tabs.Tab,
|
tab: chrome.tabs.Tab,
|
||||||
serviceCache: CachedServices
|
serviceCache: CachedServices,
|
||||||
) {
|
) {
|
||||||
if (changeInfo.status !== "complete") {
|
if (changeInfo.status !== "complete") {
|
||||||
return;
|
return;
|
||||||
@ -119,7 +119,7 @@ export class CipherContextMenuHandler {
|
|||||||
static async messageListener(
|
static async messageListener(
|
||||||
message: { command: string },
|
message: { command: string },
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
cachedServices: CachedServices
|
cachedServices: CachedServices,
|
||||||
) {
|
) {
|
||||||
if (!CipherContextMenuHandler.shouldListen(message)) {
|
if (!CipherContextMenuHandler.shouldListen(message)) {
|
||||||
return;
|
return;
|
||||||
@ -183,7 +183,7 @@ export class CipherContextMenuHandler {
|
|||||||
[CipherType.Login]: [],
|
[CipherType.Login]: [],
|
||||||
[CipherType.Card]: [],
|
[CipherType.Card]: [],
|
||||||
[CipherType.Identity]: [],
|
[CipherType.Identity]: [],
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (groupedCiphers[CipherType.Login].length === 0) {
|
if (groupedCiphers[CipherType.Login].length === 0) {
|
||||||
|
@ -31,7 +31,7 @@ import {
|
|||||||
describe("ContextMenuClickedHandler", () => {
|
describe("ContextMenuClickedHandler", () => {
|
||||||
const createData = (
|
const createData = (
|
||||||
menuItemId: chrome.contextMenus.OnClickData["menuItemId"],
|
menuItemId: chrome.contextMenus.OnClickData["menuItemId"],
|
||||||
parentMenuItemId?: chrome.contextMenus.OnClickData["parentMenuItemId"]
|
parentMenuItemId?: chrome.contextMenus.OnClickData["parentMenuItemId"],
|
||||||
): chrome.contextMenus.OnClickData => {
|
): chrome.contextMenus.OnClickData => {
|
||||||
return {
|
return {
|
||||||
menuItemId: menuItemId,
|
menuItemId: menuItemId,
|
||||||
@ -52,7 +52,7 @@ describe("ContextMenuClickedHandler", () => {
|
|||||||
new Cipher({
|
new Cipher({
|
||||||
id: id ?? "1",
|
id: id ?? "1",
|
||||||
type: CipherType.Login,
|
type: CipherType.Login,
|
||||||
} as any)
|
} as any),
|
||||||
);
|
);
|
||||||
|
|
||||||
cipherView.login.username = username ?? "USERNAME";
|
cipherView.login.username = username ?? "USERNAME";
|
||||||
@ -92,7 +92,7 @@ describe("ContextMenuClickedHandler", () => {
|
|||||||
stateService,
|
stateService,
|
||||||
totpService,
|
totpService,
|
||||||
eventCollectionService,
|
eventCollectionService,
|
||||||
userVerificationService
|
userVerificationService,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ export class ContextMenuClickedHandler {
|
|||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private totpService: TotpService,
|
private totpService: TotpService,
|
||||||
private eventCollectionService: EventCollectionService,
|
private eventCollectionService: EventCollectionService,
|
||||||
private userVerificationService: UserVerificationService
|
private userVerificationService: UserVerificationService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
static async mv3Create(cachedServices: CachedServices) {
|
static async mv3Create(cachedServices: CachedServices) {
|
||||||
@ -108,11 +108,11 @@ export class ContextMenuClickedHandler {
|
|||||||
|
|
||||||
const generatePasswordToClipboardCommand = new GeneratePasswordToClipboardCommand(
|
const generatePasswordToClipboardCommand = new GeneratePasswordToClipboardCommand(
|
||||||
await passwordGenerationServiceFactory(cachedServices, serviceOptions),
|
await passwordGenerationServiceFactory(cachedServices, serviceOptions),
|
||||||
await stateServiceFactory(cachedServices, serviceOptions)
|
await stateServiceFactory(cachedServices, serviceOptions),
|
||||||
);
|
);
|
||||||
|
|
||||||
const autofillCommand = new AutofillTabCommand(
|
const autofillCommand = new AutofillTabCommand(
|
||||||
await autofillServiceFactory(cachedServices, serviceOptions)
|
await autofillServiceFactory(cachedServices, serviceOptions),
|
||||||
);
|
);
|
||||||
|
|
||||||
return new ContextMenuClickedHandler(
|
return new ContextMenuClickedHandler(
|
||||||
@ -124,14 +124,14 @@ export class ContextMenuClickedHandler {
|
|||||||
await stateServiceFactory(cachedServices, serviceOptions),
|
await stateServiceFactory(cachedServices, serviceOptions),
|
||||||
await totpServiceFactory(cachedServices, serviceOptions),
|
await totpServiceFactory(cachedServices, serviceOptions),
|
||||||
await eventCollectionServiceFactory(cachedServices, serviceOptions),
|
await eventCollectionServiceFactory(cachedServices, serviceOptions),
|
||||||
await userVerificationServiceFactory(cachedServices, serviceOptions)
|
await userVerificationServiceFactory(cachedServices, serviceOptions),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async onClickedListener(
|
static async onClickedListener(
|
||||||
info: chrome.contextMenus.OnClickData,
|
info: chrome.contextMenus.OnClickData,
|
||||||
tab?: chrome.tabs.Tab,
|
tab?: chrome.tabs.Tab,
|
||||||
cachedServices: CachedServices = {}
|
cachedServices: CachedServices = {},
|
||||||
) {
|
) {
|
||||||
const contextMenuClickedHandler = await ContextMenuClickedHandler.mv3Create(cachedServices);
|
const contextMenuClickedHandler = await ContextMenuClickedHandler.mv3Create(cachedServices);
|
||||||
await contextMenuClickedHandler.run(info, tab);
|
await contextMenuClickedHandler.run(info, tab);
|
||||||
@ -140,7 +140,7 @@ export class ContextMenuClickedHandler {
|
|||||||
static async messageListener(
|
static async messageListener(
|
||||||
message: { command: string; data: LockedVaultPendingNotificationsItem },
|
message: { command: string; data: LockedVaultPendingNotificationsItem },
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
cachedServices: CachedServices
|
cachedServices: CachedServices,
|
||||||
) {
|
) {
|
||||||
if (
|
if (
|
||||||
message.command !== "unlockCompleted" ||
|
message.command !== "unlockCompleted" ||
|
||||||
@ -152,7 +152,7 @@ export class ContextMenuClickedHandler {
|
|||||||
const contextMenuClickedHandler = await ContextMenuClickedHandler.mv3Create(cachedServices);
|
const contextMenuClickedHandler = await ContextMenuClickedHandler.mv3Create(cachedServices);
|
||||||
await contextMenuClickedHandler.run(
|
await contextMenuClickedHandler.run(
|
||||||
message.data.commandToRetry.msg.data,
|
message.data.commandToRetry.msg.data,
|
||||||
message.data.commandToRetry.sender.tab
|
message.data.commandToRetry.sender.tab,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ export class ContextMenuClickedHandler {
|
|||||||
await BrowserApi.tabSendMessageData(
|
await BrowserApi.tabSendMessageData(
|
||||||
tab,
|
tab,
|
||||||
"addToLockedVaultPendingNotifications",
|
"addToLockedVaultPendingNotifications",
|
||||||
retryMessage
|
retryMessage,
|
||||||
);
|
);
|
||||||
|
|
||||||
await openUnlockPopout(tab);
|
await openUnlockPopout(tab);
|
||||||
@ -201,7 +201,7 @@ export class ContextMenuClickedHandler {
|
|||||||
const menuItemId = (info.menuItemId as string).split("_")[1]; // We create all the ids, we can guarantee they are strings
|
const menuItemId = (info.menuItemId as string).split("_")[1]; // We create all the ids, we can guarantee they are strings
|
||||||
let cipher: CipherView | undefined;
|
let cipher: CipherView | undefined;
|
||||||
const isCreateCipherAction = [CREATE_LOGIN_ID, CREATE_IDENTITY_ID, CREATE_CARD_ID].includes(
|
const isCreateCipherAction = [CREATE_LOGIN_ID, CREATE_IDENTITY_ID, CREATE_CARD_ID].includes(
|
||||||
menuItemId as string
|
menuItemId as string,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isCreateCipherAction) {
|
if (isCreateCipherAction) {
|
||||||
@ -211,15 +211,15 @@ export class ContextMenuClickedHandler {
|
|||||||
info.parentMenuItemId === AUTOFILL_IDENTITY_ID
|
info.parentMenuItemId === AUTOFILL_IDENTITY_ID
|
||||||
? [CipherType.Identity]
|
? [CipherType.Identity]
|
||||||
: info.parentMenuItemId === AUTOFILL_CARD_ID
|
: info.parentMenuItemId === AUTOFILL_CARD_ID
|
||||||
? [CipherType.Card]
|
? [CipherType.Card]
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
// This NOOP item has come through which is generally only for no access state but since we got here
|
// This NOOP item has come through which is generally only for no access state but since we got here
|
||||||
// we are actually unlocked we will do our best to find a good match of an item to autofill this is useful
|
// we are actually unlocked we will do our best to find a good match of an item to autofill this is useful
|
||||||
// in scenarios like unlock on autofill
|
// in scenarios like unlock on autofill
|
||||||
const ciphers = await this.cipherService.getAllDecryptedForUrl(
|
const ciphers = await this.cipherService.getAllDecryptedForUrl(
|
||||||
tab.url,
|
tab.url,
|
||||||
additionalCiphersToGet
|
additionalCiphersToGet,
|
||||||
);
|
);
|
||||||
|
|
||||||
cipher = ciphers[0];
|
cipher = ciphers[0];
|
||||||
@ -314,10 +314,10 @@ export class ContextMenuClickedHandler {
|
|||||||
return menuItemId === CREATE_IDENTITY_ID
|
return menuItemId === CREATE_IDENTITY_ID
|
||||||
? CipherType.Identity
|
? CipherType.Identity
|
||||||
: menuItemId === CREATE_CARD_ID
|
: menuItemId === CREATE_CARD_ID
|
||||||
? CipherType.Card
|
? CipherType.Card
|
||||||
: menuItemId === CREATE_LOGIN_ID
|
: menuItemId === CREATE_LOGIN_ID
|
||||||
? CipherType.Login
|
? CipherType.Login
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getIdentifier(tab: chrome.tabs.Tab, info: chrome.contextMenus.OnClickData) {
|
private async getIdentifier(tab: chrome.tabs.Tab, info: chrome.contextMenus.OnClickData) {
|
||||||
@ -333,7 +333,7 @@ export class ContextMenuClickedHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resolve(identifier);
|
resolve(identifier);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ describe("context-menu", () => {
|
|||||||
id: id ?? "1",
|
id: id ?? "1",
|
||||||
type: CipherType.Login,
|
type: CipherType.Login,
|
||||||
viewPassword: viewPassword ?? true,
|
viewPassword: viewPassword ?? true,
|
||||||
} as any)
|
} as any),
|
||||||
);
|
);
|
||||||
cipherView.login.username = username ?? "USERNAME";
|
cipherView.login.username = username ?? "USERNAME";
|
||||||
cipherView.login.password = password ?? "PASSWORD";
|
cipherView.login.password = password ?? "PASSWORD";
|
||||||
@ -113,7 +113,7 @@ describe("context-menu", () => {
|
|||||||
username: "",
|
username: "",
|
||||||
totp: "",
|
totp: "",
|
||||||
viewPassword: false,
|
viewPassword: false,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(createSpy).toHaveBeenCalledTimes(1);
|
expect(createSpy).toHaveBeenCalledTimes(1);
|
||||||
|
@ -46,7 +46,7 @@ export class MainContextMenuHandler {
|
|||||||
constructor(
|
constructor(
|
||||||
private stateService: BrowserStateService,
|
private stateService: BrowserStateService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private logService: LogService
|
private logService: LogService,
|
||||||
) {
|
) {
|
||||||
if (chrome.contextMenus) {
|
if (chrome.contextMenus) {
|
||||||
this.create = (options) => {
|
this.create = (options) => {
|
||||||
@ -89,7 +89,7 @@ export class MainContextMenuHandler {
|
|||||||
return new MainContextMenuHandler(
|
return new MainContextMenuHandler(
|
||||||
await stateServiceFactory(cachedServices, serviceOptions),
|
await stateServiceFactory(cachedServices, serviceOptions),
|
||||||
await i18nServiceFactory(cachedServices, serviceOptions),
|
await i18nServiceFactory(cachedServices, serviceOptions),
|
||||||
await logServiceFactory(cachedServices, serviceOptions)
|
await logServiceFactory(cachedServices, serviceOptions),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ export class MainContextMenuHandler {
|
|||||||
const authed = await this.stateService.getIsAuthenticated();
|
const authed = await this.stateService.getIsAuthenticated();
|
||||||
await this.loadOptions(
|
await this.loadOptions(
|
||||||
this.i18nService.t(authed ? "unlockVaultMenu" : "loginToVaultMenu"),
|
this.i18nService.t(authed ? "unlockVaultMenu" : "loginToVaultMenu"),
|
||||||
NOOP_COMMAND_SUFFIX
|
NOOP_COMMAND_SUFFIX,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import { copyToClipboard } from "./copy-to-clipboard-command";
|
|||||||
export class GeneratePasswordToClipboardCommand {
|
export class GeneratePasswordToClipboardCommand {
|
||||||
constructor(
|
constructor(
|
||||||
private passwordGenerationService: PasswordGenerationServiceAbstraction,
|
private passwordGenerationService: PasswordGenerationServiceAbstraction,
|
||||||
private stateService: BrowserStateService
|
private stateService: BrowserStateService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async generatePasswordToClipboard(tab: chrome.tabs.Tab) {
|
async generatePasswordToClipboard(tab: chrome.tabs.Tab) {
|
||||||
|
@ -21,7 +21,7 @@ export class AutofillTabCommand {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
tab,
|
tab,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ export class AutofillTabCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resolve(response);
|
resolve(response);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ describe("AutofillInit", () => {
|
|||||||
autofillInit["setupExtensionMessageListeners"]();
|
autofillInit["setupExtensionMessageListeners"]();
|
||||||
|
|
||||||
expect(chrome.runtime.onMessage.addListener).toHaveBeenCalledWith(
|
expect(chrome.runtime.onMessage.addListener).toHaveBeenCalledWith(
|
||||||
autofillInit["handleExtensionMessage"]
|
autofillInit["handleExtensionMessage"],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -157,7 +157,7 @@ describe("AutofillInit", () => {
|
|||||||
sendExtensionRuntimeMessage(
|
sendExtensionRuntimeMessage(
|
||||||
{ command: "collectPageDetailsImmediately" },
|
{ command: "collectPageDetailsImmediately" },
|
||||||
sender,
|
sender,
|
||||||
sendResponse
|
sendResponse,
|
||||||
);
|
);
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ describe("AutofillInit", () => {
|
|||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(autofillInit["insertAutofillContentService"].fillForm).not.toHaveBeenCalledWith(
|
expect(autofillInit["insertAutofillContentService"].fillForm).not.toHaveBeenCalledWith(
|
||||||
fillScript
|
fillScript,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ describe("AutofillInit", () => {
|
|||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(autofillInit["insertAutofillContentService"].fillForm).toHaveBeenCalledWith(
|
expect(autofillInit["insertAutofillContentService"].fillForm).toHaveBeenCalledWith(
|
||||||
fillScript
|
fillScript,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -220,11 +220,11 @@ describe("AutofillInit", () => {
|
|||||||
|
|
||||||
expect(autofillInit["updateOverlayIsCurrentlyFilling"]).toHaveBeenNthCalledWith(1, true);
|
expect(autofillInit["updateOverlayIsCurrentlyFilling"]).toHaveBeenNthCalledWith(1, true);
|
||||||
expect(autofillInit["insertAutofillContentService"].fillForm).toHaveBeenCalledWith(
|
expect(autofillInit["insertAutofillContentService"].fillForm).toHaveBeenCalledWith(
|
||||||
fillScript
|
fillScript,
|
||||||
);
|
);
|
||||||
expect(autofillInit["updateOverlayIsCurrentlyFilling"]).toHaveBeenNthCalledWith(2, false);
|
expect(autofillInit["updateOverlayIsCurrentlyFilling"]).toHaveBeenNthCalledWith(2, false);
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].focusMostRecentOverlayField
|
autofillInit["autofillOverlayContentService"].focusMostRecentOverlayField,
|
||||||
).toHaveBeenCalled();
|
).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -247,14 +247,14 @@ describe("AutofillInit", () => {
|
|||||||
|
|
||||||
expect(newAutofillInit["updateOverlayIsCurrentlyFilling"]).toHaveBeenNthCalledWith(
|
expect(newAutofillInit["updateOverlayIsCurrentlyFilling"]).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
expect(newAutofillInit["insertAutofillContentService"].fillForm).toHaveBeenCalledWith(
|
expect(newAutofillInit["insertAutofillContentService"].fillForm).toHaveBeenCalledWith(
|
||||||
fillScript
|
fillScript,
|
||||||
);
|
);
|
||||||
expect(newAutofillInit["updateOverlayIsCurrentlyFilling"]).not.toHaveBeenNthCalledWith(
|
expect(newAutofillInit["updateOverlayIsCurrentlyFilling"]).not.toHaveBeenNthCalledWith(
|
||||||
2,
|
2,
|
||||||
false
|
false,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -282,7 +282,7 @@ describe("AutofillInit", () => {
|
|||||||
sendExtensionRuntimeMessage(message);
|
sendExtensionRuntimeMessage(message);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].openAutofillOverlay
|
autofillInit["autofillOverlayContentService"].openAutofillOverlay,
|
||||||
).toHaveBeenCalledWith({
|
).toHaveBeenCalledWith({
|
||||||
isFocusingFieldElement: message.data.isFocusingFieldElement,
|
isFocusingFieldElement: message.data.isFocusingFieldElement,
|
||||||
isOpeningFullOverlay: message.data.isOpeningFullOverlay,
|
isOpeningFullOverlay: message.data.isOpeningFullOverlay,
|
||||||
@ -303,10 +303,10 @@ describe("AutofillInit", () => {
|
|||||||
sendExtensionRuntimeMessage({ command: "closeAutofillOverlay" });
|
sendExtensionRuntimeMessage({ command: "closeAutofillOverlay" });
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].removeAutofillOverlayList
|
autofillInit["autofillOverlayContentService"].removeAutofillOverlayList,
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].removeAutofillOverlay
|
autofillInit["autofillOverlayContentService"].removeAutofillOverlay,
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -316,10 +316,10 @@ describe("AutofillInit", () => {
|
|||||||
sendExtensionRuntimeMessage({ command: "closeAutofillOverlay" });
|
sendExtensionRuntimeMessage({ command: "closeAutofillOverlay" });
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].removeAutofillOverlayList
|
autofillInit["autofillOverlayContentService"].removeAutofillOverlayList,
|
||||||
).toHaveBeenCalled();
|
).toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].removeAutofillOverlay
|
autofillInit["autofillOverlayContentService"].removeAutofillOverlay,
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -327,10 +327,10 @@ describe("AutofillInit", () => {
|
|||||||
sendExtensionRuntimeMessage({ command: "closeAutofillOverlay" });
|
sendExtensionRuntimeMessage({ command: "closeAutofillOverlay" });
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].removeAutofillOverlayList
|
autofillInit["autofillOverlayContentService"].removeAutofillOverlayList,
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].removeAutofillOverlay
|
autofillInit["autofillOverlayContentService"].removeAutofillOverlay,
|
||||||
).toHaveBeenCalled();
|
).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -373,7 +373,7 @@ describe("AutofillInit", () => {
|
|||||||
sendExtensionRuntimeMessage(message);
|
sendExtensionRuntimeMessage(message);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].redirectOverlayFocusOut
|
autofillInit["autofillOverlayContentService"].redirectOverlayFocusOut,
|
||||||
).toHaveBeenCalledWith(message.data.direction);
|
).toHaveBeenCalledWith(message.data.direction);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -399,7 +399,7 @@ describe("AutofillInit", () => {
|
|||||||
sendExtensionRuntimeMessage(message);
|
sendExtensionRuntimeMessage(message);
|
||||||
|
|
||||||
expect(autofillInit["autofillOverlayContentService"].isOverlayCiphersPopulated).toEqual(
|
expect(autofillInit["autofillOverlayContentService"].isOverlayCiphersPopulated).toEqual(
|
||||||
message.data.isOverlayCiphersPopulated
|
message.data.isOverlayCiphersPopulated,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -423,7 +423,7 @@ describe("AutofillInit", () => {
|
|||||||
sendExtensionRuntimeMessage({ command: "bgUnlockPopoutOpened" });
|
sendExtensionRuntimeMessage({ command: "bgUnlockPopoutOpened" });
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].blurMostRecentOverlayField
|
autofillInit["autofillOverlayContentService"].blurMostRecentOverlayField,
|
||||||
).toHaveBeenCalled();
|
).toHaveBeenCalled();
|
||||||
expect(autofillInit["removeAutofillOverlay"]).toHaveBeenCalled();
|
expect(autofillInit["removeAutofillOverlay"]).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -448,7 +448,7 @@ describe("AutofillInit", () => {
|
|||||||
sendExtensionRuntimeMessage({ command: "bgVaultItemRepromptPopoutOpened" });
|
sendExtensionRuntimeMessage({ command: "bgVaultItemRepromptPopoutOpened" });
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
autofillInit["autofillOverlayContentService"].blurMostRecentOverlayField
|
autofillInit["autofillOverlayContentService"].blurMostRecentOverlayField,
|
||||||
).toHaveBeenCalled();
|
).toHaveBeenCalled();
|
||||||
expect(autofillInit["removeAutofillOverlay"]).toHaveBeenCalled();
|
expect(autofillInit["removeAutofillOverlay"]).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -39,11 +39,11 @@ class AutofillInit implements AutofillInitInterface {
|
|||||||
this.domElementVisibilityService = new DomElementVisibilityService();
|
this.domElementVisibilityService = new DomElementVisibilityService();
|
||||||
this.collectAutofillContentService = new CollectAutofillContentService(
|
this.collectAutofillContentService = new CollectAutofillContentService(
|
||||||
this.domElementVisibilityService,
|
this.domElementVisibilityService,
|
||||||
this.autofillOverlayContentService
|
this.autofillOverlayContentService,
|
||||||
);
|
);
|
||||||
this.insertAutofillContentService = new InsertAutofillContentService(
|
this.insertAutofillContentService = new InsertAutofillContentService(
|
||||||
this.domElementVisibilityService,
|
this.domElementVisibilityService,
|
||||||
this.collectAutofillContentService
|
this.collectAutofillContentService,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class AutofillInit implements AutofillInitInterface {
|
|||||||
*/
|
*/
|
||||||
private async collectPageDetails(
|
private async collectPageDetails(
|
||||||
message: AutofillExtensionMessage,
|
message: AutofillExtensionMessage,
|
||||||
sendDetailsInResponse = false
|
sendDetailsInResponse = false,
|
||||||
): Promise<AutofillPageDetails | void> {
|
): Promise<AutofillPageDetails | void> {
|
||||||
const pageDetails: AutofillPageDetails =
|
const pageDetails: AutofillPageDetails =
|
||||||
await this.collectAutofillContentService.getPageDetails();
|
await this.collectAutofillContentService.getPageDetails();
|
||||||
@ -205,7 +205,7 @@ class AutofillInit implements AutofillInitInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.autofillOverlayContentService.isOverlayCiphersPopulated = Boolean(
|
this.autofillOverlayContentService.isOverlayCiphersPopulated = Boolean(
|
||||||
data?.isOverlayCiphersPopulated
|
data?.isOverlayCiphersPopulated,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ class AutofillInit implements AutofillInitInterface {
|
|||||||
private handleExtensionMessage = (
|
private handleExtensionMessage = (
|
||||||
message: AutofillExtensionMessage,
|
message: AutofillExtensionMessage,
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
sendResponse: (response?: any) => void
|
sendResponse: (response?: any) => void,
|
||||||
): boolean => {
|
): boolean => {
|
||||||
const command: string = message.command;
|
const command: string = message.command;
|
||||||
const handler: CallableFunction | undefined = this.extensionMessageHandlers[command];
|
const handler: CallableFunction | undefined = this.extensionMessageHandlers[command];
|
||||||
|
@ -24,7 +24,7 @@ window.addEventListener(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
false
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
const forwardCommands = [
|
const forwardCommands = [
|
||||||
|
@ -7,7 +7,7 @@ async function copyText(text: string) {
|
|||||||
async function onMessageListener(
|
async function onMessageListener(
|
||||||
msg: TabMessage,
|
msg: TabMessage,
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
responseCallback: (response: unknown) => void
|
responseCallback: (response: unknown) => void,
|
||||||
) {
|
) {
|
||||||
switch (msg.command) {
|
switch (msg.command) {
|
||||||
case "copyText":
|
case "copyText":
|
||||||
|
@ -445,7 +445,7 @@ async function loadNotificationBar() {
|
|||||||
// know what type of form we are watching
|
// know what type of form we are watching
|
||||||
const submitButton = getSubmitButton(
|
const submitButton = getSubmitButton(
|
||||||
form,
|
form,
|
||||||
unionSets(logInButtonNames, changePasswordButtonNames)
|
unionSets(logInButtonNames, changePasswordButtonNames),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (submitButton != null) {
|
if (submitButton != null) {
|
||||||
@ -475,7 +475,7 @@ async function loadNotificationBar() {
|
|||||||
watchedForm.formEl,
|
watchedForm.formEl,
|
||||||
watchedForm.data.password,
|
watchedForm.data.password,
|
||||||
inputs,
|
inputs,
|
||||||
true // Only do fallback if we have expect to find a single password field
|
true, // Only do fallback if we have expect to find a single password field
|
||||||
);
|
);
|
||||||
} else if (watchedForm.data.passwords != null) {
|
} else if (watchedForm.data.passwords != null) {
|
||||||
// if we didn't find a username field, try to locate multiple password fields
|
// if we didn't find a username field, try to locate multiple password fields
|
||||||
@ -499,7 +499,7 @@ async function loadNotificationBar() {
|
|||||||
form: HTMLFormElement,
|
form: HTMLFormElement,
|
||||||
passwordData: AutofillField,
|
passwordData: AutofillField,
|
||||||
inputs: HTMLInputElement[],
|
inputs: HTMLInputElement[],
|
||||||
doLastFallback: boolean
|
doLastFallback: boolean,
|
||||||
): HTMLInputElement {
|
): HTMLInputElement {
|
||||||
let el = locateField(form, passwordData, inputs);
|
let el = locateField(form, passwordData, inputs);
|
||||||
if (el != null && el.type !== "password") {
|
if (el != null && el.type !== "password") {
|
||||||
@ -521,7 +521,7 @@ async function loadNotificationBar() {
|
|||||||
function locateField(
|
function locateField(
|
||||||
form: HTMLFormElement,
|
form: HTMLFormElement,
|
||||||
fieldData: AutofillField,
|
fieldData: AutofillField,
|
||||||
inputs: HTMLInputElement[]
|
inputs: HTMLInputElement[],
|
||||||
): HTMLInputElement | null {
|
): HTMLInputElement | null {
|
||||||
// If we have no field data, we cannot locate the field
|
// If we have no field data, we cannot locate the field
|
||||||
if (fieldData == null) {
|
if (fieldData == null) {
|
||||||
@ -667,7 +667,7 @@ async function loadNotificationBar() {
|
|||||||
// Check if the submit button contains any of the change password button names as a safeguard
|
// Check if the submit button contains any of the change password button names as a safeguard
|
||||||
const buttonText = getButtonText(getSubmitButton(form, changePasswordButtonNames));
|
const buttonText = getButtonText(getSubmitButton(form, changePasswordButtonNames));
|
||||||
const matches = Array.from(changePasswordButtonContainsNames).filter(
|
const matches = Array.from(changePasswordButtonContainsNames).filter(
|
||||||
(n) => buttonText.indexOf(n) > -1
|
(n) => buttonText.indexOf(n) > -1,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (matches.length > 0) {
|
if (matches.length > 0) {
|
||||||
@ -744,8 +744,8 @@ async function loadNotificationBar() {
|
|||||||
if (submitButton == null) {
|
if (submitButton == null) {
|
||||||
const possibleSubmitButtons = Array.from(
|
const possibleSubmitButtons = Array.from(
|
||||||
wrappingEl.querySelectorAll(
|
wrappingEl.querySelectorAll(
|
||||||
'a, span, button[type="button"], ' + 'input[type="button"], button:not([type])'
|
'a, span, button[type="button"], ' + 'input[type="button"], button:not([type])',
|
||||||
)
|
),
|
||||||
) as HTMLElement[];
|
) as HTMLElement[];
|
||||||
let typelessButton: HTMLElement = null;
|
let typelessButton: HTMLElement = null;
|
||||||
// Loop through all possible submit buttons and find the first one that matches a submit button name
|
// Loop through all possible submit buttons and find the first one that matches a submit button name
|
||||||
|
@ -106,7 +106,7 @@ function createGenerateFillScriptOptionsMock(customFields = {}): GenerateFillScr
|
|||||||
|
|
||||||
function createAutofillScriptMock(
|
function createAutofillScriptMock(
|
||||||
customFields = {},
|
customFields = {},
|
||||||
scriptTypes?: Record<string, string>
|
scriptTypes?: Record<string, string>,
|
||||||
): AutofillScript {
|
): AutofillScript {
|
||||||
let script: FillScript[] = [
|
let script: FillScript[] = [
|
||||||
["click_on_opid", "default-field"],
|
["click_on_opid", "default-field"],
|
||||||
@ -152,7 +152,7 @@ const overlayPagesTranslations = {
|
|||||||
addNewVaultItem: "addNewVaultItem",
|
addNewVaultItem: "addNewVaultItem",
|
||||||
};
|
};
|
||||||
function createInitAutofillOverlayButtonMessageMock(
|
function createInitAutofillOverlayButtonMessageMock(
|
||||||
customFields = {}
|
customFields = {},
|
||||||
): InitAutofillOverlayButtonMessage {
|
): InitAutofillOverlayButtonMessage {
|
||||||
return {
|
return {
|
||||||
command: "initAutofillOverlayButton",
|
command: "initAutofillOverlayButton",
|
||||||
@ -181,7 +181,7 @@ function createAutofillOverlayCipherDataMock(index: number, customFields = {}):
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createInitAutofillOverlayListMessageMock(
|
function createInitAutofillOverlayListMessageMock(
|
||||||
customFields = {}
|
customFields = {},
|
||||||
): InitAutofillOverlayListMessage {
|
): InitAutofillOverlayListMessage {
|
||||||
return {
|
return {
|
||||||
command: "initAutofillOverlayList",
|
command: "initAutofillOverlayList",
|
||||||
|
@ -18,7 +18,7 @@ function postWindowMessage(data: any, origin = "https://localhost/") {
|
|||||||
function sendExtensionRuntimeMessage(
|
function sendExtensionRuntimeMessage(
|
||||||
message: any,
|
message: any,
|
||||||
sender?: chrome.runtime.MessageSender,
|
sender?: chrome.runtime.MessageSender,
|
||||||
sendResponse?: CallableFunction
|
sendResponse?: CallableFunction,
|
||||||
) {
|
) {
|
||||||
(chrome.runtime.onMessage.addListener as unknown as jest.SpyInstance).mock.calls.forEach(
|
(chrome.runtime.onMessage.addListener as unknown as jest.SpyInstance).mock.calls.forEach(
|
||||||
(call) => {
|
(call) => {
|
||||||
@ -26,9 +26,9 @@ function sendExtensionRuntimeMessage(
|
|||||||
callback(
|
callback(
|
||||||
message || {},
|
message || {},
|
||||||
sender || mock<chrome.runtime.MessageSender>(),
|
sender || mock<chrome.runtime.MessageSender>(),
|
||||||
sendResponse || jest.fn()
|
sendResponse || jest.fn(),
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ function triggerWindowOnFocusedChangedEvent(windowId: number) {
|
|||||||
(call) => {
|
(call) => {
|
||||||
const callback = call[0];
|
const callback = call[0];
|
||||||
callback(windowId);
|
callback(windowId);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ function triggerTabOnActivatedEvent(activeInfo: chrome.tabs.TabActiveInfo) {
|
|||||||
(call) => {
|
(call) => {
|
||||||
const callback = call[0];
|
const callback = call[0];
|
||||||
callback(activeInfo);
|
callback(activeInfo);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ function triggerTabOnReplacedEvent(addedTabId: number, removedTabId: number) {
|
|||||||
function triggerTabOnUpdatedEvent(
|
function triggerTabOnUpdatedEvent(
|
||||||
tabId: number,
|
tabId: number,
|
||||||
changeInfo: chrome.tabs.TabChangeInfo,
|
changeInfo: chrome.tabs.TabChangeInfo,
|
||||||
tab: chrome.tabs.Tab
|
tab: chrome.tabs.Tab,
|
||||||
) {
|
) {
|
||||||
(chrome.tabs.onUpdated.addListener as unknown as jest.SpyInstance).mock.calls.forEach((call) => {
|
(chrome.tabs.onUpdated.addListener as unknown as jest.SpyInstance).mock.calls.forEach((call) => {
|
||||||
const callback = call[0];
|
const callback = call[0];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Bitwarden</title>
|
<title>Bitwarden</title>
|
||||||
|
@ -12,7 +12,7 @@ class AutofillOverlayButtonIframe extends AutofillOverlayIframeElement {
|
|||||||
border: "none",
|
border: "none",
|
||||||
},
|
},
|
||||||
chrome.i18n.getMessage("bitwardenOverlayButton"),
|
chrome.i18n.getMessage("bitwardenOverlayButton"),
|
||||||
chrome.i18n.getMessage("bitwardenOverlayMenuAvailable")
|
chrome.i18n.getMessage("bitwardenOverlayMenuAvailable"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ class AutofillOverlayIframeElement extends HTMLElement {
|
|||||||
portName: string,
|
portName: string,
|
||||||
initStyles: Partial<CSSStyleDeclaration>,
|
initStyles: Partial<CSSStyleDeclaration>,
|
||||||
iframeTitle: string,
|
iframeTitle: string,
|
||||||
ariaAlert?: string
|
ariaAlert?: string,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ class AutofillOverlayIframeElement extends HTMLElement {
|
|||||||
const autofillOverlayIframeService = new AutofillOverlayIframeService(
|
const autofillOverlayIframeService = new AutofillOverlayIframeService(
|
||||||
iframePath,
|
iframePath,
|
||||||
portName,
|
portName,
|
||||||
shadow
|
shadow,
|
||||||
);
|
);
|
||||||
autofillOverlayIframeService.initOverlayIframe(initStyles, iframeTitle, ariaAlert);
|
autofillOverlayIframeService.initOverlayIframe(initStyles, iframeTitle, ariaAlert);
|
||||||
}
|
}
|
||||||
|
@ -23,17 +23,17 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
autofillOverlayIframeService = new AutofillOverlayIframeService(
|
autofillOverlayIframeService = new AutofillOverlayIframeService(
|
||||||
iframePath,
|
iframePath,
|
||||||
AutofillOverlayPort.Button,
|
AutofillOverlayPort.Button,
|
||||||
shadow
|
shadow,
|
||||||
);
|
);
|
||||||
shadowAppendSpy = jest.spyOn(shadow, "appendChild");
|
shadowAppendSpy = jest.spyOn(shadow, "appendChild");
|
||||||
handlePortDisconnectSpy = jest.spyOn(
|
handlePortDisconnectSpy = jest.spyOn(
|
||||||
autofillOverlayIframeService as any,
|
autofillOverlayIframeService as any,
|
||||||
"handlePortDisconnect"
|
"handlePortDisconnect",
|
||||||
);
|
);
|
||||||
handlePortMessageSpy = jest.spyOn(autofillOverlayIframeService as any, "handlePortMessage");
|
handlePortMessageSpy = jest.spyOn(autofillOverlayIframeService as any, "handlePortMessage");
|
||||||
handleWindowMessageSpy = jest.spyOn(autofillOverlayIframeService as any, "handleWindowMessage");
|
handleWindowMessageSpy = jest.spyOn(autofillOverlayIframeService as any, "handleWindowMessage");
|
||||||
chrome.runtime.connect = jest.fn((connectInfo: chrome.runtime.ConnectInfo) =>
|
chrome.runtime.connect = jest.fn((connectInfo: chrome.runtime.ConnectInfo) =>
|
||||||
createPortSpyMock(connectInfo.name)
|
createPortSpyMock(connectInfo.name),
|
||||||
) as unknown as typeof chrome.runtime.connect;
|
) as unknown as typeof chrome.runtime.connect;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
autofillOverlayIframeService.initOverlayIframe({}, "title");
|
autofillOverlayIframeService.initOverlayIframe({}, "title");
|
||||||
|
|
||||||
expect(autofillOverlayIframeService["shadow"].appendChild).toBeCalledWith(
|
expect(autofillOverlayIframeService["shadow"].appendChild).toBeCalledWith(
|
||||||
autofillOverlayIframeService["iframe"]
|
autofillOverlayIframeService["iframe"],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
|
|
||||||
expect(globalThis.removeEventListener).toBeCalledWith(
|
expect(globalThis.removeEventListener).toBeCalledWith(
|
||||||
EVENTS.MESSAGE,
|
EVENTS.MESSAGE,
|
||||||
handleWindowMessageSpy
|
handleWindowMessageSpy,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
|
|
||||||
expect(autofillOverlayIframeService["iframe"].contentWindow.postMessage).toBeCalledWith(
|
expect(autofillOverlayIframeService["iframe"].contentWindow.postMessage).toBeCalledWith(
|
||||||
message,
|
message,
|
||||||
"*"
|
"*",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
updateElementStylesSpy = jest.spyOn(
|
updateElementStylesSpy = jest.spyOn(
|
||||||
autofillOverlayIframeService as any,
|
autofillOverlayIframeService as any,
|
||||||
"updateElementStyles"
|
"updateElementStyles",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
expect(updateElementStylesSpy).not.toBeCalled();
|
expect(updateElementStylesSpy).not.toBeCalled();
|
||||||
expect(autofillOverlayIframeService["iframe"].contentWindow.postMessage).toBeCalledWith(
|
expect(autofillOverlayIframeService["iframe"].contentWindow.postMessage).toBeCalledWith(
|
||||||
message,
|
message,
|
||||||
"*"
|
"*",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
data: {},
|
data: {},
|
||||||
source: window,
|
source: window,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(portSpy.postMessage).not.toBeCalled();
|
expect(portSpy.postMessage).not.toBeCalled();
|
||||||
@ -356,7 +356,7 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
data: {},
|
data: {},
|
||||||
source: autofillOverlayIframeService["iframe"].contentWindow,
|
source: autofillOverlayIframeService["iframe"].contentWindow,
|
||||||
origin: "https://www.google.com",
|
origin: "https://www.google.com",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(portSpy.postMessage).not.toBeCalled();
|
expect(portSpy.postMessage).not.toBeCalled();
|
||||||
@ -368,7 +368,7 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
data: { command: "not-a-handled-command" },
|
data: { command: "not-a-handled-command" },
|
||||||
source: autofillOverlayIframeService["iframe"].contentWindow,
|
source: autofillOverlayIframeService["iframe"].contentWindow,
|
||||||
origin: "chrome-extension://id",
|
origin: "chrome-extension://id",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(portSpy.postMessage).toBeCalledWith({ command: "not-a-handled-command" });
|
expect(portSpy.postMessage).toBeCalledWith({ command: "not-a-handled-command" });
|
||||||
@ -380,7 +380,7 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
data: { command: "updateAutofillOverlayListHeight", styles: { height: "300px" } },
|
data: { command: "updateAutofillOverlayListHeight", styles: { height: "300px" } },
|
||||||
source: autofillOverlayIframeService["iframe"].contentWindow,
|
source: autofillOverlayIframeService["iframe"].contentWindow,
|
||||||
origin: "chrome-extension://id",
|
origin: "chrome-extension://id",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillOverlayIframeService["iframe"].style.height).toBe("300px");
|
expect(autofillOverlayIframeService["iframe"].style.height).toBe("300px");
|
||||||
|
@ -40,7 +40,11 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
|||||||
updateOverlayHidden: ({ message }) => this.updateElementStyles(this.iframe, message.styles),
|
updateOverlayHidden: ({ message }) => this.updateElementStyles(this.iframe, message.styles),
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(private iframePath: string, private portName: string, private shadow: ShadowRoot) {
|
constructor(
|
||||||
|
private iframePath: string,
|
||||||
|
private portName: string,
|
||||||
|
private shadow: ShadowRoot,
|
||||||
|
) {
|
||||||
this.extensionOriginsSet = new Set([
|
this.extensionOriginsSet = new Set([
|
||||||
chrome.runtime.getURL("").slice(0, -1).toLowerCase(), // Remove the trailing slash and normalize the extension url to lowercase
|
chrome.runtime.getURL("").slice(0, -1).toLowerCase(), // Remove the trailing slash and normalize the extension url to lowercase
|
||||||
"null",
|
"null",
|
||||||
@ -65,7 +69,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
|||||||
initOverlayIframe(
|
initOverlayIframe(
|
||||||
initStyles: Partial<CSSStyleDeclaration>,
|
initStyles: Partial<CSSStyleDeclaration>,
|
||||||
iframeTitle: string,
|
iframeTitle: string,
|
||||||
ariaAlert?: string
|
ariaAlert?: string,
|
||||||
) {
|
) {
|
||||||
this.iframe = globalThis.document.createElement("iframe");
|
this.iframe = globalThis.document.createElement("iframe");
|
||||||
this.iframe.src = chrome.runtime.getURL(this.iframePath);
|
this.iframe.src = chrome.runtime.getURL(this.iframePath);
|
||||||
@ -167,7 +171,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
|||||||
*/
|
*/
|
||||||
private handlePortMessage = (
|
private handlePortMessage = (
|
||||||
message: AutofillOverlayIframeExtensionMessage,
|
message: AutofillOverlayIframeExtensionMessage,
|
||||||
port: chrome.runtime.Port
|
port: chrome.runtime.Port,
|
||||||
) => {
|
) => {
|
||||||
if (port.name !== this.portName) {
|
if (port.name !== this.portName) {
|
||||||
return;
|
return;
|
||||||
|
@ -17,7 +17,7 @@ class AutofillOverlayListIframe extends AutofillOverlayIframeElement {
|
|||||||
borderStyle: "solid",
|
borderStyle: "solid",
|
||||||
borderColor: "rgb(206, 212, 220)",
|
borderColor: "rgb(206, 212, 220)",
|
||||||
},
|
},
|
||||||
chrome.i18n.getMessage("bitwardenVault")
|
chrome.i18n.getMessage("bitwardenVault"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,12 @@ describe("AutofillOverlayButton", () => {
|
|||||||
describe("initAutofillOverlayButton", () => {
|
describe("initAutofillOverlayButton", () => {
|
||||||
it("creates the button element with the locked icon when the user's auth status is not Unlocked", () => {
|
it("creates the button element with the locked icon when the user's auth status is not Unlocked", () => {
|
||||||
postWindowMessage(
|
postWindowMessage(
|
||||||
createInitAutofillOverlayButtonMessageMock({ authStatus: AuthenticationStatus.Locked })
|
createInitAutofillOverlayButtonMessageMock({ authStatus: AuthenticationStatus.Locked }),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillOverlayButton["buttonElement"]).toMatchSnapshot();
|
expect(autofillOverlayButton["buttonElement"]).toMatchSnapshot();
|
||||||
expect(autofillOverlayButton["buttonElement"].querySelector("svg")).toBe(
|
expect(autofillOverlayButton["buttonElement"].querySelector("svg")).toBe(
|
||||||
autofillOverlayButton["logoLockedIconElement"]
|
autofillOverlayButton["logoLockedIconElement"],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ describe("AutofillOverlayButton", () => {
|
|||||||
|
|
||||||
expect(autofillOverlayButton["buttonElement"]).toMatchSnapshot();
|
expect(autofillOverlayButton["buttonElement"]).toMatchSnapshot();
|
||||||
expect(autofillOverlayButton["buttonElement"].querySelector("svg")).toBe(
|
expect(autofillOverlayButton["buttonElement"].querySelector("svg")).toBe(
|
||||||
autofillOverlayButton["logoIconElement"]
|
autofillOverlayButton["logoIconElement"],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ describe("AutofillOverlayButton", () => {
|
|||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "overlayButtonClicked" },
|
{ command: "overlayButtonClicked" },
|
||||||
"https://localhost/"
|
"https://localhost/",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -74,7 +74,7 @@ describe("AutofillOverlayButton", () => {
|
|||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "closeAutofillOverlay" },
|
{ command: "closeAutofillOverlay" },
|
||||||
"https://localhost/"
|
"https://localhost/",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class AutofillOverlayButton extends AutofillOverlayPageElement {
|
|||||||
this.buttonElement.classList.add("overlay-button");
|
this.buttonElement.classList.add("overlay-button");
|
||||||
this.buttonElement.setAttribute(
|
this.buttonElement.setAttribute(
|
||||||
"aria-label",
|
"aria-label",
|
||||||
this.getTranslation("toggleBitwardenVaultOverlay")
|
this.getTranslation("toggleBitwardenVaultOverlay"),
|
||||||
);
|
);
|
||||||
this.buttonElement.addEventListener(EVENTS.CLICK, this.handleButtonElementClick);
|
this.buttonElement.addEventListener(EVENTS.CLICK, this.handleButtonElementClick);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Bitwarden overlay button</title>
|
<title>Bitwarden overlay button</title>
|
||||||
|
@ -36,7 +36,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
createInitAutofillOverlayListMessageMock({
|
createInitAutofillOverlayListMessageMock({
|
||||||
authStatus: AuthenticationStatus.Locked,
|
authStatus: AuthenticationStatus.Locked,
|
||||||
cipherList: [],
|
cipherList: [],
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "unlockVault" },
|
{ command: "unlockVault" },
|
||||||
"https://localhost/"
|
"https://localhost/",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -63,7 +63,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
createInitAutofillOverlayListMessageMock({
|
createInitAutofillOverlayListMessageMock({
|
||||||
authStatus: AuthenticationStatus.Unlocked,
|
authStatus: AuthenticationStatus.Unlocked,
|
||||||
ciphers: [],
|
ciphers: [],
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "addNewVaultItem" },
|
{ command: "addNewVaultItem" },
|
||||||
"https://localhost/"
|
"https://localhost/",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -113,7 +113,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
autofillOverlayList["cipherListScrollDebounceTimeout"] = setTimeout(jest.fn, 0);
|
autofillOverlayList["cipherListScrollDebounceTimeout"] = setTimeout(jest.fn, 0);
|
||||||
const handleDebouncedScrollEventSpy = jest.spyOn(
|
const handleDebouncedScrollEventSpy = jest.spyOn(
|
||||||
autofillOverlayList as any,
|
autofillOverlayList as any,
|
||||||
"handleDebouncedScrollEvent"
|
"handleDebouncedScrollEvent",
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayList["handleCiphersListScrollEvent"]();
|
autofillOverlayList["handleCiphersListScrollEvent"]();
|
||||||
@ -139,7 +139,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "fillSelectedListItem", overlayCipherId: "1" },
|
{ command: "fillSelectedListItem", overlayCipherId: "1" },
|
||||||
"https://localhost/"
|
"https://localhost/",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "viewSelectedCipher", overlayCipherId: "1" },
|
{ command: "viewSelectedCipher", overlayCipherId: "1" },
|
||||||
"https://localhost/"
|
"https://localhost/",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "checkAutofillOverlayButtonFocused" },
|
{ command: "checkAutofillOverlayButtonFocused" },
|
||||||
"https://localhost/"
|
"https://localhost/",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
createInitAutofillOverlayListMessageMock({
|
createInitAutofillOverlayListMessageMock({
|
||||||
authStatus: AuthenticationStatus.Locked,
|
authStatus: AuthenticationStatus.Locked,
|
||||||
cipherList: [],
|
cipherList: [],
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
const unlockButton =
|
const unlockButton =
|
||||||
autofillOverlayList["overlayListContainer"].querySelector("#unlock-button");
|
autofillOverlayList["overlayListContainer"].querySelector("#unlock-button");
|
||||||
@ -382,7 +382,7 @@ describe("AutofillOverlayList", () => {
|
|||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "updateAutofillOverlayListHeight", styles: { height: "300px" } },
|
{ command: "updateAutofillOverlayListHeight", styles: { height: "300px" } },
|
||||||
"https://localhost/"
|
"https://localhost/",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -89,7 +89,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
unlockButtonElement.textContent = this.getTranslation("unlockAccount");
|
unlockButtonElement.textContent = this.getTranslation("unlockAccount");
|
||||||
unlockButtonElement.setAttribute(
|
unlockButtonElement.setAttribute(
|
||||||
"aria-label",
|
"aria-label",
|
||||||
`${this.getTranslation("unlockAccount")}, ${this.getTranslation("opensInANewWindow")}`
|
`${this.getTranslation("unlockAccount")}, ${this.getTranslation("opensInANewWindow")}`,
|
||||||
);
|
);
|
||||||
unlockButtonElement.prepend(buildSvgDomElement(lockIcon));
|
unlockButtonElement.prepend(buildSvgDomElement(lockIcon));
|
||||||
unlockButtonElement.addEventListener(EVENTS.CLICK, this.handleUnlockButtonClick);
|
unlockButtonElement.addEventListener(EVENTS.CLICK, this.handleUnlockButtonClick);
|
||||||
@ -151,7 +151,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
newItemButton.textContent = this.getTranslation("newItem");
|
newItemButton.textContent = this.getTranslation("newItem");
|
||||||
newItemButton.setAttribute(
|
newItemButton.setAttribute(
|
||||||
"aria-label",
|
"aria-label",
|
||||||
`${this.getTranslation("addNewVaultItem")}, ${this.getTranslation("opensInANewWindow")}`
|
`${this.getTranslation("addNewVaultItem")}, ${this.getTranslation("opensInANewWindow")}`,
|
||||||
);
|
);
|
||||||
newItemButton.prepend(buildSvgDomElement(plusIcon));
|
newItemButton.prepend(buildSvgDomElement(plusIcon));
|
||||||
newItemButton.addEventListener(EVENTS.CLICK, this.handeNewItemButtonClick);
|
newItemButton.addEventListener(EVENTS.CLICK, this.handeNewItemButtonClick);
|
||||||
@ -177,7 +177,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
private loadPageOfCiphers() {
|
private loadPageOfCiphers() {
|
||||||
const lastIndex = Math.min(
|
const lastIndex = Math.min(
|
||||||
this.currentCipherIndex + this.showCiphersPerPage,
|
this.currentCipherIndex + this.showCiphersPerPage,
|
||||||
this.ciphers.length
|
this.ciphers.length,
|
||||||
);
|
);
|
||||||
for (let cipherIndex = this.currentCipherIndex; cipherIndex < lastIndex; cipherIndex++) {
|
for (let cipherIndex = this.currentCipherIndex; cipherIndex < lastIndex; cipherIndex++) {
|
||||||
this.ciphersList.appendChild(this.buildOverlayActionsListItem(this.ciphers[cipherIndex]));
|
this.ciphersList.appendChild(this.buildOverlayActionsListItem(this.ciphers[cipherIndex]));
|
||||||
@ -253,11 +253,11 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
fillCipherElement.classList.add("fill-cipher-button");
|
fillCipherElement.classList.add("fill-cipher-button");
|
||||||
fillCipherElement.setAttribute(
|
fillCipherElement.setAttribute(
|
||||||
"aria-label",
|
"aria-label",
|
||||||
`${this.getTranslation("fillCredentialsFor")} ${cipher.name}`
|
`${this.getTranslation("fillCredentialsFor")} ${cipher.name}`,
|
||||||
);
|
);
|
||||||
fillCipherElement.setAttribute(
|
fillCipherElement.setAttribute(
|
||||||
"aria-description",
|
"aria-description",
|
||||||
`${this.getTranslation("partialUsername")}, ${cipher.login.username}`
|
`${this.getTranslation("partialUsername")}, ${cipher.login.username}`,
|
||||||
);
|
);
|
||||||
fillCipherElement.append(cipherIcon, cipherDetailsElement);
|
fillCipherElement.append(cipherIcon, cipherDetailsElement);
|
||||||
fillCipherElement.addEventListener(EVENTS.CLICK, this.handleFillCipherClickEvent(cipher));
|
fillCipherElement.addEventListener(EVENTS.CLICK, this.handleFillCipherClickEvent(cipher));
|
||||||
@ -279,7 +279,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
command: "fillSelectedListItem",
|
command: "fillSelectedListItem",
|
||||||
overlayCipherId: cipher.id,
|
overlayCipherId: cipher.id,
|
||||||
}),
|
}),
|
||||||
`${cipher.id}-fill-cipher-button-click-handler`
|
`${cipher.id}-fill-cipher-button-click-handler`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
viewCipherElement.classList.add("view-cipher-button");
|
viewCipherElement.classList.add("view-cipher-button");
|
||||||
viewCipherElement.setAttribute(
|
viewCipherElement.setAttribute(
|
||||||
"aria-label",
|
"aria-label",
|
||||||
`${this.getTranslation("view")} ${cipher.name}, ${this.getTranslation("opensInANewWindow")}`
|
`${this.getTranslation("view")} ${cipher.name}, ${this.getTranslation("opensInANewWindow")}`,
|
||||||
);
|
);
|
||||||
viewCipherElement.append(buildSvgDomElement(viewCipherIcon));
|
viewCipherElement.append(buildSvgDomElement(viewCipherIcon));
|
||||||
viewCipherElement.addEventListener(EVENTS.CLICK, this.handleViewCipherClickEvent(cipher));
|
viewCipherElement.addEventListener(EVENTS.CLICK, this.handleViewCipherClickEvent(cipher));
|
||||||
@ -341,7 +341,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
private handleViewCipherClickEvent = (cipher: OverlayCipherData) => {
|
private handleViewCipherClickEvent = (cipher: OverlayCipherData) => {
|
||||||
return this.useEventHandlersMemo(
|
return this.useEventHandlersMemo(
|
||||||
() => this.postMessageToParent({ command: "viewSelectedCipher", overlayCipherId: cipher.id }),
|
() => this.postMessageToParent({ command: "viewSelectedCipher", overlayCipherId: cipher.id }),
|
||||||
`${cipher.id}-view-cipher-button-click-handler`
|
`${cipher.id}-view-cipher-button-click-handler`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -485,7 +485,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
*/
|
*/
|
||||||
private focusOverlayList() {
|
private focusOverlayList() {
|
||||||
const unlockButtonElement = this.overlayListContainer.querySelector(
|
const unlockButtonElement = this.overlayListContainer.querySelector(
|
||||||
"#unlock-button"
|
"#unlock-button",
|
||||||
) as HTMLElement;
|
) as HTMLElement;
|
||||||
if (unlockButtonElement) {
|
if (unlockButtonElement) {
|
||||||
unlockButtonElement.focus();
|
unlockButtonElement.focus();
|
||||||
@ -493,7 +493,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newItemButtonElement = this.overlayListContainer.querySelector(
|
const newItemButtonElement = this.overlayListContainer.querySelector(
|
||||||
"#new-item-button"
|
"#new-item-button",
|
||||||
) as HTMLElement;
|
) as HTMLElement;
|
||||||
if (newItemButtonElement) {
|
if (newItemButtonElement) {
|
||||||
newItemButtonElement.focus();
|
newItemButtonElement.focus();
|
||||||
@ -501,7 +501,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const firstCipherElement = this.overlayListContainer.querySelector(
|
const firstCipherElement = this.overlayListContainer.querySelector(
|
||||||
".fill-cipher-button"
|
".fill-cipher-button",
|
||||||
) as HTMLElement;
|
) as HTMLElement;
|
||||||
firstCipherElement?.focus();
|
firstCipherElement?.focus();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Bitwarden vault</title>
|
<title>Bitwarden vault</title>
|
||||||
|
@ -35,12 +35,12 @@ describe("AutofillOverlayPageElement", () => {
|
|||||||
const linkElement = autofillOverlayPageElement["initOverlayPage"](
|
const linkElement = autofillOverlayPageElement["initOverlayPage"](
|
||||||
"button",
|
"button",
|
||||||
"https://jest-testing-website.com",
|
"https://jest-testing-website.com",
|
||||||
translations
|
translations,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(globalThis.document.documentElement.setAttribute).toHaveBeenCalledWith(
|
expect(globalThis.document.documentElement.setAttribute).toHaveBeenCalledWith(
|
||||||
"lang",
|
"lang",
|
||||||
translations.locale
|
translations.locale,
|
||||||
);
|
);
|
||||||
expect(globalThis.document.head.title).toEqual(translations.buttonPageTitle);
|
expect(globalThis.document.head.title).toEqual(translations.buttonPageTitle);
|
||||||
expect(globalThis.document.createElement).toHaveBeenCalledWith("link");
|
expect(globalThis.document.createElement).toHaveBeenCalledWith("link");
|
||||||
@ -62,7 +62,7 @@ describe("AutofillOverlayPageElement", () => {
|
|||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "test" },
|
{ command: "test" },
|
||||||
"https://jest-testing-website.com"
|
"https://jest-testing-website.com",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -79,25 +79,25 @@ describe("AutofillOverlayPageElement", () => {
|
|||||||
it("sets up global event listeners", () => {
|
it("sets up global event listeners", () => {
|
||||||
const handleWindowMessageSpy = jest.spyOn(
|
const handleWindowMessageSpy = jest.spyOn(
|
||||||
autofillOverlayPageElement as any,
|
autofillOverlayPageElement as any,
|
||||||
"handleWindowMessage"
|
"handleWindowMessage",
|
||||||
);
|
);
|
||||||
const handleWindowBlurEventSpy = jest.spyOn(
|
const handleWindowBlurEventSpy = jest.spyOn(
|
||||||
autofillOverlayPageElement as any,
|
autofillOverlayPageElement as any,
|
||||||
"handleWindowBlurEvent"
|
"handleWindowBlurEvent",
|
||||||
);
|
);
|
||||||
const handleDocumentKeyDownEventSpy = jest.spyOn(
|
const handleDocumentKeyDownEventSpy = jest.spyOn(
|
||||||
autofillOverlayPageElement as any,
|
autofillOverlayPageElement as any,
|
||||||
"handleDocumentKeyDownEvent"
|
"handleDocumentKeyDownEvent",
|
||||||
);
|
);
|
||||||
autofillOverlayPageElement["setupGlobalListeners"](
|
autofillOverlayPageElement["setupGlobalListeners"](
|
||||||
mock<OverlayButtonWindowMessageHandlers>()
|
mock<OverlayButtonWindowMessageHandlers>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(globalThis.addEventListener).toHaveBeenCalledWith("message", handleWindowMessageSpy);
|
expect(globalThis.addEventListener).toHaveBeenCalledWith("message", handleWindowMessageSpy);
|
||||||
expect(globalThis.addEventListener).toHaveBeenCalledWith("blur", handleWindowBlurEventSpy);
|
expect(globalThis.addEventListener).toHaveBeenCalledWith("blur", handleWindowBlurEventSpy);
|
||||||
expect(globalThis.document.addEventListener).toHaveBeenCalledWith(
|
expect(globalThis.document.addEventListener).toHaveBeenCalledWith(
|
||||||
"keydown",
|
"keydown",
|
||||||
handleDocumentKeyDownEventSpy
|
handleDocumentKeyDownEventSpy,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -106,18 +106,18 @@ describe("AutofillOverlayPageElement", () => {
|
|||||||
autofillOverlayPageElement["setupGlobalListeners"](
|
autofillOverlayPageElement["setupGlobalListeners"](
|
||||||
mock<OverlayButtonWindowMessageHandlers>({
|
mock<OverlayButtonWindowMessageHandlers>({
|
||||||
initAutofillOverlayButton: initAutofillOverlayButtonSpy,
|
initAutofillOverlayButton: initAutofillOverlayButtonSpy,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
globalThis.dispatchEvent(
|
globalThis.dispatchEvent(
|
||||||
new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
data: { command: "initAutofillOverlayButton" },
|
data: { command: "initAutofillOverlayButton" },
|
||||||
origin: "https://jest-testing-website.com",
|
origin: "https://jest-testing-website.com",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillOverlayPageElement["messageOrigin"]).toEqual(
|
expect(autofillOverlayPageElement["messageOrigin"]).toEqual(
|
||||||
"https://jest-testing-website.com"
|
"https://jest-testing-website.com",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ describe("AutofillOverlayPageElement", () => {
|
|||||||
autofillOverlayPageElement["setupGlobalListeners"](
|
autofillOverlayPageElement["setupGlobalListeners"](
|
||||||
mock<OverlayButtonWindowMessageHandlers>({
|
mock<OverlayButtonWindowMessageHandlers>({
|
||||||
initAutofillOverlayButton: initAutofillOverlayButtonSpy,
|
initAutofillOverlayButton: initAutofillOverlayButtonSpy,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
const data = { command: "initAutofillOverlayButton" };
|
const data = { command: "initAutofillOverlayButton" };
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ describe("AutofillOverlayPageElement", () => {
|
|||||||
autofillOverlayPageElement["setupGlobalListeners"](
|
autofillOverlayPageElement["setupGlobalListeners"](
|
||||||
mock<OverlayButtonWindowMessageHandlers>({
|
mock<OverlayButtonWindowMessageHandlers>({
|
||||||
initAutofillOverlayButton: initAutofillOverlayButtonSpy,
|
initAutofillOverlayButton: initAutofillOverlayButtonSpy,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
globalThis.dispatchEvent(new MessageEvent("message", { data: { command: "test" } }));
|
globalThis.dispatchEvent(new MessageEvent("message", { data: { command: "test" } }));
|
||||||
@ -151,20 +151,20 @@ describe("AutofillOverlayPageElement", () => {
|
|||||||
it("posts a message to the parent when the window is blurred", () => {
|
it("posts a message to the parent when the window is blurred", () => {
|
||||||
autofillOverlayPageElement["messageOrigin"] = "https://jest-testing-website.com";
|
autofillOverlayPageElement["messageOrigin"] = "https://jest-testing-website.com";
|
||||||
autofillOverlayPageElement["setupGlobalListeners"](
|
autofillOverlayPageElement["setupGlobalListeners"](
|
||||||
mock<OverlayButtonWindowMessageHandlers>()
|
mock<OverlayButtonWindowMessageHandlers>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
globalThis.dispatchEvent(new Event("blur"));
|
globalThis.dispatchEvent(new Event("blur"));
|
||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "overlayPageBlurred" },
|
{ command: "overlayPageBlurred" },
|
||||||
"https://jest-testing-website.com"
|
"https://jest-testing-website.com",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("skips redirecting keyboard focus when a KeyDown event triggers and the key is not a `Tab` or `Escape` key", () => {
|
it("skips redirecting keyboard focus when a KeyDown event triggers and the key is not a `Tab` or `Escape` key", () => {
|
||||||
autofillOverlayPageElement["setupGlobalListeners"](
|
autofillOverlayPageElement["setupGlobalListeners"](
|
||||||
mock<OverlayButtonWindowMessageHandlers>()
|
mock<OverlayButtonWindowMessageHandlers>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
globalThis.document.dispatchEvent(new KeyboardEvent("keydown", { code: "test" }));
|
globalThis.document.dispatchEvent(new KeyboardEvent("keydown", { code: "test" }));
|
||||||
@ -175,44 +175,44 @@ describe("AutofillOverlayPageElement", () => {
|
|||||||
it("redirects the overlay focus out to the previous element on KeyDown of the `Tab+Shift` keys", () => {
|
it("redirects the overlay focus out to the previous element on KeyDown of the `Tab+Shift` keys", () => {
|
||||||
autofillOverlayPageElement["messageOrigin"] = "https://jest-testing-website.com";
|
autofillOverlayPageElement["messageOrigin"] = "https://jest-testing-website.com";
|
||||||
autofillOverlayPageElement["setupGlobalListeners"](
|
autofillOverlayPageElement["setupGlobalListeners"](
|
||||||
mock<OverlayButtonWindowMessageHandlers>()
|
mock<OverlayButtonWindowMessageHandlers>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
globalThis.document.dispatchEvent(
|
globalThis.document.dispatchEvent(
|
||||||
new KeyboardEvent("keydown", { code: "Tab", shiftKey: true })
|
new KeyboardEvent("keydown", { code: "Tab", shiftKey: true }),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "redirectOverlayFocusOut", direction: "previous" },
|
{ command: "redirectOverlayFocusOut", direction: "previous" },
|
||||||
"https://jest-testing-website.com"
|
"https://jest-testing-website.com",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("redirects the overlay focus out to the next element on KeyDown of the `Tab` key", () => {
|
it("redirects the overlay focus out to the next element on KeyDown of the `Tab` key", () => {
|
||||||
autofillOverlayPageElement["messageOrigin"] = "https://jest-testing-website.com";
|
autofillOverlayPageElement["messageOrigin"] = "https://jest-testing-website.com";
|
||||||
autofillOverlayPageElement["setupGlobalListeners"](
|
autofillOverlayPageElement["setupGlobalListeners"](
|
||||||
mock<OverlayButtonWindowMessageHandlers>()
|
mock<OverlayButtonWindowMessageHandlers>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
globalThis.document.dispatchEvent(new KeyboardEvent("keydown", { code: "Tab" }));
|
globalThis.document.dispatchEvent(new KeyboardEvent("keydown", { code: "Tab" }));
|
||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "redirectOverlayFocusOut", direction: "next" },
|
{ command: "redirectOverlayFocusOut", direction: "next" },
|
||||||
"https://jest-testing-website.com"
|
"https://jest-testing-website.com",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("redirects the overlay focus out to the current element on KeyDown of the `Escape` key", () => {
|
it("redirects the overlay focus out to the current element on KeyDown of the `Escape` key", () => {
|
||||||
autofillOverlayPageElement["messageOrigin"] = "https://jest-testing-website.com";
|
autofillOverlayPageElement["messageOrigin"] = "https://jest-testing-website.com";
|
||||||
autofillOverlayPageElement["setupGlobalListeners"](
|
autofillOverlayPageElement["setupGlobalListeners"](
|
||||||
mock<OverlayButtonWindowMessageHandlers>()
|
mock<OverlayButtonWindowMessageHandlers>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
globalThis.document.dispatchEvent(new KeyboardEvent("keydown", { code: "Escape" }));
|
globalThis.document.dispatchEvent(new KeyboardEvent("keydown", { code: "Escape" }));
|
||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "redirectOverlayFocusOut", direction: "current" },
|
{ command: "redirectOverlayFocusOut", direction: "current" },
|
||||||
"https://jest-testing-website.com"
|
"https://jest-testing-website.com",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,7 @@ class AutofillOverlayPageElement extends HTMLElement {
|
|||||||
protected initOverlayPage(
|
protected initOverlayPage(
|
||||||
elementName: "button" | "list",
|
elementName: "button" | "list",
|
||||||
styleSheetUrl: string,
|
styleSheetUrl: string,
|
||||||
translations: Record<string, string>
|
translations: Record<string, string>,
|
||||||
): HTMLLinkElement {
|
): HTMLLinkElement {
|
||||||
this.translations = translations;
|
this.translations = translations;
|
||||||
globalThis.document.documentElement.setAttribute("lang", this.getTranslation("locale"));
|
globalThis.document.documentElement.setAttribute("lang", this.getTranslation("locale"));
|
||||||
@ -127,7 +127,7 @@ class AutofillOverlayPageElement extends HTMLElement {
|
|||||||
|
|
||||||
if (event.code === "Tab") {
|
if (event.code === "Tab") {
|
||||||
this.redirectOverlayFocusOutMessage(
|
this.redirectOverlayFocusOutMessage(
|
||||||
event.shiftKey ? RedirectFocusDirection.Previous : RedirectFocusDirection.Next
|
event.shiftKey ? RedirectFocusDirection.Previous : RedirectFocusDirection.Next,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ interface AutofillOverlayContentService {
|
|||||||
init(): void;
|
init(): void;
|
||||||
setupAutofillOverlayListenerOnField(
|
setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement: ElementWithOpId<FormFieldElement>,
|
autofillFieldElement: ElementWithOpId<FormFieldElement>,
|
||||||
autofillFieldData: AutofillField
|
autofillFieldData: AutofillField,
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
openAutofillOverlay(options: OpenAutofillOverlayOptions): void;
|
openAutofillOverlay(options: OpenAutofillOverlayOptions): void;
|
||||||
removeAutofillOverlay(): void;
|
removeAutofillOverlay(): void;
|
||||||
|
@ -47,19 +47,19 @@ export abstract class AutofillService {
|
|||||||
injectAutofillScripts: (
|
injectAutofillScripts: (
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
autofillV2?: boolean,
|
autofillV2?: boolean,
|
||||||
autofillOverlay?: boolean
|
autofillOverlay?: boolean,
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
getFormsWithPasswordFields: (pageDetails: AutofillPageDetails) => FormData[];
|
getFormsWithPasswordFields: (pageDetails: AutofillPageDetails) => FormData[];
|
||||||
doAutoFill: (options: AutoFillOptions) => Promise<string | null>;
|
doAutoFill: (options: AutoFillOptions) => Promise<string | null>;
|
||||||
doAutoFillOnTab: (
|
doAutoFillOnTab: (
|
||||||
pageDetails: PageDetail[],
|
pageDetails: PageDetail[],
|
||||||
tab: chrome.tabs.Tab,
|
tab: chrome.tabs.Tab,
|
||||||
fromCommand: boolean
|
fromCommand: boolean,
|
||||||
) => Promise<string | null>;
|
) => Promise<string | null>;
|
||||||
doAutoFillActiveTab: (
|
doAutoFillActiveTab: (
|
||||||
pageDetails: PageDetail[],
|
pageDetails: PageDetail[],
|
||||||
fromCommand: boolean,
|
fromCommand: boolean,
|
||||||
cipherType?: CipherType
|
cipherType?: CipherType,
|
||||||
) => Promise<string | null>;
|
) => Promise<string | null>;
|
||||||
isPasswordRepromptRequired: (cipher: CipherView, tab: chrome.tabs.Tab) => Promise<boolean>;
|
isPasswordRepromptRequired: (cipher: CipherView, tab: chrome.tabs.Tab) => Promise<boolean>;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ interface CollectAutofillContentService {
|
|||||||
queryAllTreeWalkerNodes(
|
queryAllTreeWalkerNodes(
|
||||||
rootNode: Node,
|
rootNode: Node,
|
||||||
filterCallback: CallableFunction,
|
filterCallback: CallableFunction,
|
||||||
isObservingShadowRoot?: boolean
|
isObservingShadowRoot?: boolean,
|
||||||
): Node[];
|
): Node[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.spyOn(window, "addEventListener");
|
jest.spyOn(window, "addEventListener");
|
||||||
setupGlobalEventListenersSpy = jest.spyOn(
|
setupGlobalEventListenersSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"setupGlobalEventListeners"
|
"setupGlobalEventListeners",
|
||||||
);
|
);
|
||||||
setupMutationObserverSpy = jest.spyOn(
|
setupMutationObserverSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"setupMutationObserver"
|
"setupMutationObserver",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(document.addEventListener).toHaveBeenCalledWith(
|
expect(document.addEventListener).toHaveBeenCalledWith(
|
||||||
"DOMContentLoaded",
|
"DOMContentLoaded",
|
||||||
setupGlobalEventListenersSpy
|
setupGlobalEventListenersSpy,
|
||||||
);
|
);
|
||||||
expect(setupGlobalEventListenersSpy).not.toHaveBeenCalled();
|
expect(setupGlobalEventListenersSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -84,21 +84,21 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("sets up a visibility change listener for the DOM", () => {
|
it("sets up a visibility change listener for the DOM", () => {
|
||||||
const handleVisibilityChangeEventSpy = jest.spyOn(
|
const handleVisibilityChangeEventSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"handleVisibilityChangeEvent"
|
"handleVisibilityChangeEvent",
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayContentService.init();
|
autofillOverlayContentService.init();
|
||||||
|
|
||||||
expect(document.addEventListener).toHaveBeenCalledWith(
|
expect(document.addEventListener).toHaveBeenCalledWith(
|
||||||
"visibilitychange",
|
"visibilitychange",
|
||||||
handleVisibilityChangeEventSpy
|
handleVisibilityChangeEventSpy,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets up a focus out listener for the window", () => {
|
it("sets up a focus out listener for the window", () => {
|
||||||
const handleFormFieldBlurEventSpy = jest.spyOn(
|
const handleFormFieldBlurEventSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"handleFormFieldBlurEvent"
|
"handleFormFieldBlurEvent",
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayContentService.init();
|
autofillOverlayContentService.init();
|
||||||
@ -112,15 +112,15 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
.mockImplementation(() => mock<MutationObserver>({ observe: jest.fn() }));
|
.mockImplementation(() => mock<MutationObserver>({ observe: jest.fn() }));
|
||||||
const handleOverlayElementMutationObserverUpdateSpy = jest.spyOn(
|
const handleOverlayElementMutationObserverUpdateSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"handleOverlayElementMutationObserverUpdate"
|
"handleOverlayElementMutationObserverUpdate",
|
||||||
);
|
);
|
||||||
const handleBodyElementMutationObserverUpdateSpy = jest.spyOn(
|
const handleBodyElementMutationObserverUpdateSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"handleBodyElementMutationObserverUpdate"
|
"handleBodyElementMutationObserverUpdate",
|
||||||
);
|
);
|
||||||
const handleDocumentElementMutationObserverUpdateSpy = jest.spyOn(
|
const handleDocumentElementMutationObserverUpdateSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"handleDocumentElementMutationObserverUpdate"
|
"handleDocumentElementMutationObserverUpdate",
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayContentService.init();
|
autofillOverlayContentService.init();
|
||||||
@ -128,15 +128,15 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
expect(setupMutationObserverSpy).toHaveBeenCalledTimes(1);
|
expect(setupMutationObserverSpy).toHaveBeenCalledTimes(1);
|
||||||
expect(globalThis.MutationObserver).toHaveBeenNthCalledWith(
|
expect(globalThis.MutationObserver).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
handleOverlayElementMutationObserverUpdateSpy
|
handleOverlayElementMutationObserverUpdateSpy,
|
||||||
);
|
);
|
||||||
expect(globalThis.MutationObserver).toHaveBeenNthCalledWith(
|
expect(globalThis.MutationObserver).toHaveBeenNthCalledWith(
|
||||||
2,
|
2,
|
||||||
handleBodyElementMutationObserverUpdateSpy
|
handleBodyElementMutationObserverUpdateSpy,
|
||||||
);
|
);
|
||||||
expect(globalThis.MutationObserver).toHaveBeenNthCalledWith(
|
expect(globalThis.MutationObserver).toHaveBeenNthCalledWith(
|
||||||
3,
|
3,
|
||||||
handleDocumentElementMutationObserverUpdateSpy
|
handleDocumentElementMutationObserverUpdateSpy,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -154,7 +154,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
autofillFieldElement = document.getElementById(
|
autofillFieldElement = document.getElementById(
|
||||||
"username-field"
|
"username-field",
|
||||||
) as ElementWithOpId<FormFieldElement>;
|
) as ElementWithOpId<FormFieldElement>;
|
||||||
autofillFieldElement.opid = "op-1";
|
autofillFieldElement.opid = "op-1";
|
||||||
jest.spyOn(autofillFieldElement, "addEventListener");
|
jest.spyOn(autofillFieldElement, "addEventListener");
|
||||||
@ -176,7 +176,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
||||||
@ -187,7 +187,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
||||||
@ -198,7 +198,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
||||||
@ -210,7 +210,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
||||||
@ -222,7 +222,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
||||||
@ -233,7 +233,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
||||||
@ -244,7 +244,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
expect(autofillFieldElement.addEventListener).not.toHaveBeenCalled();
|
||||||
@ -258,12 +258,12 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("getAutofillOverlayVisibility");
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("getAutofillOverlayVisibility");
|
||||||
expect(autofillOverlayContentService["autofillOverlayVisibility"]).toEqual(
|
expect(autofillOverlayContentService["autofillOverlayVisibility"]).toEqual(
|
||||||
AutofillOverlayVisibility.OnFieldFocus
|
AutofillOverlayVisibility.OnFieldFocus,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -273,11 +273,11 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillOverlayContentService["autofillOverlayVisibility"]).toEqual(
|
expect(autofillOverlayContentService["autofillOverlayVisibility"]).toEqual(
|
||||||
AutofillOverlayVisibility.OnFieldFocus
|
AutofillOverlayVisibility.OnFieldFocus,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -296,23 +296,23 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldElement.removeEventListener).toHaveBeenNthCalledWith(
|
expect(autofillFieldElement.removeEventListener).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
"input",
|
"input",
|
||||||
inputHandler
|
inputHandler,
|
||||||
);
|
);
|
||||||
expect(autofillFieldElement.removeEventListener).toHaveBeenNthCalledWith(
|
expect(autofillFieldElement.removeEventListener).toHaveBeenNthCalledWith(
|
||||||
2,
|
2,
|
||||||
"click",
|
"click",
|
||||||
clickHandler
|
clickHandler,
|
||||||
);
|
);
|
||||||
expect(autofillFieldElement.removeEventListener).toHaveBeenNthCalledWith(
|
expect(autofillFieldElement.removeEventListener).toHaveBeenNthCalledWith(
|
||||||
3,
|
3,
|
||||||
"focus",
|
"focus",
|
||||||
focusHandler
|
focusHandler,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
jest.spyOn(globalThis.customElements, "define").mockImplementation();
|
jest.spyOn(globalThis.customElements, "define").mockImplementation();
|
||||||
});
|
});
|
||||||
@ -359,7 +359,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("repositions the overlay if autofill is not currently filling when the `Enter` key is pressed", () => {
|
it("repositions the overlay if autofill is not currently filling when the `Enter` key is pressed", () => {
|
||||||
const handleOverlayRepositionEventSpy = jest.spyOn(
|
const handleOverlayRepositionEventSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"handleOverlayRepositionEvent"
|
"handleOverlayRepositionEvent",
|
||||||
);
|
);
|
||||||
autofillOverlayContentService["isCurrentlyFilling"] = false;
|
autofillOverlayContentService["isCurrentlyFilling"] = false;
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("skips repositioning the overlay if autofill is currently filling when the `Enter` key is pressed", () => {
|
it("skips repositioning the overlay if autofill is currently filling when the `Enter` key is pressed", () => {
|
||||||
const handleOverlayRepositionEventSpy = jest.spyOn(
|
const handleOverlayRepositionEventSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"handleOverlayRepositionEvent"
|
"handleOverlayRepositionEvent",
|
||||||
);
|
);
|
||||||
autofillOverlayContentService["isCurrentlyFilling"] = true;
|
autofillOverlayContentService["isCurrentlyFilling"] = true;
|
||||||
|
|
||||||
@ -384,11 +384,11 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
const updateMostRecentlyFocusedFieldSpy = jest.spyOn(
|
const updateMostRecentlyFocusedFieldSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"updateMostRecentlyFocusedField"
|
"updateMostRecentlyFocusedField",
|
||||||
);
|
);
|
||||||
const openAutofillOverlaySpy = jest.spyOn(
|
const openAutofillOverlaySpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"openAutofillOverlay"
|
"openAutofillOverlay",
|
||||||
);
|
);
|
||||||
autofillOverlayContentService["isOverlayListVisible"] = false;
|
autofillOverlayContentService["isOverlayListVisible"] = false;
|
||||||
|
|
||||||
@ -420,13 +420,13 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
it("ignores span elements that trigger the listener", async () => {
|
it("ignores span elements that trigger the listener", async () => {
|
||||||
const spanAutofillFieldElement = document.createElement(
|
const spanAutofillFieldElement = document.createElement(
|
||||||
"span"
|
"span",
|
||||||
) as ElementWithOpId<HTMLSpanElement>;
|
) as ElementWithOpId<HTMLSpanElement>;
|
||||||
jest.spyOn(autofillOverlayContentService as any, "storeModifiedFormElement");
|
jest.spyOn(autofillOverlayContentService as any, "storeModifiedFormElement");
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
spanAutofillFieldElement,
|
spanAutofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
spanAutofillFieldElement.dispatchEvent(new Event("input"));
|
spanAutofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
@ -437,28 +437,28 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("stores the field as a user filled field if the form field data indicates that it is for a username", async () => {
|
it("stores the field as a user filled field if the form field data indicates that it is for a username", async () => {
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
autofillFieldElement.dispatchEvent(new Event("input"));
|
autofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
|
|
||||||
expect(autofillOverlayContentService["userFilledFields"].username).toEqual(
|
expect(autofillOverlayContentService["userFilledFields"].username).toEqual(
|
||||||
autofillFieldElement
|
autofillFieldElement,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("stores the field as a user filled field if the form field is of type password", async () => {
|
it("stores the field as a user filled field if the form field is of type password", async () => {
|
||||||
const passwordFieldElement = document.getElementById(
|
const passwordFieldElement = document.getElementById(
|
||||||
"password-field"
|
"password-field",
|
||||||
) as ElementWithOpId<FormFieldElement>;
|
) as ElementWithOpId<FormFieldElement>;
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
passwordFieldElement,
|
passwordFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
passwordFieldElement.dispatchEvent(new Event("input"));
|
passwordFieldElement.dispatchEvent(new Event("input"));
|
||||||
|
|
||||||
expect(autofillOverlayContentService["userFilledFields"].password).toEqual(
|
expect(autofillOverlayContentService["userFilledFields"].password).toEqual(
|
||||||
passwordFieldElement
|
passwordFieldElement,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -466,13 +466,13 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.spyOn(autofillOverlayContentService as any, "isUserAuthed").mockReturnValue(false);
|
jest.spyOn(autofillOverlayContentService as any, "isUserAuthed").mockReturnValue(false);
|
||||||
const removeAutofillOverlayListSpy = jest.spyOn(
|
const removeAutofillOverlayListSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"removeAutofillOverlayList"
|
"removeAutofillOverlayList",
|
||||||
);
|
);
|
||||||
(autofillFieldElement as HTMLInputElement).value = "test";
|
(autofillFieldElement as HTMLInputElement).value = "test";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
autofillFieldElement.dispatchEvent(new Event("input"));
|
autofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
|
|
||||||
@ -484,13 +484,13 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillOverlayContentService["isOverlayCiphersPopulated"] = true;
|
autofillOverlayContentService["isOverlayCiphersPopulated"] = true;
|
||||||
const removeAutofillOverlayListSpy = jest.spyOn(
|
const removeAutofillOverlayListSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"removeAutofillOverlayList"
|
"removeAutofillOverlayList",
|
||||||
);
|
);
|
||||||
(autofillFieldElement as HTMLInputElement).value = "test";
|
(autofillFieldElement as HTMLInputElement).value = "test";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
autofillFieldElement.dispatchEvent(new Event("input"));
|
autofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
|
|
||||||
@ -503,7 +503,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
autofillFieldElement.dispatchEvent(new Event("input"));
|
autofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
autofillFieldElement.dispatchEvent(new Event("input"));
|
autofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
|
|
||||||
@ -532,7 +532,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
autofillFieldElement.dispatchEvent(new Event("input"));
|
autofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
|
|
||||||
@ -549,7 +549,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillOverlayContentService["isOverlayListVisible"] = false;
|
autofillOverlayContentService["isOverlayListVisible"] = false;
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -565,7 +565,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillFieldElement.dispatchEvent(new Event("click"));
|
autofillFieldElement.dispatchEvent(new Event("click"));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
autofillOverlayContentService["triggerFormFieldFocusedAction"]
|
autofillOverlayContentService["triggerFormFieldFocusedAction"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillFieldElement.dispatchEvent(new Event("click"));
|
autofillFieldElement.dispatchEvent(new Event("click"));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
autofillOverlayContentService["triggerFormFieldFocusedAction"]
|
autofillOverlayContentService["triggerFormFieldFocusedAction"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -587,7 +587,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.spyOn(globalThis.customElements, "define").mockImplementation();
|
jest.spyOn(globalThis.customElements, "define").mockImplementation();
|
||||||
updateMostRecentlyFocusedFieldSpy = jest.spyOn(
|
updateMostRecentlyFocusedFieldSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"updateMostRecentlyFocusedField"
|
"updateMostRecentlyFocusedField",
|
||||||
);
|
);
|
||||||
autofillOverlayContentService["isCurrentlyFilling"] = false;
|
autofillOverlayContentService["isCurrentlyFilling"] = false;
|
||||||
});
|
});
|
||||||
@ -599,7 +599,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
AutofillOverlayVisibility.OnFieldFocus;
|
AutofillOverlayVisibility.OnFieldFocus;
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillFieldElement.dispatchEvent(new Event("focus"));
|
autofillFieldElement.dispatchEvent(new Event("focus"));
|
||||||
@ -610,14 +610,14 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("updates the most recently focused field", async () => {
|
it("updates the most recently focused field", async () => {
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillFieldElement.dispatchEvent(new Event("focus"));
|
autofillFieldElement.dispatchEvent(new Event("focus"));
|
||||||
|
|
||||||
expect(updateMostRecentlyFocusedFieldSpy).toHaveBeenCalledWith(autofillFieldElement);
|
expect(updateMostRecentlyFocusedFieldSpy).toHaveBeenCalledWith(autofillFieldElement);
|
||||||
expect(autofillOverlayContentService["mostRecentlyFocusedField"]).toEqual(
|
expect(autofillOverlayContentService["mostRecentlyFocusedField"]).toEqual(
|
||||||
autofillFieldElement
|
autofillFieldElement,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -627,7 +627,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
AutofillOverlayVisibility.OnButtonClick;
|
AutofillOverlayVisibility.OnButtonClick;
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillFieldElement.dispatchEvent(new Event("focus"));
|
autofillFieldElement.dispatchEvent(new Event("focus"));
|
||||||
@ -641,12 +641,12 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("removes the overlay list if the form element has a value and the focused field is newly focused", async () => {
|
it("removes the overlay list if the form element has a value and the focused field is newly focused", async () => {
|
||||||
autofillOverlayContentService["overlayListElement"] = document.createElement("div");
|
autofillOverlayContentService["overlayListElement"] = document.createElement("div");
|
||||||
autofillOverlayContentService["mostRecentlyFocusedField"] = document.createElement(
|
autofillOverlayContentService["mostRecentlyFocusedField"] = document.createElement(
|
||||||
"input"
|
"input",
|
||||||
) as ElementWithOpId<HTMLInputElement>;
|
) as ElementWithOpId<HTMLInputElement>;
|
||||||
(autofillFieldElement as HTMLInputElement).value = "test";
|
(autofillFieldElement as HTMLInputElement).value = "test";
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillFieldElement.dispatchEvent(new Event("focus"));
|
autofillFieldElement.dispatchEvent(new Event("focus"));
|
||||||
@ -664,7 +664,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
AutofillOverlayVisibility.OnFieldFocus;
|
AutofillOverlayVisibility.OnFieldFocus;
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillFieldElement.dispatchEvent(new Event("focus"));
|
autofillFieldElement.dispatchEvent(new Event("focus"));
|
||||||
@ -681,7 +681,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.spyOn(autofillOverlayContentService as any, "isUserAuthed").mockReturnValue(true);
|
jest.spyOn(autofillOverlayContentService as any, "isUserAuthed").mockReturnValue(true);
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillFieldElement.dispatchEvent(new Event("focus"));
|
autofillFieldElement.dispatchEvent(new Event("focus"));
|
||||||
@ -697,7 +697,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillOverlayContentService["isOverlayCiphersPopulated"] = true;
|
autofillOverlayContentService["isOverlayCiphersPopulated"] = true;
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillFieldElement.dispatchEvent(new Event("focus"));
|
autofillFieldElement.dispatchEvent(new Event("focus"));
|
||||||
@ -719,12 +719,12 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("openAutofillOverlay");
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("openAutofillOverlay");
|
||||||
expect(autofillOverlayContentService["mostRecentlyFocusedField"]).toEqual(
|
expect(autofillOverlayContentService["mostRecentlyFocusedField"]).toEqual(
|
||||||
autofillFieldElement
|
autofillFieldElement,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -733,11 +733,11 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillOverlayContentService["mostRecentlyFocusedField"]).toEqual(
|
expect(autofillOverlayContentService["mostRecentlyFocusedField"]).toEqual(
|
||||||
autofillFieldElement
|
autofillFieldElement,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -754,7 +754,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
autofillFieldElement = document.getElementById(
|
autofillFieldElement = document.getElementById(
|
||||||
"username-field"
|
"username-field",
|
||||||
) as ElementWithOpId<FormFieldElement>;
|
) as ElementWithOpId<FormFieldElement>;
|
||||||
autofillFieldElement.opid = "op-1";
|
autofillFieldElement.opid = "op-1";
|
||||||
autofillOverlayContentService["mostRecentlyFocusedField"] = autofillFieldElement;
|
autofillOverlayContentService["mostRecentlyFocusedField"] = autofillFieldElement;
|
||||||
@ -776,7 +776,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
});
|
});
|
||||||
const focusMostRecentOverlayFieldSpy = jest.spyOn(
|
const focusMostRecentOverlayFieldSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"focusMostRecentOverlayField"
|
"focusMostRecentOverlayField",
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayContentService["openAutofillOverlay"]({ isFocusingFieldElement: true });
|
autofillOverlayContentService["openAutofillOverlay"]({ isFocusingFieldElement: true });
|
||||||
@ -792,7 +792,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
});
|
});
|
||||||
const focusMostRecentOverlayFieldSpy = jest.spyOn(
|
const focusMostRecentOverlayFieldSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"focusMostRecentOverlayField"
|
"focusMostRecentOverlayField",
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayContentService["openAutofillOverlay"]({ isFocusingFieldElement: true });
|
autofillOverlayContentService["openAutofillOverlay"]({ isFocusingFieldElement: true });
|
||||||
@ -866,7 +866,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
describe("focusMostRecentOverlayField", () => {
|
describe("focusMostRecentOverlayField", () => {
|
||||||
it("focuses the most recently focused overlay field", () => {
|
it("focuses the most recently focused overlay field", () => {
|
||||||
const mostRecentlyFocusedField = document.createElement(
|
const mostRecentlyFocusedField = document.createElement(
|
||||||
"input"
|
"input",
|
||||||
) as ElementWithOpId<HTMLInputElement>;
|
) as ElementWithOpId<HTMLInputElement>;
|
||||||
autofillOverlayContentService["mostRecentlyFocusedField"] = mostRecentlyFocusedField;
|
autofillOverlayContentService["mostRecentlyFocusedField"] = mostRecentlyFocusedField;
|
||||||
jest.spyOn(mostRecentlyFocusedField, "focus");
|
jest.spyOn(mostRecentlyFocusedField, "focus");
|
||||||
@ -880,7 +880,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
describe("blurMostRecentOverlayField", () => {
|
describe("blurMostRecentOverlayField", () => {
|
||||||
it("removes focus from the most recently focused overlay field", () => {
|
it("removes focus from the most recently focused overlay field", () => {
|
||||||
const mostRecentlyFocusedField = document.createElement(
|
const mostRecentlyFocusedField = document.createElement(
|
||||||
"input"
|
"input",
|
||||||
) as ElementWithOpId<HTMLInputElement>;
|
) as ElementWithOpId<HTMLInputElement>;
|
||||||
autofillOverlayContentService["mostRecentlyFocusedField"] = mostRecentlyFocusedField;
|
autofillOverlayContentService["mostRecentlyFocusedField"] = mostRecentlyFocusedField;
|
||||||
jest.spyOn(mostRecentlyFocusedField, "blur");
|
jest.spyOn(mostRecentlyFocusedField, "blur");
|
||||||
@ -906,7 +906,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
document.body.innerHTML = `<div class="overlay-button"></div>`;
|
document.body.innerHTML = `<div class="overlay-button"></div>`;
|
||||||
autofillOverlayContentService["overlayButtonElement"] = document.querySelector(
|
autofillOverlayContentService["overlayButtonElement"] = document.querySelector(
|
||||||
".overlay-button"
|
".overlay-button",
|
||||||
) as HTMLElement;
|
) as HTMLElement;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -933,7 +933,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.spyOn(globalThis, "removeEventListener");
|
jest.spyOn(globalThis, "removeEventListener");
|
||||||
const handleOverlayRepositionEventSpy = jest.spyOn(
|
const handleOverlayRepositionEventSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"handleOverlayRepositionEvent"
|
"handleOverlayRepositionEvent",
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayContentService.removeAutofillOverlay();
|
autofillOverlayContentService.removeAutofillOverlay();
|
||||||
@ -943,11 +943,11 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
handleOverlayRepositionEventSpy,
|
handleOverlayRepositionEventSpy,
|
||||||
{
|
{
|
||||||
capture: true,
|
capture: true,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
expect(globalThis.removeEventListener).toHaveBeenCalledWith(
|
expect(globalThis.removeEventListener).toHaveBeenCalledWith(
|
||||||
EVENTS.RESIZE,
|
EVENTS.RESIZE,
|
||||||
handleOverlayRepositionEventSpy
|
handleOverlayRepositionEventSpy,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -956,7 +956,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
document.body.innerHTML = `<div class="overlay-list"></div>`;
|
document.body.innerHTML = `<div class="overlay-list"></div>`;
|
||||||
autofillOverlayContentService["overlayListElement"] = document.querySelector(
|
autofillOverlayContentService["overlayListElement"] = document.querySelector(
|
||||||
".overlay-list"
|
".overlay-list",
|
||||||
) as HTMLElement;
|
) as HTMLElement;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1011,10 +1011,10 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
</form>
|
</form>
|
||||||
`;
|
`;
|
||||||
const usernameField = document.getElementById(
|
const usernameField = document.getElementById(
|
||||||
"username-field"
|
"username-field",
|
||||||
) as ElementWithOpId<HTMLInputElement>;
|
) as ElementWithOpId<HTMLInputElement>;
|
||||||
const passwordField = document.getElementById(
|
const passwordField = document.getElementById(
|
||||||
"password-field"
|
"password-field",
|
||||||
) as ElementWithOpId<HTMLInputElement>;
|
) as ElementWithOpId<HTMLInputElement>;
|
||||||
usernameField.value = "test-username";
|
usernameField.value = "test-username";
|
||||||
passwordField.value = "test-password";
|
passwordField.value = "test-password";
|
||||||
@ -1054,11 +1054,11 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
<div class="next-focusable-element" tabindex="0"></div>
|
<div class="next-focusable-element" tabindex="0"></div>
|
||||||
`;
|
`;
|
||||||
autofillFieldElement = document.getElementById(
|
autofillFieldElement = document.getElementById(
|
||||||
"username-field"
|
"username-field",
|
||||||
) as ElementWithOpId<FormFieldElement>;
|
) as ElementWithOpId<FormFieldElement>;
|
||||||
autofillFieldElement.opid = "op-1";
|
autofillFieldElement.opid = "op-1";
|
||||||
previousFocusableElement = document.querySelector(
|
previousFocusableElement = document.querySelector(
|
||||||
".previous-focusable-element"
|
".previous-focusable-element",
|
||||||
) as HTMLElement;
|
) as HTMLElement;
|
||||||
nextFocusableElement = document.querySelector(".next-focusable-element") as HTMLElement;
|
nextFocusableElement = document.querySelector(".next-focusable-element") as HTMLElement;
|
||||||
autofillFieldFocusSpy = jest.spyOn(autofillFieldElement, "focus");
|
autofillFieldFocusSpy = jest.spyOn(autofillFieldElement, "focus");
|
||||||
@ -1099,7 +1099,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
const removeAutofillOverlaySpy = jest.spyOn(
|
const removeAutofillOverlaySpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"removeAutofillOverlay"
|
"removeAutofillOverlay",
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayContentService.redirectOverlayFocusOut(RedirectFocusDirection.Current);
|
autofillOverlayContentService.redirectOverlayFocusOut(RedirectFocusDirection.Current);
|
||||||
@ -1149,7 +1149,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
</form>
|
</form>
|
||||||
`;
|
`;
|
||||||
const usernameField = document.getElementById(
|
const usernameField = document.getElementById(
|
||||||
"username-field"
|
"username-field",
|
||||||
) as ElementWithOpId<HTMLInputElement>;
|
) as ElementWithOpId<HTMLInputElement>;
|
||||||
autofillOverlayContentService["mostRecentlyFocusedField"] = usernameField;
|
autofillOverlayContentService["mostRecentlyFocusedField"] = usernameField;
|
||||||
autofillOverlayContentService["setOverlayRepositionEventListeners"]();
|
autofillOverlayContentService["setOverlayRepositionEventListeners"]();
|
||||||
@ -1196,7 +1196,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
.mockReturnValue(false);
|
.mockReturnValue(false);
|
||||||
const removeAutofillOverlaySpy = jest.spyOn(
|
const removeAutofillOverlaySpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"removeAutofillOverlay"
|
"removeAutofillOverlay",
|
||||||
);
|
);
|
||||||
autofillOverlayContentService["mostRecentlyFocusedField"] = undefined;
|
autofillOverlayContentService["mostRecentlyFocusedField"] = undefined;
|
||||||
|
|
||||||
@ -1225,7 +1225,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
});
|
});
|
||||||
const clearUserInteractionEventTimeoutSpy = jest.spyOn(
|
const clearUserInteractionEventTimeoutSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"clearUserInteractionEventTimeout"
|
"clearUserInteractionEventTimeout",
|
||||||
);
|
);
|
||||||
|
|
||||||
globalThis.dispatchEvent(new Event(EVENTS.SCROLL));
|
globalThis.dispatchEvent(new Event(EVENTS.SCROLL));
|
||||||
@ -1255,7 +1255,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
});
|
});
|
||||||
const removeAutofillOverlaySpy = jest.spyOn(
|
const removeAutofillOverlaySpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"removeAutofillOverlay"
|
"removeAutofillOverlay",
|
||||||
);
|
);
|
||||||
|
|
||||||
globalThis.dispatchEvent(new Event(EVENTS.SCROLL));
|
globalThis.dispatchEvent(new Event(EVENTS.SCROLL));
|
||||||
@ -1277,7 +1277,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
</form>
|
</form>
|
||||||
`;
|
`;
|
||||||
usernameField = document.getElementById(
|
usernameField = document.getElementById(
|
||||||
"username-field"
|
"username-field",
|
||||||
) as ElementWithOpId<HTMLInputElement>;
|
) as ElementWithOpId<HTMLInputElement>;
|
||||||
usernameField.style.setProperty("display", "block", "important");
|
usernameField.style.setProperty("display", "block", "important");
|
||||||
jest.spyOn(usernameField, "removeAttribute");
|
jest.spyOn(usernameField, "removeAttribute");
|
||||||
@ -1285,7 +1285,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(
|
.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"isTriggeringExcessiveMutationObserverIterations"
|
"isTriggeringExcessiveMutationObserverIterations",
|
||||||
)
|
)
|
||||||
.mockReturnValue(false);
|
.mockReturnValue(false);
|
||||||
});
|
});
|
||||||
@ -1294,7 +1294,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(
|
.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"isTriggeringExcessiveMutationObserverIterations"
|
"isTriggeringExcessiveMutationObserverIterations",
|
||||||
)
|
)
|
||||||
.mockReturnValue(true);
|
.mockReturnValue(true);
|
||||||
|
|
||||||
@ -1344,7 +1344,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
expect(usernameField.style.setProperty).toHaveBeenCalledWith(
|
expect(usernameField.style.setProperty).toHaveBeenCalledWith(
|
||||||
"position",
|
"position",
|
||||||
"fixed",
|
"fixed",
|
||||||
"important"
|
"important",
|
||||||
);
|
);
|
||||||
expect(usernameField.style.setProperty).toHaveBeenCalledWith("display", "block", "important");
|
expect(usernameField.style.setProperty).toHaveBeenCalledWith("display", "block", "important");
|
||||||
});
|
});
|
||||||
@ -1368,7 +1368,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(
|
.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"isTriggeringExcessiveMutationObserverIterations"
|
"isTriggeringExcessiveMutationObserverIterations",
|
||||||
)
|
)
|
||||||
.mockReturnValue(false);
|
.mockReturnValue(false);
|
||||||
});
|
});
|
||||||
@ -1386,7 +1386,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(
|
.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"isTriggeringExcessiveMutationObserverIterations"
|
"isTriggeringExcessiveMutationObserverIterations",
|
||||||
)
|
)
|
||||||
.mockReturnValue(true);
|
.mockReturnValue(true);
|
||||||
|
|
||||||
@ -1418,7 +1418,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(globalThis.document.body.insertBefore).toHaveBeenCalledWith(
|
expect(globalThis.document.body.insertBefore).toHaveBeenCalledWith(
|
||||||
overlayButtonElement,
|
overlayButtonElement,
|
||||||
overlayListElement
|
overlayListElement,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1429,7 +1429,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(globalThis.document.body.insertBefore).toHaveBeenCalledWith(
|
expect(globalThis.document.body.insertBefore).toHaveBeenCalledWith(
|
||||||
overlayButtonElement,
|
overlayButtonElement,
|
||||||
overlayListElement
|
overlayListElement,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1441,7 +1441,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(globalThis.document.body.insertBefore).toHaveBeenCalledWith(
|
expect(globalThis.document.body.insertBefore).toHaveBeenCalledWith(
|
||||||
injectedElement,
|
injectedElement,
|
||||||
overlayButtonElement
|
overlayButtonElement,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1465,7 +1465,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(
|
.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"isTriggeringExcessiveMutationObserverIterations"
|
"isTriggeringExcessiveMutationObserverIterations",
|
||||||
)
|
)
|
||||||
.mockReturnValue(false);
|
.mockReturnValue(false);
|
||||||
});
|
});
|
||||||
@ -1485,7 +1485,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(
|
.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"isTriggeringExcessiveMutationObserverIterations"
|
"isTriggeringExcessiveMutationObserverIterations",
|
||||||
)
|
)
|
||||||
.mockReturnValue(true);
|
.mockReturnValue(true);
|
||||||
|
|
||||||
@ -1551,7 +1551,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
const clearTimeoutSpy = jest.spyOn(globalThis, "clearTimeout");
|
const clearTimeoutSpy = jest.spyOn(globalThis, "clearTimeout");
|
||||||
autofillOverlayContentService["mutationObserverIterationsResetTimeout"] = setTimeout(
|
autofillOverlayContentService["mutationObserverIterationsResetTimeout"] = setTimeout(
|
||||||
jest.fn(),
|
jest.fn(),
|
||||||
123
|
123,
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayContentService["isTriggeringExcessiveMutationObserverIterations"]();
|
autofillOverlayContentService["isTriggeringExcessiveMutationObserverIterations"]();
|
||||||
@ -1573,11 +1573,11 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillOverlayContentService["mutationObserverIterations"] = 101;
|
autofillOverlayContentService["mutationObserverIterations"] = 101;
|
||||||
const blurMostRecentOverlayFieldSpy = jest.spyOn(
|
const blurMostRecentOverlayFieldSpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"blurMostRecentOverlayField"
|
"blurMostRecentOverlayField",
|
||||||
);
|
);
|
||||||
const removeAutofillOverlaySpy = jest.spyOn(
|
const removeAutofillOverlaySpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"removeAutofillOverlay"
|
"removeAutofillOverlay",
|
||||||
);
|
);
|
||||||
|
|
||||||
autofillOverlayContentService["isTriggeringExcessiveMutationObserverIterations"]();
|
autofillOverlayContentService["isTriggeringExcessiveMutationObserverIterations"]();
|
||||||
|
@ -80,7 +80,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
*/
|
*/
|
||||||
async setupAutofillOverlayListenerOnField(
|
async setupAutofillOverlayListenerOnField(
|
||||||
formFieldElement: ElementWithOpId<FormFieldElement>,
|
formFieldElement: ElementWithOpId<FormFieldElement>,
|
||||||
autofillFieldData: AutofillField
|
autofillFieldData: AutofillField,
|
||||||
) {
|
) {
|
||||||
if (this.isIgnoredField(autofillFieldData)) {
|
if (this.isIgnoredField(autofillFieldData)) {
|
||||||
return;
|
return;
|
||||||
@ -241,7 +241,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
const focusedElementIndex = this.focusableElements.findIndex(
|
const focusedElementIndex = this.focusableElements.findIndex(
|
||||||
(element) => element === this.mostRecentlyFocusedField
|
(element) => element === this.mostRecentlyFocusedField,
|
||||||
);
|
);
|
||||||
|
|
||||||
const indexOffset = direction === RedirectFocusDirection.Previous ? -1 : 1;
|
const indexOffset = direction === RedirectFocusDirection.Previous ? -1 : 1;
|
||||||
@ -263,15 +263,15 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
formFieldElement.addEventListener(EVENTS.KEYUP, this.handleFormFieldKeyupEvent);
|
formFieldElement.addEventListener(EVENTS.KEYUP, this.handleFormFieldKeyupEvent);
|
||||||
formFieldElement.addEventListener(
|
formFieldElement.addEventListener(
|
||||||
EVENTS.INPUT,
|
EVENTS.INPUT,
|
||||||
this.handleFormFieldInputEvent(formFieldElement)
|
this.handleFormFieldInputEvent(formFieldElement),
|
||||||
);
|
);
|
||||||
formFieldElement.addEventListener(
|
formFieldElement.addEventListener(
|
||||||
EVENTS.CLICK,
|
EVENTS.CLICK,
|
||||||
this.handleFormFieldClickEvent(formFieldElement)
|
this.handleFormFieldClickEvent(formFieldElement),
|
||||||
);
|
);
|
||||||
formFieldElement.addEventListener(
|
formFieldElement.addEventListener(
|
||||||
EVENTS.FOCUS,
|
EVENTS.FOCUS,
|
||||||
this.handleFormFieldFocusEvent(formFieldElement)
|
this.handleFormFieldFocusEvent(formFieldElement),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
*/
|
*/
|
||||||
private getFormFieldHandlerMemoIndex(
|
private getFormFieldHandlerMemoIndex(
|
||||||
formFieldElement: ElementWithOpId<FormFieldElement>,
|
formFieldElement: ElementWithOpId<FormFieldElement>,
|
||||||
event: string
|
event: string,
|
||||||
) {
|
) {
|
||||||
return `${formFieldElement.opid}-${formFieldElement.id}-${event}-handler`;
|
return `${formFieldElement.opid}-${formFieldElement.id}-${event}-handler`;
|
||||||
}
|
}
|
||||||
@ -381,7 +381,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
private handleFormFieldInputEvent = (formFieldElement: ElementWithOpId<FormFieldElement>) => {
|
private handleFormFieldInputEvent = (formFieldElement: ElementWithOpId<FormFieldElement>) => {
|
||||||
return this.useEventHandlersMemo(
|
return this.useEventHandlersMemo(
|
||||||
() => this.triggerFormFieldInput(formFieldElement),
|
() => this.triggerFormFieldInput(formFieldElement),
|
||||||
this.getFormFieldHandlerMemoIndex(formFieldElement, EVENTS.INPUT)
|
this.getFormFieldHandlerMemoIndex(formFieldElement, EVENTS.INPUT),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -436,7 +436,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
private handleFormFieldClickEvent = (formFieldElement: ElementWithOpId<FormFieldElement>) => {
|
private handleFormFieldClickEvent = (formFieldElement: ElementWithOpId<FormFieldElement>) => {
|
||||||
return this.useEventHandlersMemo(
|
return this.useEventHandlersMemo(
|
||||||
() => this.triggerFormFieldClickedAction(formFieldElement),
|
() => this.triggerFormFieldClickedAction(formFieldElement),
|
||||||
this.getFormFieldHandlerMemoIndex(formFieldElement, EVENTS.CLICK)
|
this.getFormFieldHandlerMemoIndex(formFieldElement, EVENTS.CLICK),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -462,7 +462,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
private handleFormFieldFocusEvent = (formFieldElement: ElementWithOpId<FormFieldElement>) => {
|
private handleFormFieldFocusEvent = (formFieldElement: ElementWithOpId<FormFieldElement>) => {
|
||||||
return this.useEventHandlersMemo(
|
return this.useEventHandlersMemo(
|
||||||
() => this.triggerFormFieldFocusedAction(formFieldElement),
|
() => this.triggerFormFieldFocusedAction(formFieldElement),
|
||||||
this.getFormFieldHandlerMemoIndex(formFieldElement, EVENTS.FOCUS)
|
this.getFormFieldHandlerMemoIndex(formFieldElement, EVENTS.FOCUS),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -637,13 +637,12 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
* @param formFieldElement - The form field element that triggered the focus event.
|
* @param formFieldElement - The form field element that triggered the focus event.
|
||||||
*/
|
*/
|
||||||
private async updateMostRecentlyFocusedField(
|
private async updateMostRecentlyFocusedField(
|
||||||
formFieldElement: ElementWithOpId<FormFieldElement>
|
formFieldElement: ElementWithOpId<FormFieldElement>,
|
||||||
) {
|
) {
|
||||||
this.mostRecentlyFocusedField = formFieldElement;
|
this.mostRecentlyFocusedField = formFieldElement;
|
||||||
const { paddingRight, paddingLeft } = globalThis.getComputedStyle(formFieldElement);
|
const { paddingRight, paddingLeft } = globalThis.getComputedStyle(formFieldElement);
|
||||||
const { width, height, top, left } = await this.getMostRecentlyFocusedFieldRects(
|
const { width, height, top, left } =
|
||||||
formFieldElement
|
await this.getMostRecentlyFocusedFieldRects(formFieldElement);
|
||||||
);
|
|
||||||
this.focusedFieldData = {
|
this.focusedFieldData = {
|
||||||
focusedFieldStyles: { paddingRight, paddingLeft },
|
focusedFieldStyles: { paddingRight, paddingLeft },
|
||||||
focusedFieldRects: { width, height, top, left },
|
focusedFieldRects: { width, height, top, left },
|
||||||
@ -664,11 +663,10 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
* @param formFieldElement - The form field element that triggered the focus event.
|
* @param formFieldElement - The form field element that triggered the focus event.
|
||||||
*/
|
*/
|
||||||
private async getMostRecentlyFocusedFieldRects(
|
private async getMostRecentlyFocusedFieldRects(
|
||||||
formFieldElement: ElementWithOpId<FormFieldElement>
|
formFieldElement: ElementWithOpId<FormFieldElement>,
|
||||||
) {
|
) {
|
||||||
const focusedFieldRects = await this.getBoundingClientRectFromIntersectionObserver(
|
const focusedFieldRects =
|
||||||
formFieldElement
|
await this.getBoundingClientRectFromIntersectionObserver(formFieldElement);
|
||||||
);
|
|
||||||
if (focusedFieldRects) {
|
if (focusedFieldRects) {
|
||||||
return focusedFieldRects;
|
return focusedFieldRects;
|
||||||
}
|
}
|
||||||
@ -682,7 +680,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
* @param formFieldElement - The form field element that triggered the focus event.
|
* @param formFieldElement - The form field element that triggered the focus event.
|
||||||
*/
|
*/
|
||||||
private async getBoundingClientRectFromIntersectionObserver(
|
private async getBoundingClientRectFromIntersectionObserver(
|
||||||
formFieldElement: ElementWithOpId<FormFieldElement>
|
formFieldElement: ElementWithOpId<FormFieldElement>,
|
||||||
): Promise<DOMRectReadOnly | null> {
|
): Promise<DOMRectReadOnly | null> {
|
||||||
if (!("IntersectionObserver" in window) && !("IntersectionObserverEntry" in window)) {
|
if (!("IntersectionObserver" in window) && !("IntersectionObserverEntry" in window)) {
|
||||||
return null;
|
return null;
|
||||||
@ -703,7 +701,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
root: globalThis.document.body,
|
root: globalThis.document.body,
|
||||||
rootMargin: "0px",
|
rootMargin: "0px",
|
||||||
threshold: 0.9999, // Safari doesn't seem to function properly with a threshold of 1
|
threshold: 0.9999, // Safari doesn't seem to function properly with a threshold of 1
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
intersectionObserver.observe(formFieldElement);
|
intersectionObserver.observe(formFieldElement);
|
||||||
});
|
});
|
||||||
@ -896,15 +894,15 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
*/
|
*/
|
||||||
private setupMutationObserver = () => {
|
private setupMutationObserver = () => {
|
||||||
this.overlayElementsMutationObserver = new MutationObserver(
|
this.overlayElementsMutationObserver = new MutationObserver(
|
||||||
this.handleOverlayElementMutationObserverUpdate
|
this.handleOverlayElementMutationObserverUpdate,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.bodyElementMutationObserver = new MutationObserver(
|
this.bodyElementMutationObserver = new MutationObserver(
|
||||||
this.handleBodyElementMutationObserverUpdate
|
this.handleBodyElementMutationObserverUpdate,
|
||||||
);
|
);
|
||||||
|
|
||||||
const documentElementMutationObserver = new MutationObserver(
|
const documentElementMutationObserver = new MutationObserver(
|
||||||
this.handleDocumentElementMutationObserverUpdate
|
this.handleDocumentElementMutationObserverUpdate,
|
||||||
);
|
);
|
||||||
documentElementMutationObserver.observe(globalThis.document.documentElement, {
|
documentElementMutationObserver.observe(globalThis.document.documentElement, {
|
||||||
childList: true,
|
childList: true,
|
||||||
@ -1095,7 +1093,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
this.mutationObserverIterations++;
|
this.mutationObserverIterations++;
|
||||||
this.mutationObserverIterationsResetTimeout = setTimeout(
|
this.mutationObserverIterationsResetTimeout = setTimeout(
|
||||||
() => (this.mutationObserverIterations = 0),
|
() => (this.mutationObserverIterations = 0),
|
||||||
2000
|
2000,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.mutationObserverIterations > 100) {
|
if (this.mutationObserverIterations > 100) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -43,7 +43,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
private eventCollectionService: EventCollectionService,
|
private eventCollectionService: EventCollectionService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private settingsService: SettingsService,
|
private settingsService: SettingsService,
|
||||||
private userVerificationService: UserVerificationService
|
private userVerificationService: UserVerificationService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +59,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
async injectAutofillScripts(
|
async injectAutofillScripts(
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
autofillV2 = false,
|
autofillV2 = false,
|
||||||
autofillOverlay = false
|
autofillOverlay = false,
|
||||||
) {
|
) {
|
||||||
let mainAutofillScript = "autofill.js";
|
let mainAutofillScript = "autofill.js";
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
url: tab.url,
|
url: tab.url,
|
||||||
pageDetailsUrl: pd.details.url,
|
pageDetailsUrl: pd.details.url,
|
||||||
},
|
},
|
||||||
{ frameId: pd.frameId }
|
{ frameId: pd.frameId },
|
||||||
);
|
);
|
||||||
|
|
||||||
// Skip getting the TOTP code for clipboard in these cases
|
// Skip getting the TOTP code for clipboard in these cases
|
||||||
@ -245,7 +245,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (didAutofill) {
|
if (didAutofill) {
|
||||||
@ -270,7 +270,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
async doAutoFillOnTab(
|
async doAutoFillOnTab(
|
||||||
pageDetails: PageDetail[],
|
pageDetails: PageDetail[],
|
||||||
tab: chrome.tabs.Tab,
|
tab: chrome.tabs.Tab,
|
||||||
fromCommand: boolean
|
fromCommand: boolean,
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
let cipher: CipherView;
|
let cipher: CipherView;
|
||||||
if (fromCommand) {
|
if (fromCommand) {
|
||||||
@ -347,7 +347,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
async doAutoFillActiveTab(
|
async doAutoFillActiveTab(
|
||||||
pageDetails: PageDetail[],
|
pageDetails: PageDetail[],
|
||||||
fromCommand: boolean,
|
fromCommand: boolean,
|
||||||
cipherType?: CipherType
|
cipherType?: CipherType,
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
if (!pageDetails[0]?.details?.fields?.length) {
|
if (!pageDetails[0]?.details?.fields?.length) {
|
||||||
return null;
|
return null;
|
||||||
@ -410,7 +410,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
*/
|
*/
|
||||||
private async generateFillScript(
|
private async generateFillScript(
|
||||||
pageDetails: AutofillPageDetails,
|
pageDetails: AutofillPageDetails,
|
||||||
options: GenerateFillScriptOptions
|
options: GenerateFillScriptOptions,
|
||||||
): Promise<AutofillScript | null> {
|
): Promise<AutofillScript | null> {
|
||||||
if (!pageDetails || !options.cipher) {
|
if (!pageDetails || !options.cipher) {
|
||||||
return null;
|
return null;
|
||||||
@ -465,7 +465,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillScript,
|
fillScript,
|
||||||
pageDetails,
|
pageDetails,
|
||||||
filledFields,
|
filledFields,
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case CipherType.Card:
|
case CipherType.Card:
|
||||||
@ -476,7 +476,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillScript,
|
fillScript,
|
||||||
pageDetails,
|
pageDetails,
|
||||||
filledFields,
|
filledFields,
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -499,7 +499,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillScript: AutofillScript,
|
fillScript: AutofillScript,
|
||||||
pageDetails: AutofillPageDetails,
|
pageDetails: AutofillPageDetails,
|
||||||
filledFields: { [id: string]: AutofillField },
|
filledFields: { [id: string]: AutofillField },
|
||||||
options: GenerateFillScriptOptions
|
options: GenerateFillScriptOptions,
|
||||||
): Promise<AutofillScript | null> {
|
): Promise<AutofillScript | null> {
|
||||||
if (!options.cipher.login) {
|
if (!options.cipher.login) {
|
||||||
return null;
|
return null;
|
||||||
@ -522,7 +522,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
options.onlyEmptyFields,
|
options.onlyEmptyFields,
|
||||||
options.fillNewPassword
|
options.fillNewPassword,
|
||||||
);
|
);
|
||||||
if (!passwordFields.length && !options.onlyVisibleFields) {
|
if (!passwordFields.length && !options.onlyVisibleFields) {
|
||||||
// not able to find any viewable password fields. maybe there are some "hidden" ones?
|
// not able to find any viewable password fields. maybe there are some "hidden" ones?
|
||||||
@ -531,7 +531,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
options.onlyEmptyFields,
|
options.onlyEmptyFields,
|
||||||
options.fillNewPassword
|
options.fillNewPassword,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,7 +661,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
filledFields[t.opid] = t;
|
filledFields[t.opid] = t;
|
||||||
const totpValue = await this.totpService.getCode(login.totp);
|
const totpValue = await this.totpService.getCode(login.totp);
|
||||||
AutofillService.fillByOpid(fillScript, t, totpValue);
|
AutofillService.fillByOpid(fillScript, t, totpValue);
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,7 +682,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillScript: AutofillScript,
|
fillScript: AutofillScript,
|
||||||
pageDetails: AutofillPageDetails,
|
pageDetails: AutofillPageDetails,
|
||||||
filledFields: { [id: string]: AutofillField },
|
filledFields: { [id: string]: AutofillField },
|
||||||
options: GenerateFillScriptOptions
|
options: GenerateFillScriptOptions,
|
||||||
): AutofillScript | null {
|
): AutofillScript | null {
|
||||||
if (!options.cipher.card) {
|
if (!options.cipher.card) {
|
||||||
return null;
|
return null;
|
||||||
@ -713,7 +713,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
AutofillService.isFieldMatch(
|
AutofillService.isFieldMatch(
|
||||||
f[attr],
|
f[attr],
|
||||||
CreditCardAutoFillConstants.CardHolderFieldNames,
|
CreditCardAutoFillConstants.CardHolderFieldNames,
|
||||||
CreditCardAutoFillConstants.CardHolderFieldNameValues
|
CreditCardAutoFillConstants.CardHolderFieldNameValues,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
fillFields.cardholderName = f;
|
fillFields.cardholderName = f;
|
||||||
@ -723,7 +723,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
AutofillService.isFieldMatch(
|
AutofillService.isFieldMatch(
|
||||||
f[attr],
|
f[attr],
|
||||||
CreditCardAutoFillConstants.CardNumberFieldNames,
|
CreditCardAutoFillConstants.CardNumberFieldNames,
|
||||||
CreditCardAutoFillConstants.CardNumberFieldNameValues
|
CreditCardAutoFillConstants.CardNumberFieldNameValues,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
fillFields.number = f;
|
fillFields.number = f;
|
||||||
@ -733,7 +733,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
AutofillService.isFieldMatch(
|
AutofillService.isFieldMatch(
|
||||||
f[attr],
|
f[attr],
|
||||||
CreditCardAutoFillConstants.CardExpiryFieldNames,
|
CreditCardAutoFillConstants.CardExpiryFieldNames,
|
||||||
CreditCardAutoFillConstants.CardExpiryFieldNameValues
|
CreditCardAutoFillConstants.CardExpiryFieldNameValues,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
fillFields.exp = f;
|
fillFields.exp = f;
|
||||||
@ -879,7 +879,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||||
"/" +
|
"/" +
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i]
|
CreditCardAutoFillConstants.YearAbbrLong[i],
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullMonth + "/" + fullYear;
|
exp = fullMonth + "/" + fullYear;
|
||||||
@ -888,7 +888,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||||
"/" +
|
"/" +
|
||||||
CreditCardAutoFillConstants.YearAbbrShort[i]
|
CreditCardAutoFillConstants.YearAbbrShort[i],
|
||||||
) &&
|
) &&
|
||||||
partYear != null
|
partYear != null
|
||||||
) {
|
) {
|
||||||
@ -898,7 +898,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
||||||
"/" +
|
"/" +
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
CreditCardAutoFillConstants.MonthAbbr[i],
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullYear + "/" + fullMonth;
|
exp = fullYear + "/" + fullMonth;
|
||||||
@ -907,7 +907,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.YearAbbrShort[i] +
|
CreditCardAutoFillConstants.YearAbbrShort[i] +
|
||||||
"/" +
|
"/" +
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
CreditCardAutoFillConstants.MonthAbbr[i],
|
||||||
) &&
|
) &&
|
||||||
partYear != null
|
partYear != null
|
||||||
) {
|
) {
|
||||||
@ -917,7 +917,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||||
"-" +
|
"-" +
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i]
|
CreditCardAutoFillConstants.YearAbbrLong[i],
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullMonth + "-" + fullYear;
|
exp = fullMonth + "-" + fullYear;
|
||||||
@ -926,7 +926,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] +
|
CreditCardAutoFillConstants.MonthAbbr[i] +
|
||||||
"-" +
|
"-" +
|
||||||
CreditCardAutoFillConstants.YearAbbrShort[i]
|
CreditCardAutoFillConstants.YearAbbrShort[i],
|
||||||
) &&
|
) &&
|
||||||
partYear != null
|
partYear != null
|
||||||
) {
|
) {
|
||||||
@ -936,7 +936,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
CreditCardAutoFillConstants.YearAbbrLong[i] +
|
||||||
"-" +
|
"-" +
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
CreditCardAutoFillConstants.MonthAbbr[i],
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullYear + "-" + fullMonth;
|
exp = fullYear + "-" + fullMonth;
|
||||||
@ -945,7 +945,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.YearAbbrShort[i] +
|
CreditCardAutoFillConstants.YearAbbrShort[i] +
|
||||||
"-" +
|
"-" +
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i]
|
CreditCardAutoFillConstants.MonthAbbr[i],
|
||||||
) &&
|
) &&
|
||||||
partYear != null
|
partYear != null
|
||||||
) {
|
) {
|
||||||
@ -953,14 +953,14 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.YearAbbrLong[i] + CreditCardAutoFillConstants.MonthAbbr[i]
|
CreditCardAutoFillConstants.YearAbbrLong[i] + CreditCardAutoFillConstants.MonthAbbr[i],
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullYear + fullMonth;
|
exp = fullYear + fullMonth;
|
||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.YearAbbrShort[i] + CreditCardAutoFillConstants.MonthAbbr[i]
|
CreditCardAutoFillConstants.YearAbbrShort[i] + CreditCardAutoFillConstants.MonthAbbr[i],
|
||||||
) &&
|
) &&
|
||||||
partYear != null
|
partYear != null
|
||||||
) {
|
) {
|
||||||
@ -968,14 +968,14 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrLong[i]
|
CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrLong[i],
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
exp = fullMonth + fullYear;
|
exp = fullMonth + fullYear;
|
||||||
} else if (
|
} else if (
|
||||||
this.fieldAttrsContain(
|
this.fieldAttrsContain(
|
||||||
fillFields.exp,
|
fillFields.exp,
|
||||||
CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrShort[i]
|
CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrShort[i],
|
||||||
) &&
|
) &&
|
||||||
partYear != null
|
partYear != null
|
||||||
) {
|
) {
|
||||||
@ -1018,7 +1018,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
const matchesUri = options.cipher.login.matchesUri(
|
const matchesUri = options.cipher.login.matchesUri(
|
||||||
pageUrl,
|
pageUrl,
|
||||||
equivalentDomains,
|
equivalentDomains,
|
||||||
options.defaultUriMatch
|
options.defaultUriMatch,
|
||||||
);
|
);
|
||||||
return !matchesUri;
|
return !matchesUri;
|
||||||
}
|
}
|
||||||
@ -1064,7 +1064,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillScript: AutofillScript,
|
fillScript: AutofillScript,
|
||||||
pageDetails: AutofillPageDetails,
|
pageDetails: AutofillPageDetails,
|
||||||
filledFields: { [id: string]: AutofillField },
|
filledFields: { [id: string]: AutofillField },
|
||||||
options: GenerateFillScriptOptions
|
options: GenerateFillScriptOptions,
|
||||||
): AutofillScript {
|
): AutofillScript {
|
||||||
if (!options.cipher.identity) {
|
if (!options.cipher.identity) {
|
||||||
return null;
|
return null;
|
||||||
@ -1095,7 +1095,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
AutofillService.isFieldMatch(
|
AutofillService.isFieldMatch(
|
||||||
f[attr],
|
f[attr],
|
||||||
IdentityAutoFillConstants.FullNameFieldNames,
|
IdentityAutoFillConstants.FullNameFieldNames,
|
||||||
IdentityAutoFillConstants.FullNameFieldNameValues
|
IdentityAutoFillConstants.FullNameFieldNameValues,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
fillFields.name = f;
|
fillFields.name = f;
|
||||||
@ -1135,7 +1135,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
AutofillService.isFieldMatch(
|
AutofillService.isFieldMatch(
|
||||||
f[attr],
|
f[attr],
|
||||||
IdentityAutoFillConstants.AddressFieldNames,
|
IdentityAutoFillConstants.AddressFieldNames,
|
||||||
IdentityAutoFillConstants.AddressFieldNameValues
|
IdentityAutoFillConstants.AddressFieldNameValues,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
fillFields.address = f;
|
fillFields.address = f;
|
||||||
@ -1320,7 +1320,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
private static isFieldMatch(
|
private static isFieldMatch(
|
||||||
value: string,
|
value: string,
|
||||||
options: string[],
|
options: string[],
|
||||||
containsOptions?: string[]
|
containsOptions?: string[],
|
||||||
): boolean {
|
): boolean {
|
||||||
value = value
|
value = value
|
||||||
.trim()
|
.trim()
|
||||||
@ -1355,14 +1355,14 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillFields: { [id: string]: AutofillField },
|
fillFields: { [id: string]: AutofillField },
|
||||||
filledFields: { [id: string]: AutofillField },
|
filledFields: { [id: string]: AutofillField },
|
||||||
dataProp: string,
|
dataProp: string,
|
||||||
fieldProp?: string
|
fieldProp?: string,
|
||||||
) {
|
) {
|
||||||
fieldProp = fieldProp || dataProp;
|
fieldProp = fieldProp || dataProp;
|
||||||
this.makeScriptActionWithValue(
|
this.makeScriptActionWithValue(
|
||||||
fillScript,
|
fillScript,
|
||||||
cipherData[dataProp],
|
cipherData[dataProp],
|
||||||
fillFields[fieldProp],
|
fillFields[fieldProp],
|
||||||
filledFields
|
filledFields,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1381,7 +1381,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
fillScript: AutofillScript,
|
fillScript: AutofillScript,
|
||||||
dataValue: any,
|
dataValue: any,
|
||||||
field: AutofillField,
|
field: AutofillField,
|
||||||
filledFields: { [id: string]: AutofillField }
|
filledFields: { [id: string]: AutofillField },
|
||||||
) {
|
) {
|
||||||
let doFill = false;
|
let doFill = false;
|
||||||
if (AutofillService.hasValue(dataValue) && field) {
|
if (AutofillService.hasValue(dataValue) && field) {
|
||||||
@ -1431,7 +1431,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
canBeHidden: boolean,
|
canBeHidden: boolean,
|
||||||
canBeReadOnly: boolean,
|
canBeReadOnly: boolean,
|
||||||
mustBeEmpty: boolean,
|
mustBeEmpty: boolean,
|
||||||
fillNewPassword: boolean
|
fillNewPassword: boolean,
|
||||||
) {
|
) {
|
||||||
const arr: AutofillField[] = [];
|
const arr: AutofillField[] = [];
|
||||||
pageDetails.fields.forEach((f) => {
|
pageDetails.fields.forEach((f) => {
|
||||||
@ -1503,7 +1503,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
passwordField: AutofillField,
|
passwordField: AutofillField,
|
||||||
canBeHidden: boolean,
|
canBeHidden: boolean,
|
||||||
canBeReadOnly: boolean,
|
canBeReadOnly: boolean,
|
||||||
withoutForm: boolean
|
withoutForm: boolean,
|
||||||
): AutofillField | null {
|
): AutofillField | null {
|
||||||
let usernameField: AutofillField = null;
|
let usernameField: AutofillField = null;
|
||||||
for (let i = 0; i < pageDetails.fields.length; i++) {
|
for (let i = 0; i < pageDetails.fields.length; i++) {
|
||||||
@ -1551,7 +1551,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
passwordField: AutofillField,
|
passwordField: AutofillField,
|
||||||
canBeHidden: boolean,
|
canBeHidden: boolean,
|
||||||
canBeReadOnly: boolean,
|
canBeReadOnly: boolean,
|
||||||
withoutForm: boolean
|
withoutForm: boolean,
|
||||||
): AutofillField | null {
|
): AutofillField | null {
|
||||||
let totpField: AutofillField = null;
|
let totpField: AutofillField = null;
|
||||||
for (let i = 0; i < pageDetails.fields.length; i++) {
|
for (let i = 0; i < pageDetails.fields.length; i++) {
|
||||||
@ -1659,7 +1659,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
property: string,
|
property: string,
|
||||||
name: string,
|
name: string,
|
||||||
prefix: string,
|
prefix: string,
|
||||||
separator = "="
|
separator = "=",
|
||||||
): boolean {
|
): boolean {
|
||||||
if (name.indexOf(prefix + separator) === 0) {
|
if (name.indexOf(prefix + separator) === 0) {
|
||||||
const sepIndex = name.indexOf(separator);
|
const sepIndex = name.indexOf(separator);
|
||||||
@ -1806,7 +1806,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
|||||||
*/
|
*/
|
||||||
static setFillScriptForFocus(
|
static setFillScriptForFocus(
|
||||||
filledFields: { [id: string]: AutofillField },
|
filledFields: { [id: string]: AutofillField },
|
||||||
fillScript: AutofillScript
|
fillScript: AutofillScript,
|
||||||
): AutofillScript {
|
): AutofillScript {
|
||||||
let lastField: AutofillField = null;
|
let lastField: AutofillField = null;
|
||||||
let lastPasswordField: AutofillField = null;
|
let lastPasswordField: AutofillField = null;
|
||||||
|
@ -31,7 +31,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
document.body.innerHTML = mockLoginForm;
|
document.body.innerHTML = mockLoginForm;
|
||||||
collectAutofillContentService = new CollectAutofillContentService(
|
collectAutofillContentService = new CollectAutofillContentService(
|
||||||
domElementVisibilityService,
|
domElementVisibilityService,
|
||||||
autofillOverlayContentService
|
autofillOverlayContentService,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
expect(collectAutofillContentService["getFormattedPageDetails"]).toHaveBeenCalledWith({}, []);
|
expect(collectAutofillContentService["getFormattedPageDetails"]).toHaveBeenCalledWith({}, []);
|
||||||
expect(
|
expect(
|
||||||
collectAutofillContentService["queryAutofillFormAndFieldElements"]
|
collectAutofillContentService["queryAutofillFormAndFieldElements"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(collectAutofillContentService["buildAutofillFormsData"]).not.toHaveBeenCalled();
|
expect(collectAutofillContentService["buildAutofillFormsData"]).not.toHaveBeenCalled();
|
||||||
expect(collectAutofillContentService["buildAutofillFieldsData"]).not.toHaveBeenCalled();
|
expect(collectAutofillContentService["buildAutofillFieldsData"]).not.toHaveBeenCalled();
|
||||||
@ -102,7 +102,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
htmlMethod: formMethod,
|
htmlMethod: formMethod,
|
||||||
};
|
};
|
||||||
const fieldElement = document.getElementById(
|
const fieldElement = document.getElementById(
|
||||||
usernameFieldId
|
usernameFieldId,
|
||||||
) as ElementWithOpId<FormFieldElement>;
|
) as ElementWithOpId<FormFieldElement>;
|
||||||
const autofillField: AutofillField = {
|
const autofillField: AutofillField = {
|
||||||
opid: "__0",
|
opid: "__0",
|
||||||
@ -156,7 +156,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
expect(collectAutofillContentService["getFormattedAutofillFormsData"]).toHaveBeenCalled();
|
expect(collectAutofillContentService["getFormattedAutofillFormsData"]).toHaveBeenCalled();
|
||||||
expect(collectAutofillContentService["getFormattedAutofillFieldsData"]).toHaveBeenCalled();
|
expect(collectAutofillContentService["getFormattedAutofillFieldsData"]).toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
collectAutofillContentService["queryAutofillFormAndFieldElements"]
|
collectAutofillContentService["queryAutofillFormAndFieldElements"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(collectAutofillContentService["buildAutofillFormsData"]).not.toHaveBeenCalled();
|
expect(collectAutofillContentService["buildAutofillFormsData"]).not.toHaveBeenCalled();
|
||||||
expect(collectAutofillContentService["buildAutofillFieldsData"]).not.toHaveBeenCalled();
|
expect(collectAutofillContentService["buildAutofillFieldsData"]).not.toHaveBeenCalled();
|
||||||
@ -294,7 +294,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
it("returns the element with the opid property value matching the passed value", () => {
|
it("returns the element with the opid property value matching the passed value", () => {
|
||||||
const textInput = document.querySelector('input[type="text"]') as FormElementWithAttribute;
|
const textInput = document.querySelector('input[type="text"]') as FormElementWithAttribute;
|
||||||
const passwordInput = document.querySelector(
|
const passwordInput = document.querySelector(
|
||||||
'input[type="password"]'
|
'input[type="password"]',
|
||||||
) as FormElementWithAttribute;
|
) as FormElementWithAttribute;
|
||||||
textInput.opid = "__0";
|
textInput.opid = "__0";
|
||||||
passwordInput.opid = "__1";
|
passwordInput.opid = "__1";
|
||||||
@ -311,7 +311,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
it("returns the first of the element with an `opid` value matching the passed value and emits a console warning if multiple fields contain the same `opid`", () => {
|
it("returns the first of the element with an `opid` value matching the passed value and emits a console warning if multiple fields contain the same `opid`", () => {
|
||||||
const textInput = document.querySelector('input[type="text"]') as FormElementWithAttribute;
|
const textInput = document.querySelector('input[type="text"]') as FormElementWithAttribute;
|
||||||
const passwordInput = document.querySelector(
|
const passwordInput = document.querySelector(
|
||||||
'input[type="password"]'
|
'input[type="password"]',
|
||||||
) as FormElementWithAttribute;
|
) as FormElementWithAttribute;
|
||||||
jest.spyOn(console, "warn").mockImplementationOnce(jest.fn());
|
jest.spyOn(console, "warn").mockImplementationOnce(jest.fn());
|
||||||
textInput.opid = "__1";
|
textInput.opid = "__1";
|
||||||
@ -330,7 +330,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
it("returns the element at the index position (parsed from passed opid) of all AutofillField elements when the passed opid value cannot be found", () => {
|
it("returns the element at the index position (parsed from passed opid) of all AutofillField elements when the passed opid value cannot be found", () => {
|
||||||
const textInput = document.querySelector('input[type="text"]') as FormElementWithAttribute;
|
const textInput = document.querySelector('input[type="text"]') as FormElementWithAttribute;
|
||||||
const passwordInput = document.querySelector(
|
const passwordInput = document.querySelector(
|
||||||
'input[type="password"]'
|
'input[type="password"]',
|
||||||
) as FormElementWithAttribute;
|
) as FormElementWithAttribute;
|
||||||
textInput.opid = undefined;
|
textInput.opid = undefined;
|
||||||
passwordInput.opid = "__1";
|
passwordInput.opid = "__1";
|
||||||
@ -387,7 +387,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
jest.spyOn(collectAutofillContentService as any, "getFormActionAttribute");
|
jest.spyOn(collectAutofillContentService as any, "getFormActionAttribute");
|
||||||
|
|
||||||
const autofillFormsData = collectAutofillContentService["buildAutofillFormsData"](
|
const autofillFormsData = collectAutofillContentService["buildAutofillFormsData"](
|
||||||
formElements as Node[]
|
formElements as Node[],
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(collectAutofillContentService["getFormActionAttribute"]).not.toHaveBeenCalled();
|
expect(collectAutofillContentService["getFormActionAttribute"]).not.toHaveBeenCalled();
|
||||||
@ -452,13 +452,13 @@ describe("CollectAutofillContentService", () => {
|
|||||||
const { formFieldElements } =
|
const { formFieldElements } =
|
||||||
collectAutofillContentService["queryAutofillFormAndFieldElements"]();
|
collectAutofillContentService["queryAutofillFormAndFieldElements"]();
|
||||||
const autofillFieldsPromise = collectAutofillContentService["buildAutofillFieldsData"](
|
const autofillFieldsPromise = collectAutofillContentService["buildAutofillFieldsData"](
|
||||||
formFieldElements as FormFieldElement[]
|
formFieldElements as FormFieldElement[],
|
||||||
);
|
);
|
||||||
const autofillFieldsData = await Promise.resolve(autofillFieldsPromise);
|
const autofillFieldsData = await Promise.resolve(autofillFieldsPromise);
|
||||||
|
|
||||||
expect(collectAutofillContentService["getAutofillFieldElements"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["getAutofillFieldElements"]).toHaveBeenCalledWith(
|
||||||
100,
|
100,
|
||||||
formFieldElements
|
formFieldElements,
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["buildAutofillFieldItem"]).toHaveBeenCalledTimes(2);
|
expect(collectAutofillContentService["buildAutofillFieldItem"]).toHaveBeenCalledTimes(2);
|
||||||
expect(autofillFieldsPromise).toBeInstanceOf(Promise);
|
expect(autofillFieldsPromise).toBeInstanceOf(Promise);
|
||||||
@ -595,12 +595,12 @@ describe("CollectAutofillContentService", () => {
|
|||||||
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
spanElement,
|
spanElement,
|
||||||
"type"
|
"type",
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
||||||
2,
|
2,
|
||||||
textAreaInput,
|
textAreaInput,
|
||||||
"type"
|
"type",
|
||||||
);
|
);
|
||||||
expect(formElements).toEqual([spanElement, textAreaInput]);
|
expect(formElements).toEqual([spanElement, textAreaInput]);
|
||||||
});
|
});
|
||||||
@ -799,7 +799,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
viewable: true,
|
viewable: true,
|
||||||
};
|
};
|
||||||
const usernameInput = document.getElementById(
|
const usernameInput = document.getElementById(
|
||||||
usernameField.id
|
usernameField.id,
|
||||||
) as ElementWithOpId<FillableFormFieldElement>;
|
) as ElementWithOpId<FillableFormFieldElement>;
|
||||||
usernameInput.opid = "__0";
|
usernameInput.opid = "__0";
|
||||||
collectAutofillContentService["autofillFieldElements"].set(usernameInput, existingFieldData);
|
collectAutofillContentService["autofillFieldElements"].set(usernameInput, existingFieldData);
|
||||||
@ -812,12 +812,12 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
const autofillFieldItem = await collectAutofillContentService["buildAutofillFieldItem"](
|
const autofillFieldItem = await collectAutofillContentService["buildAutofillFieldItem"](
|
||||||
usernameInput,
|
usernameInput,
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(collectAutofillContentService["getAutofillFieldMaxLength"]).not.toHaveBeenCalled();
|
expect(collectAutofillContentService["getAutofillFieldMaxLength"]).not.toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
collectAutofillContentService["domElementVisibilityService"].isFormFieldViewable
|
collectAutofillContentService["domElementVisibilityService"].isFormFieldViewable,
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(collectAutofillContentService["getPropertyOrAttribute"]).not.toHaveBeenCalled();
|
expect(collectAutofillContentService["getPropertyOrAttribute"]).not.toHaveBeenCalled();
|
||||||
expect(collectAutofillContentService["getElementValue"]).not.toHaveBeenCalled();
|
expect(collectAutofillContentService["getElementValue"]).not.toHaveBeenCalled();
|
||||||
@ -834,7 +834,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
<span id="${spanElementId}" class="${spanElementClasses}" tabindex="${spanElementTabIndex}" title="${spanElementTitle}">Span Element</span>
|
<span id="${spanElementId}" class="${spanElementClasses}" tabindex="${spanElementTabIndex}" title="${spanElementTitle}">Span Element</span>
|
||||||
`;
|
`;
|
||||||
const spanElement = document.getElementById(
|
const spanElement = document.getElementById(
|
||||||
spanElementId
|
spanElementId,
|
||||||
) as ElementWithOpId<FormFieldElement>;
|
) as ElementWithOpId<FormFieldElement>;
|
||||||
jest.spyOn(collectAutofillContentService as any, "getAutofillFieldMaxLength");
|
jest.spyOn(collectAutofillContentService as any, "getAutofillFieldMaxLength");
|
||||||
jest
|
jest
|
||||||
@ -845,44 +845,44 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
const autofillFieldItem = await collectAutofillContentService["buildAutofillFieldItem"](
|
const autofillFieldItem = await collectAutofillContentService["buildAutofillFieldItem"](
|
||||||
spanElement,
|
spanElement,
|
||||||
index
|
index,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(collectAutofillContentService["getAutofillFieldMaxLength"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["getAutofillFieldMaxLength"]).toHaveBeenCalledWith(
|
||||||
spanElement
|
spanElement,
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
collectAutofillContentService["domElementVisibilityService"].isFormFieldViewable
|
collectAutofillContentService["domElementVisibilityService"].isFormFieldViewable,
|
||||||
).toHaveBeenCalledWith(spanElement);
|
).toHaveBeenCalledWith(spanElement);
|
||||||
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
spanElement,
|
spanElement,
|
||||||
"id"
|
"id",
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
||||||
2,
|
2,
|
||||||
spanElement,
|
spanElement,
|
||||||
"name"
|
"name",
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
||||||
3,
|
3,
|
||||||
spanElement,
|
spanElement,
|
||||||
"class"
|
"class",
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
||||||
4,
|
4,
|
||||||
spanElement,
|
spanElement,
|
||||||
"tabindex"
|
"tabindex",
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
||||||
5,
|
5,
|
||||||
spanElement,
|
spanElement,
|
||||||
"title"
|
"title",
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
expect(collectAutofillContentService["getPropertyOrAttribute"]).toHaveBeenNthCalledWith(
|
||||||
6,
|
6,
|
||||||
spanElement,
|
spanElement,
|
||||||
"tagName"
|
"tagName",
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["getElementValue"]).not.toHaveBeenCalled();
|
expect(collectAutofillContentService["getElementValue"]).not.toHaveBeenCalled();
|
||||||
expect(autofillFieldItem).toEqual({
|
expect(autofillFieldItem).toEqual({
|
||||||
@ -942,7 +942,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
const formElement = document.querySelector("form");
|
const formElement = document.querySelector("form");
|
||||||
formElement.opid = "form-opid";
|
formElement.opid = "form-opid";
|
||||||
const usernameInput = document.getElementById(
|
const usernameInput = document.getElementById(
|
||||||
usernameField.id
|
usernameField.id,
|
||||||
) as ElementWithOpId<FillableFormFieldElement>;
|
) as ElementWithOpId<FillableFormFieldElement>;
|
||||||
jest.spyOn(collectAutofillContentService as any, "getAutofillFieldMaxLength");
|
jest.spyOn(collectAutofillContentService as any, "getAutofillFieldMaxLength");
|
||||||
jest
|
jest
|
||||||
@ -953,7 +953,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
const autofillFieldItem = await collectAutofillContentService["buildAutofillFieldItem"](
|
const autofillFieldItem = await collectAutofillContentService["buildAutofillFieldItem"](
|
||||||
usernameInput,
|
usernameInput,
|
||||||
index
|
index,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldItem).toEqual({
|
expect(autofillFieldItem).toEqual({
|
||||||
@ -1027,7 +1027,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
const formElement = document.querySelector("form");
|
const formElement = document.querySelector("form");
|
||||||
formElement.opid = "form-opid";
|
formElement.opid = "form-opid";
|
||||||
const hiddenInput = document.getElementById(
|
const hiddenInput = document.getElementById(
|
||||||
hiddenField.id
|
hiddenField.id,
|
||||||
) as ElementWithOpId<FillableFormFieldElement>;
|
) as ElementWithOpId<FillableFormFieldElement>;
|
||||||
jest.spyOn(collectAutofillContentService as any, "getAutofillFieldMaxLength");
|
jest.spyOn(collectAutofillContentService as any, "getAutofillFieldMaxLength");
|
||||||
jest
|
jest
|
||||||
@ -1038,7 +1038,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
const autofillFieldItem = await collectAutofillContentService["buildAutofillFieldItem"](
|
const autofillFieldItem = await collectAutofillContentService["buildAutofillFieldItem"](
|
||||||
hiddenInput,
|
hiddenInput,
|
||||||
index
|
index,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(autofillFieldItem).toEqual({
|
expect(autofillFieldItem).toEqual({
|
||||||
@ -1086,7 +1086,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
const labelTag = collectAutofillContentService["createAutofillFieldLabelTag"](element);
|
const labelTag = collectAutofillContentService["createAutofillFieldLabelTag"](element);
|
||||||
|
|
||||||
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
||||||
new Set(element.labels)
|
new Set(element.labels),
|
||||||
);
|
);
|
||||||
expect(document.querySelectorAll).not.toHaveBeenCalled();
|
expect(document.querySelectorAll).not.toHaveBeenCalled();
|
||||||
expect(labelTag).toEqual("Username");
|
expect(labelTag).toEqual("Username");
|
||||||
@ -1104,7 +1104,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
expect(document.querySelectorAll).toHaveBeenCalledWith(`label[for="${element.id}"]`);
|
expect(document.querySelectorAll).toHaveBeenCalledWith(`label[for="${element.id}"]`);
|
||||||
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
||||||
new Set([elementLabel])
|
new Set([elementLabel]),
|
||||||
);
|
);
|
||||||
expect(labelTag).toEqual("Country");
|
expect(labelTag).toEqual("Country");
|
||||||
});
|
});
|
||||||
@ -1122,7 +1122,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
expect(document.querySelectorAll).not.toHaveBeenCalledWith(`label[for="${element.id}"]`);
|
expect(document.querySelectorAll).not.toHaveBeenCalledWith(`label[for="${element.id}"]`);
|
||||||
expect(document.querySelectorAll).toHaveBeenCalledWith(`label[for="${element.name}"]`);
|
expect(document.querySelectorAll).toHaveBeenCalledWith(`label[for="${element.name}"]`);
|
||||||
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
||||||
new Set([elementLabel])
|
new Set([elementLabel]),
|
||||||
);
|
);
|
||||||
expect(labelTag).toEqual("Country");
|
expect(labelTag).toEqual("Country");
|
||||||
});
|
});
|
||||||
@ -1139,10 +1139,10 @@ describe("CollectAutofillContentService", () => {
|
|||||||
const labelTag = collectAutofillContentService["createAutofillFieldLabelTag"](element);
|
const labelTag = collectAutofillContentService["createAutofillFieldLabelTag"](element);
|
||||||
|
|
||||||
expect(document.querySelectorAll).toHaveBeenCalledWith(
|
expect(document.querySelectorAll).toHaveBeenCalledWith(
|
||||||
`label[for="${element.id}"], label[for="${element.name}"]`
|
`label[for="${element.id}"], label[for="${element.name}"]`,
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
||||||
new Set([elementLabel])
|
new Set([elementLabel]),
|
||||||
);
|
);
|
||||||
expect(labelTag).toEqual("Country");
|
expect(labelTag).toEqual("Country");
|
||||||
});
|
});
|
||||||
@ -1158,7 +1158,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
const labelTag = collectAutofillContentService["createAutofillFieldLabelTag"](element);
|
const labelTag = collectAutofillContentService["createAutofillFieldLabelTag"](element);
|
||||||
|
|
||||||
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
||||||
new Set([elementLabel])
|
new Set([elementLabel]),
|
||||||
);
|
);
|
||||||
expect(labelTag).toEqual("Username");
|
expect(labelTag).toEqual("Username");
|
||||||
});
|
});
|
||||||
@ -1178,7 +1178,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
const labelTag = collectAutofillContentService["createAutofillFieldLabelTag"](element);
|
const labelTag = collectAutofillContentService["createAutofillFieldLabelTag"](element);
|
||||||
|
|
||||||
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["createLabelElementsTag"]).toHaveBeenCalledWith(
|
||||||
new Set([elementLabel])
|
new Set([elementLabel]),
|
||||||
);
|
);
|
||||||
expect(labelTag).toEqual("Username");
|
expect(labelTag).toEqual("Username");
|
||||||
});
|
});
|
||||||
@ -1275,10 +1275,10 @@ describe("CollectAutofillContentService", () => {
|
|||||||
const labelTag = collectAutofillContentService["createLabelElementsTag"](new Set(labels));
|
const labelTag = collectAutofillContentService["createLabelElementsTag"](new Set(labels));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
collectAutofillContentService["trimAndRemoveNonPrintableText"]
|
collectAutofillContentService["trimAndRemoveNonPrintableText"],
|
||||||
).toHaveBeenNthCalledWith(1, firstLabelText);
|
).toHaveBeenNthCalledWith(1, firstLabelText);
|
||||||
expect(
|
expect(
|
||||||
collectAutofillContentService["trimAndRemoveNonPrintableText"]
|
collectAutofillContentService["trimAndRemoveNonPrintableText"],
|
||||||
).toHaveBeenNthCalledWith(2, secondLabelText);
|
).toHaveBeenNthCalledWith(2, secondLabelText);
|
||||||
expect(labelTag).toEqual(`${firstLabelText}${secondLabelText}`);
|
expect(labelTag).toEqual(`${firstLabelText}${secondLabelText}`);
|
||||||
});
|
});
|
||||||
@ -1406,7 +1406,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
</table>
|
</table>
|
||||||
`;
|
`;
|
||||||
const targetTableCellInput = document.querySelector(
|
const targetTableCellInput = document.querySelector(
|
||||||
'input[name="password"]'
|
'input[name="password"]',
|
||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
|
|
||||||
const targetTableCellLabel =
|
const targetTableCellLabel =
|
||||||
@ -1433,7 +1433,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
</table>
|
</table>
|
||||||
`;
|
`;
|
||||||
const targetTableCellInput = document.querySelector(
|
const targetTableCellInput = document.querySelector(
|
||||||
'input[name="auth-code"]'
|
'input[name="auth-code"]',
|
||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
|
|
||||||
const targetTableCellLabel =
|
const targetTableCellLabel =
|
||||||
@ -1455,7 +1455,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
</table>
|
</table>
|
||||||
`;
|
`;
|
||||||
const targetTableCellInput = document.querySelector(
|
const targetTableCellInput = document.querySelector(
|
||||||
'input[name="password"]'
|
'input[name="password"]',
|
||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
|
|
||||||
const targetTableCellLabel =
|
const targetTableCellLabel =
|
||||||
@ -1482,7 +1482,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
</table>
|
</table>
|
||||||
`;
|
`;
|
||||||
const targetTableCellInput = document.querySelector(
|
const targetTableCellInput = document.querySelector(
|
||||||
'input[name="password"]'
|
'input[name="password"]',
|
||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
|
|
||||||
const targetTableCellLabel =
|
const targetTableCellLabel =
|
||||||
@ -1508,7 +1508,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
</table>
|
</table>
|
||||||
`;
|
`;
|
||||||
const targetTableCellInput = document.querySelector(
|
const targetTableCellInput = document.querySelector(
|
||||||
'input[name="auth-code"]'
|
'input[name="auth-code"]',
|
||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
|
|
||||||
const targetTableCellLabel =
|
const targetTableCellLabel =
|
||||||
@ -1573,7 +1573,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
const element = document.querySelector("#username-id");
|
const element = document.querySelector("#username-id");
|
||||||
const textNode = element.previousSibling;
|
const textNode = element.previousSibling;
|
||||||
const parsedTextContent = collectAutofillContentService["trimAndRemoveNonPrintableText"](
|
const parsedTextContent = collectAutofillContentService["trimAndRemoveNonPrintableText"](
|
||||||
textNode.nodeValue
|
textNode.nodeValue,
|
||||||
);
|
);
|
||||||
jest.spyOn(collectAutofillContentService as any, "trimAndRemoveNonPrintableText");
|
jest.spyOn(collectAutofillContentService as any, "trimAndRemoveNonPrintableText");
|
||||||
|
|
||||||
@ -1581,7 +1581,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
expect(textNode.nodeType).toEqual(Node.TEXT_NODE);
|
expect(textNode.nodeType).toEqual(Node.TEXT_NODE);
|
||||||
expect(collectAutofillContentService["trimAndRemoveNonPrintableText"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["trimAndRemoveNonPrintableText"]).toHaveBeenCalledWith(
|
||||||
textNode.nodeValue
|
textNode.nodeValue,
|
||||||
);
|
);
|
||||||
expect(textContent).toEqual(parsedTextContent);
|
expect(textContent).toEqual(parsedTextContent);
|
||||||
});
|
});
|
||||||
@ -1600,7 +1600,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
expect(element.nodeType).toEqual(Node.ELEMENT_NODE);
|
expect(element.nodeType).toEqual(Node.ELEMENT_NODE);
|
||||||
expect(collectAutofillContentService["trimAndRemoveNonPrintableText"]).toHaveBeenCalledWith(
|
expect(collectAutofillContentService["trimAndRemoveNonPrintableText"]).toHaveBeenCalledWith(
|
||||||
element.textContent
|
element.textContent,
|
||||||
);
|
);
|
||||||
expect(textContent).toEqual(element.textContent);
|
expect(textContent).toEqual(element.textContent);
|
||||||
});
|
});
|
||||||
@ -1735,20 +1735,20 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
const textInputValue = collectAutofillContentService["getPropertyOrAttribute"](
|
const textInputValue = collectAutofillContentService["getPropertyOrAttribute"](
|
||||||
textInput,
|
textInput,
|
||||||
"value"
|
"value",
|
||||||
);
|
);
|
||||||
const textInputId = collectAutofillContentService["getPropertyOrAttribute"](textInput, "id");
|
const textInputId = collectAutofillContentService["getPropertyOrAttribute"](textInput, "id");
|
||||||
const textInputBaseURI = collectAutofillContentService["getPropertyOrAttribute"](
|
const textInputBaseURI = collectAutofillContentService["getPropertyOrAttribute"](
|
||||||
textInput,
|
textInput,
|
||||||
"baseURI"
|
"baseURI",
|
||||||
);
|
);
|
||||||
const textInputAutofocus = collectAutofillContentService["getPropertyOrAttribute"](
|
const textInputAutofocus = collectAutofillContentService["getPropertyOrAttribute"](
|
||||||
textInput,
|
textInput,
|
||||||
"autofocus"
|
"autofocus",
|
||||||
);
|
);
|
||||||
const checkboxInputChecked = collectAutofillContentService["getPropertyOrAttribute"](
|
const checkboxInputChecked = collectAutofillContentService["getPropertyOrAttribute"](
|
||||||
checkboxInput,
|
checkboxInput,
|
||||||
"checked"
|
"checked",
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(textInput.getAttribute).not.toHaveBeenCalled();
|
expect(textInput.getAttribute).not.toHaveBeenCalled();
|
||||||
@ -1767,7 +1767,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
const textInputUniqueAttribute = collectAutofillContentService["getPropertyOrAttribute"](
|
const textInputUniqueAttribute = collectAutofillContentService["getPropertyOrAttribute"](
|
||||||
textInput,
|
textInput,
|
||||||
"data-unique-attribute"
|
"data-unique-attribute",
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(textInputUniqueAttribute).toEqual("unique-value");
|
expect(textInputUniqueAttribute).toEqual("unique-value");
|
||||||
@ -1780,7 +1780,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
|
|
||||||
const textInputNonExistentAttribute = collectAutofillContentService["getPropertyOrAttribute"](
|
const textInputNonExistentAttribute = collectAutofillContentService["getPropertyOrAttribute"](
|
||||||
textInput,
|
textInput,
|
||||||
"non-existent-attribute"
|
"non-existent-attribute",
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(textInputNonExistentAttribute).toEqual(null);
|
expect(textInputNonExistentAttribute).toEqual(null);
|
||||||
@ -1841,14 +1841,14 @@ describe("CollectAutofillContentService", () => {
|
|||||||
<input id="long-value-hidden-input" type="hidden" value="’Twas brillig, and the slithy toves | Did gyre and gimble in the wabe: | All mimsy were the borogoves, | And the mome raths outgrabe. | “Beware the Jabberwock, my son! | The jaws that bite, the claws that catch! | Beware the Jubjub bird, and shun | The frumious Bandersnatch!” | He took his vorpal sword in hand; | Long time the manxome foe he sought— | So rested he by the Tumtum tree | And stood awhile in thought. | And, as in uffish thought he stood, | The Jabberwock, with eyes of flame, | Came whiffling through the tulgey wood, | And burbled as it came! | One, two! One, two! And through and through | The vorpal blade went snicker-snack! | He left it dead, and with its head | He went galumphing back. | “And hast thou slain the Jabberwock? | Come to my arms, my beamish boy! | O frabjous day! Callooh! Callay!” | He chortled in his joy. | ’Twas brillig, and the slithy toves | Did gyre and gimble in the wabe: | All mimsy were the borogoves, | And the mome raths outgrabe." />
|
<input id="long-value-hidden-input" type="hidden" value="’Twas brillig, and the slithy toves | Did gyre and gimble in the wabe: | All mimsy were the borogoves, | And the mome raths outgrabe. | “Beware the Jabberwock, my son! | The jaws that bite, the claws that catch! | Beware the Jubjub bird, and shun | The frumious Bandersnatch!” | He took his vorpal sword in hand; | Long time the manxome foe he sought— | So rested he by the Tumtum tree | And stood awhile in thought. | And, as in uffish thought he stood, | The Jabberwock, with eyes of flame, | Came whiffling through the tulgey wood, | And burbled as it came! | One, two! One, two! And through and through | The vorpal blade went snicker-snack! | He left it dead, and with its head | He went galumphing back. | “And hast thou slain the Jabberwock? | Come to my arms, my beamish boy! | O frabjous day! Callooh! Callay!” | He chortled in his joy. | ’Twas brillig, and the slithy toves | Did gyre and gimble in the wabe: | All mimsy were the borogoves, | And the mome raths outgrabe." />
|
||||||
`;
|
`;
|
||||||
const longValueHiddenInput = document.querySelector(
|
const longValueHiddenInput = document.querySelector(
|
||||||
"#long-value-hidden-input"
|
"#long-value-hidden-input",
|
||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
|
|
||||||
const longHiddenValue =
|
const longHiddenValue =
|
||||||
collectAutofillContentService["getElementValue"](longValueHiddenInput);
|
collectAutofillContentService["getElementValue"](longValueHiddenInput);
|
||||||
|
|
||||||
expect(longHiddenValue).toEqual(
|
expect(longHiddenValue).toEqual(
|
||||||
"’Twas brillig, and the slithy toves | Did gyre and gimble in the wabe: | All mimsy were the borogoves, | And the mome raths outgrabe. | “Beware the Jabberwock, my son! | The jaws that bite, the claws that catch! | Beware the Jubjub bird, and shun | The f...SNIPPED"
|
"’Twas brillig, and the slithy toves | Did gyre and gimble in the wabe: | All mimsy were the borogoves, | And the mome raths outgrabe. | “Beware the Jabberwock, my son! | The jaws that bite, the claws that catch! | Beware the Jubjub bird, and shun | The f...SNIPPED",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1866,7 +1866,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
`;
|
`;
|
||||||
const selectWithOptions = document.querySelector("#select-with-options") as HTMLSelectElement;
|
const selectWithOptions = document.querySelector("#select-with-options") as HTMLSelectElement;
|
||||||
const selectWithoutOptions = document.querySelector(
|
const selectWithoutOptions = document.querySelector(
|
||||||
"#select-without-options"
|
"#select-without-options",
|
||||||
) as HTMLSelectElement;
|
) as HTMLSelectElement;
|
||||||
|
|
||||||
const selectWithOptionsOptions =
|
const selectWithOptionsOptions =
|
||||||
@ -1925,7 +1925,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
document.body,
|
document.body,
|
||||||
[],
|
[],
|
||||||
callbackFilter,
|
callbackFilter,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(collectAutofillContentService["buildTreeWalkerNodesQueryResults"]).toBeCalledTimes(2);
|
expect(collectAutofillContentService["buildTreeWalkerNodesQueryResults"]).toBeCalledTimes(2);
|
||||||
@ -1946,7 +1946,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
document.body,
|
document.body,
|
||||||
[],
|
[],
|
||||||
callbackFilter,
|
callbackFilter,
|
||||||
false
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(collectAutofillContentService["mutationObserver"].observe).not.toBeCalled();
|
expect(collectAutofillContentService["mutationObserver"].observe).not.toBeCalled();
|
||||||
@ -1993,10 +1993,10 @@ describe("CollectAutofillContentService", () => {
|
|||||||
expect(collectAutofillContentService["noFieldsFound"]).toEqual(false);
|
expect(collectAutofillContentService["noFieldsFound"]).toEqual(false);
|
||||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).toBeCalledWith(
|
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).toBeCalledWith(
|
||||||
removedNodes,
|
removedNodes,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).toBeCalledWith(
|
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).toBeCalledWith(
|
||||||
addedNodes
|
addedNodes,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2048,7 +2048,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
expect(collectAutofillContentService["handleWindowLocationMutation"]).toBeCalled();
|
expect(collectAutofillContentService["handleWindowLocationMutation"]).toBeCalled();
|
||||||
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).not.toBeCalled();
|
expect(collectAutofillContentService["isAutofillElementNodeMutated"]).not.toBeCalled();
|
||||||
expect(
|
expect(
|
||||||
collectAutofillContentService["handleAutofillElementAttributeMutation"]
|
collectAutofillContentService["handleAutofillElementAttributeMutation"],
|
||||||
).not.toBeCalled();
|
).not.toBeCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -2170,7 +2170,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
expect(collectAutofillContentService["updateAutofillFormElementData"]).toBeCalledWith(
|
expect(collectAutofillContentService["updateAutofillFormElementData"]).toBeCalledWith(
|
||||||
mutationRecord.attributeName,
|
mutationRecord.attributeName,
|
||||||
mutationRecord.target,
|
mutationRecord.target,
|
||||||
autofillForm
|
autofillForm,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2217,7 +2217,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
expect(collectAutofillContentService["updateAutofillFieldElementData"]).toBeCalledWith(
|
expect(collectAutofillContentService["updateAutofillFieldElementData"]).toBeCalledWith(
|
||||||
mutationRecord.attributeName,
|
mutationRecord.attributeName,
|
||||||
mutationRecord.target,
|
mutationRecord.target,
|
||||||
autofillField
|
autofillField,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -2240,12 +2240,12 @@ describe("CollectAutofillContentService", () => {
|
|||||||
collectAutofillContentService["updateAutofillFormElementData"](
|
collectAutofillContentService["updateAutofillFormElementData"](
|
||||||
attribute,
|
attribute,
|
||||||
formElement,
|
formElement,
|
||||||
autofillForm
|
autofillForm,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(collectAutofillContentService["autofillFormElements"].set).toBeCalledWith(
|
expect(collectAutofillContentService["autofillFormElements"].set).toBeCalledWith(
|
||||||
formElement,
|
formElement,
|
||||||
autofillForm
|
autofillForm,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -2256,7 +2256,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
collectAutofillContentService["updateAutofillFormElementData"](
|
collectAutofillContentService["updateAutofillFormElementData"](
|
||||||
"aria-label",
|
"aria-label",
|
||||||
formElement,
|
formElement,
|
||||||
autofillForm
|
autofillForm,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(collectAutofillContentService["autofillFormElements"].set).not.toBeCalled();
|
expect(collectAutofillContentService["autofillFormElements"].set).not.toBeCalled();
|
||||||
@ -2305,12 +2305,12 @@ describe("CollectAutofillContentService", () => {
|
|||||||
await collectAutofillContentService["updateAutofillFieldElementData"](
|
await collectAutofillContentService["updateAutofillFieldElementData"](
|
||||||
attribute,
|
attribute,
|
||||||
fieldElement,
|
fieldElement,
|
||||||
autofillField
|
autofillField,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(collectAutofillContentService["autofillFieldElements"].set).toBeCalledWith(
|
expect(collectAutofillContentService["autofillFieldElements"].set).toBeCalledWith(
|
||||||
fieldElement,
|
fieldElement,
|
||||||
autofillField
|
autofillField,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -2318,7 +2318,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
it("will check the dom element's visibility if the `style` or `class` attribute has updated ", async () => {
|
it("will check the dom element's visibility if the `style` or `class` attribute has updated ", async () => {
|
||||||
jest.spyOn(
|
jest.spyOn(
|
||||||
collectAutofillContentService["domElementVisibilityService"],
|
collectAutofillContentService["domElementVisibilityService"],
|
||||||
"isFormFieldViewable"
|
"isFormFieldViewable",
|
||||||
);
|
);
|
||||||
const attributes = ["class", "style"];
|
const attributes = ["class", "style"];
|
||||||
|
|
||||||
@ -2326,11 +2326,11 @@ describe("CollectAutofillContentService", () => {
|
|||||||
await collectAutofillContentService["updateAutofillFieldElementData"](
|
await collectAutofillContentService["updateAutofillFieldElementData"](
|
||||||
attribute,
|
attribute,
|
||||||
fieldElement,
|
fieldElement,
|
||||||
autofillField
|
autofillField,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
collectAutofillContentService["domElementVisibilityService"].isFormFieldViewable
|
collectAutofillContentService["domElementVisibilityService"].isFormFieldViewable,
|
||||||
).toBeCalledWith(fieldElement);
|
).toBeCalledWith(fieldElement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2341,7 +2341,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
await collectAutofillContentService["updateAutofillFieldElementData"](
|
await collectAutofillContentService["updateAutofillFieldElementData"](
|
||||||
"random-attribute",
|
"random-attribute",
|
||||||
fieldElement,
|
fieldElement,
|
||||||
autofillField
|
autofillField,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(collectAutofillContentService["autofillFieldElements"].set).not.toBeCalled();
|
expect(collectAutofillContentService["autofillFieldElements"].set).not.toBeCalled();
|
||||||
|
@ -31,7 +31,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
domElementVisibilityService: DomElementVisibilityService,
|
domElementVisibilityService: DomElementVisibilityService,
|
||||||
autofillOverlayContentService?: AutofillOverlayContentService
|
autofillOverlayContentService?: AutofillOverlayContentService,
|
||||||
) {
|
) {
|
||||||
this.domElementVisibilityService = domElementVisibilityService;
|
this.domElementVisibilityService = domElementVisibilityService;
|
||||||
this.autofillOverlayContentService = autofillOverlayContentService;
|
this.autofillOverlayContentService = autofillOverlayContentService;
|
||||||
@ -56,7 +56,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
if (!this.domRecentlyMutated && this.autofillFieldElements.size) {
|
if (!this.domRecentlyMutated && this.autofillFieldElements.size) {
|
||||||
return this.getFormattedPageDetails(
|
return this.getFormattedPageDetails(
|
||||||
this.getFormattedAutofillFormsData(),
|
this.getFormattedAutofillFormsData(),
|
||||||
this.getFormattedAutofillFieldsData()
|
this.getFormattedAutofillFieldsData(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
const autofillFormsData: Record<string, AutofillForm> =
|
const autofillFormsData: Record<string, AutofillForm> =
|
||||||
this.buildAutofillFormsData(formElements);
|
this.buildAutofillFormsData(formElements);
|
||||||
const autofillFieldsData: AutofillField[] = await this.buildAutofillFieldsData(
|
const autofillFieldsData: AutofillField[] = await this.buildAutofillFieldsData(
|
||||||
formFieldElements as FormFieldElement[]
|
formFieldElements as FormFieldElement[],
|
||||||
);
|
);
|
||||||
this.sortAutofillFieldElementsMap();
|
this.sortAutofillFieldElementsMap();
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
? cachedFormFieldElements
|
? cachedFormFieldElements
|
||||||
: this.getAutofillFieldElements();
|
: this.getAutofillFieldElements();
|
||||||
const fieldElementsWithOpid = formFieldElements.filter(
|
const fieldElementsWithOpid = formFieldElements.filter(
|
||||||
(fieldElement) => (fieldElement as ElementWithOpId<FormFieldElement>).opid === opid
|
(fieldElement) => (fieldElement as ElementWithOpId<FormFieldElement>).opid === opid,
|
||||||
) as ElementWithOpId<FormFieldElement>[];
|
) as ElementWithOpId<FormFieldElement>[];
|
||||||
|
|
||||||
if (!fieldElementsWithOpid.length) {
|
if (!fieldElementsWithOpid.length) {
|
||||||
@ -117,7 +117,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
queryAllTreeWalkerNodes(
|
queryAllTreeWalkerNodes(
|
||||||
rootNode: Node,
|
rootNode: Node,
|
||||||
filterCallback: CallableFunction,
|
filterCallback: CallableFunction,
|
||||||
isObservingShadowRoot = true
|
isObservingShadowRoot = true,
|
||||||
): Node[] {
|
): Node[] {
|
||||||
const treeWalkerQueryResults: Node[] = [];
|
const treeWalkerQueryResults: Node[] = [];
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
rootNode,
|
rootNode,
|
||||||
treeWalkerQueryResults,
|
treeWalkerQueryResults,
|
||||||
filterCallback,
|
filterCallback,
|
||||||
isObservingShadowRoot
|
isObservingShadowRoot,
|
||||||
);
|
);
|
||||||
|
|
||||||
return treeWalkerQueryResults;
|
return treeWalkerQueryResults;
|
||||||
@ -141,7 +141,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.autofillFieldElements = new Map(
|
this.autofillFieldElements = new Map(
|
||||||
[...this.autofillFieldElements].sort((a, b) => a[1].elementNumber - b[1].elementNumber)
|
[...this.autofillFieldElements].sort((a, b) => a[1].elementNumber - b[1].elementNumber),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
*/
|
*/
|
||||||
private getFormattedPageDetails(
|
private getFormattedPageDetails(
|
||||||
autofillFormsData: Record<string, AutofillForm>,
|
autofillFormsData: Record<string, AutofillForm>,
|
||||||
autofillFieldsData: AutofillField[]
|
autofillFieldsData: AutofillField[],
|
||||||
): AutofillPageDetails {
|
): AutofillPageDetails {
|
||||||
return {
|
return {
|
||||||
title: document.title,
|
title: document.title,
|
||||||
@ -231,7 +231,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private async buildAutofillFieldsData(
|
private async buildAutofillFieldsData(
|
||||||
formFieldElements: FormFieldElement[]
|
formFieldElements: FormFieldElement[],
|
||||||
): Promise<AutofillField[]> {
|
): Promise<AutofillField[]> {
|
||||||
const autofillFieldElements = this.getAutofillFieldElements(100, formFieldElements);
|
const autofillFieldElements = this.getAutofillFieldElements(100, formFieldElements);
|
||||||
const autofillFieldDataPromises = autofillFieldElements.map(this.buildAutofillFieldItem);
|
const autofillFieldDataPromises = autofillFieldElements.map(this.buildAutofillFieldItem);
|
||||||
@ -250,12 +250,12 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
*/
|
*/
|
||||||
private getAutofillFieldElements(
|
private getAutofillFieldElements(
|
||||||
fieldsLimit?: number,
|
fieldsLimit?: number,
|
||||||
previouslyFoundFormFieldElements?: FormFieldElement[]
|
previouslyFoundFormFieldElements?: FormFieldElement[],
|
||||||
): FormFieldElement[] {
|
): FormFieldElement[] {
|
||||||
const formFieldElements =
|
const formFieldElements =
|
||||||
previouslyFoundFormFieldElements ||
|
previouslyFoundFormFieldElements ||
|
||||||
(this.queryAllTreeWalkerNodes(document.documentElement, (node: Node) =>
|
(this.queryAllTreeWalkerNodes(document.documentElement, (node: Node) =>
|
||||||
this.isNodeFormFieldElement(node)
|
this.isNodeFormFieldElement(node),
|
||||||
) as FormFieldElement[]);
|
) as FormFieldElement[]);
|
||||||
|
|
||||||
if (!fieldsLimit || formFieldElements.length <= fieldsLimit) {
|
if (!fieldsLimit || formFieldElements.length <= fieldsLimit) {
|
||||||
@ -298,7 +298,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
*/
|
*/
|
||||||
private buildAutofillFieldItem = async (
|
private buildAutofillFieldItem = async (
|
||||||
element: ElementWithOpId<FormFieldElement>,
|
element: ElementWithOpId<FormFieldElement>,
|
||||||
index: number
|
index: number,
|
||||||
): Promise<AutofillField> => {
|
): Promise<AutofillField> => {
|
||||||
element.opid = `__${index}`;
|
element.opid = `__${index}`;
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
this.autofillFieldElements.set(element, autofillFieldBase);
|
this.autofillFieldElements.set(element, autofillFieldBase);
|
||||||
this.autofillOverlayContentService?.setupAutofillOverlayListenerOnField(
|
this.autofillOverlayContentService?.setupAutofillOverlayListenerOnField(
|
||||||
element,
|
element,
|
||||||
autofillFieldBase
|
autofillFieldBase,
|
||||||
);
|
);
|
||||||
return autofillFieldBase;
|
return autofillFieldBase;
|
||||||
}
|
}
|
||||||
@ -397,7 +397,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
private getAttributeBoolean(
|
private getAttributeBoolean(
|
||||||
element: ElementWithOpId<FormFieldElement>,
|
element: ElementWithOpId<FormFieldElement>,
|
||||||
attributeName: string,
|
attributeName: string,
|
||||||
checkString = false
|
checkString = false,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (checkString) {
|
if (checkString) {
|
||||||
return this.getPropertyOrAttribute(element, attributeName) === "true";
|
return this.getPropertyOrAttribute(element, attributeName) === "true";
|
||||||
@ -415,7 +415,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
*/
|
*/
|
||||||
private getAttributeLowerCase(
|
private getAttributeLowerCase(
|
||||||
element: ElementWithOpId<FormFieldElement>,
|
element: ElementWithOpId<FormFieldElement>,
|
||||||
attributeName: string
|
attributeName: string,
|
||||||
): string {
|
): string {
|
||||||
return this.getPropertyOrAttribute(element, attributeName)?.toLowerCase();
|
return this.getPropertyOrAttribute(element, attributeName)?.toLowerCase();
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private queryElementLabels(
|
private queryElementLabels(
|
||||||
element: FillableFormFieldElement
|
element: FillableFormFieldElement,
|
||||||
): NodeListOf<HTMLLabelElement> | null {
|
): NodeListOf<HTMLLabelElement> | null {
|
||||||
let labelQuerySelectors = element.id ? `label[for="${element.id}"]` : "";
|
let labelQuerySelectors = element.id ? `label[for="${element.id}"]` : "";
|
||||||
if (element.name) {
|
if (element.name) {
|
||||||
@ -494,7 +494,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (element.getRootNode() as Document | ShadowRoot).querySelectorAll(
|
return (element.getRootNode() as Document | ShadowRoot).querySelectorAll(
|
||||||
labelQuerySelectors.replace(/\n/g, "")
|
labelQuerySelectors.replace(/\n/g, ""),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.trimAndRemoveNonPrintableText(
|
return this.trimAndRemoveNonPrintableText(
|
||||||
element.textContent || (element as HTMLElement).innerText
|
element.textContent || (element as HTMLElement).innerText,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -869,7 +869,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
rootNode: Node,
|
rootNode: Node,
|
||||||
treeWalkerQueryResults: Node[],
|
treeWalkerQueryResults: Node[],
|
||||||
filterCallback: CallableFunction,
|
filterCallback: CallableFunction,
|
||||||
isObservingShadowRoot: boolean
|
isObservingShadowRoot: boolean,
|
||||||
) {
|
) {
|
||||||
const treeWalker = document?.createTreeWalker(rootNode, NodeFilter.SHOW_ELEMENT);
|
const treeWalker = document?.createTreeWalker(rootNode, NodeFilter.SHOW_ELEMENT);
|
||||||
let currentNode = treeWalker?.currentNode;
|
let currentNode = treeWalker?.currentNode;
|
||||||
@ -893,7 +893,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
nodeShadowRoot,
|
nodeShadowRoot,
|
||||||
treeWalkerQueryResults,
|
treeWalkerQueryResults,
|
||||||
filterCallback,
|
filterCallback,
|
||||||
isObservingShadowRoot
|
isObservingShadowRoot,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,7 +1002,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
|
|
||||||
const childNodes = this.queryAllTreeWalkerNodes(
|
const childNodes = this.queryAllTreeWalkerNodes(
|
||||||
node,
|
node,
|
||||||
(node: Node) => node instanceof HTMLFormElement || this.isNodeFormFieldElement(node)
|
(node: Node) => node instanceof HTMLFormElement || this.isNodeFormFieldElement(node),
|
||||||
) as HTMLElement[];
|
) as HTMLElement[];
|
||||||
if (childNodes.length) {
|
if (childNodes.length) {
|
||||||
isElementMutated = true;
|
isElementMutated = true;
|
||||||
@ -1014,7 +1014,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
const node = mutatedElements[elementIndex];
|
const node = mutatedElements[elementIndex];
|
||||||
if (isRemovingNodes) {
|
if (isRemovingNodes) {
|
||||||
this.deleteCachedAutofillElement(
|
this.deleteCachedAutofillElement(
|
||||||
node as ElementWithOpId<HTMLFormElement> | ElementWithOpId<FormFieldElement>
|
node as ElementWithOpId<HTMLFormElement> | ElementWithOpId<FormFieldElement>,
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1040,7 +1040,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private deleteCachedAutofillElement(
|
private deleteCachedAutofillElement(
|
||||||
element: ElementWithOpId<HTMLFormElement> | ElementWithOpId<FormFieldElement>
|
element: ElementWithOpId<HTMLFormElement> | ElementWithOpId<FormFieldElement>,
|
||||||
) {
|
) {
|
||||||
if (element instanceof HTMLFormElement && this.autofillFormElements.has(element)) {
|
if (element instanceof HTMLFormElement && this.autofillFormElements.has(element)) {
|
||||||
this.autofillFormElements.delete(element);
|
this.autofillFormElements.delete(element);
|
||||||
@ -1064,7 +1064,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
|
|
||||||
this.updateAutofillElementsAfterMutationTimeout = setTimeout(
|
this.updateAutofillElementsAfterMutationTimeout = setTimeout(
|
||||||
this.getPageDetails.bind(this),
|
this.getPageDetails.bind(this),
|
||||||
this.updateAfterMutationTimeoutDelay
|
this.updateAfterMutationTimeoutDelay,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,21 +1081,21 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
|
|
||||||
const attributeName = mutation.attributeName?.toLowerCase();
|
const attributeName = mutation.attributeName?.toLowerCase();
|
||||||
const autofillForm = this.autofillFormElements.get(
|
const autofillForm = this.autofillFormElements.get(
|
||||||
targetElement as ElementWithOpId<HTMLFormElement>
|
targetElement as ElementWithOpId<HTMLFormElement>,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (autofillForm) {
|
if (autofillForm) {
|
||||||
this.updateAutofillFormElementData(
|
this.updateAutofillFormElementData(
|
||||||
attributeName,
|
attributeName,
|
||||||
targetElement as ElementWithOpId<HTMLFormElement>,
|
targetElement as ElementWithOpId<HTMLFormElement>,
|
||||||
autofillForm
|
autofillForm,
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const autofillField = this.autofillFieldElements.get(
|
const autofillField = this.autofillFieldElements.get(
|
||||||
targetElement as ElementWithOpId<FormFieldElement>
|
targetElement as ElementWithOpId<FormFieldElement>,
|
||||||
);
|
);
|
||||||
if (!autofillField) {
|
if (!autofillField) {
|
||||||
return;
|
return;
|
||||||
@ -1104,7 +1104,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
this.updateAutofillFieldElementData(
|
this.updateAutofillFieldElementData(
|
||||||
attributeName,
|
attributeName,
|
||||||
targetElement as ElementWithOpId<FormFieldElement>,
|
targetElement as ElementWithOpId<FormFieldElement>,
|
||||||
autofillField
|
autofillField,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1118,7 +1118,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
private updateAutofillFormElementData(
|
private updateAutofillFormElementData(
|
||||||
attributeName: string,
|
attributeName: string,
|
||||||
element: ElementWithOpId<HTMLFormElement>,
|
element: ElementWithOpId<HTMLFormElement>,
|
||||||
dataTarget: AutofillForm
|
dataTarget: AutofillForm,
|
||||||
) {
|
) {
|
||||||
const updateAttribute = (dataTargetKey: string) => {
|
const updateAttribute = (dataTargetKey: string) => {
|
||||||
this.updateAutofillDataAttribute({ element, attributeName, dataTarget, dataTargetKey });
|
this.updateAutofillDataAttribute({ element, attributeName, dataTarget, dataTargetKey });
|
||||||
@ -1149,7 +1149,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
private async updateAutofillFieldElementData(
|
private async updateAutofillFieldElementData(
|
||||||
attributeName: string,
|
attributeName: string,
|
||||||
element: ElementWithOpId<FormFieldElement>,
|
element: ElementWithOpId<FormFieldElement>,
|
||||||
dataTarget: AutofillField
|
dataTarget: AutofillField,
|
||||||
) {
|
) {
|
||||||
const updateAttribute = (dataTargetKey: string) => {
|
const updateAttribute = (dataTargetKey: string) => {
|
||||||
this.updateAutofillDataAttribute({ element, attributeName, dataTarget, dataTargetKey });
|
this.updateAutofillDataAttribute({ element, attributeName, dataTarget, dataTargetKey });
|
||||||
|
@ -47,19 +47,18 @@ describe("DomElementVisibilityService", () => {
|
|||||||
jest.spyOn(domElementVisibilityService, "isElementHiddenByCss");
|
jest.spyOn(domElementVisibilityService, "isElementHiddenByCss");
|
||||||
jest.spyOn(domElementVisibilityService as any, "formFieldIsNotHiddenBehindAnotherElement");
|
jest.spyOn(domElementVisibilityService as any, "formFieldIsNotHiddenBehindAnotherElement");
|
||||||
|
|
||||||
const isFormFieldViewable = await domElementVisibilityService.isFormFieldViewable(
|
const isFormFieldViewable =
|
||||||
usernameElement
|
await domElementVisibilityService.isFormFieldViewable(usernameElement);
|
||||||
);
|
|
||||||
|
|
||||||
expect(isFormFieldViewable).toEqual(false);
|
expect(isFormFieldViewable).toEqual(false);
|
||||||
expect(usernameElement.getBoundingClientRect).toHaveBeenCalled();
|
expect(usernameElement.getBoundingClientRect).toHaveBeenCalled();
|
||||||
expect(domElementVisibilityService["isElementOutsideViewportBounds"]).toHaveBeenCalledWith(
|
expect(domElementVisibilityService["isElementOutsideViewportBounds"]).toHaveBeenCalledWith(
|
||||||
usernameElement,
|
usernameElement,
|
||||||
usernameElement.getBoundingClientRect()
|
usernameElement.getBoundingClientRect(),
|
||||||
);
|
);
|
||||||
expect(domElementVisibilityService["isElementHiddenByCss"]).not.toHaveBeenCalled();
|
expect(domElementVisibilityService["isElementHiddenByCss"]).not.toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
domElementVisibilityService["formFieldIsNotHiddenBehindAnotherElement"]
|
domElementVisibilityService["formFieldIsNotHiddenBehindAnotherElement"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,21 +71,20 @@ describe("DomElementVisibilityService", () => {
|
|||||||
jest.spyOn(domElementVisibilityService, "isElementHiddenByCss").mockReturnValueOnce(true);
|
jest.spyOn(domElementVisibilityService, "isElementHiddenByCss").mockReturnValueOnce(true);
|
||||||
jest.spyOn(domElementVisibilityService as any, "formFieldIsNotHiddenBehindAnotherElement");
|
jest.spyOn(domElementVisibilityService as any, "formFieldIsNotHiddenBehindAnotherElement");
|
||||||
|
|
||||||
const isFormFieldViewable = await domElementVisibilityService.isFormFieldViewable(
|
const isFormFieldViewable =
|
||||||
usernameElement
|
await domElementVisibilityService.isFormFieldViewable(usernameElement);
|
||||||
);
|
|
||||||
|
|
||||||
expect(isFormFieldViewable).toEqual(false);
|
expect(isFormFieldViewable).toEqual(false);
|
||||||
expect(usernameElement.getBoundingClientRect).toHaveBeenCalled();
|
expect(usernameElement.getBoundingClientRect).toHaveBeenCalled();
|
||||||
expect(domElementVisibilityService["isElementOutsideViewportBounds"]).toHaveBeenCalledWith(
|
expect(domElementVisibilityService["isElementOutsideViewportBounds"]).toHaveBeenCalledWith(
|
||||||
usernameElement,
|
usernameElement,
|
||||||
usernameElement.getBoundingClientRect()
|
usernameElement.getBoundingClientRect(),
|
||||||
);
|
);
|
||||||
expect(domElementVisibilityService["isElementHiddenByCss"]).toHaveBeenCalledWith(
|
expect(domElementVisibilityService["isElementHiddenByCss"]).toHaveBeenCalledWith(
|
||||||
usernameElement
|
usernameElement,
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
domElementVisibilityService["formFieldIsNotHiddenBehindAnotherElement"]
|
domElementVisibilityService["formFieldIsNotHiddenBehindAnotherElement"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -101,21 +99,20 @@ describe("DomElementVisibilityService", () => {
|
|||||||
.spyOn(domElementVisibilityService as any, "formFieldIsNotHiddenBehindAnotherElement")
|
.spyOn(domElementVisibilityService as any, "formFieldIsNotHiddenBehindAnotherElement")
|
||||||
.mockReturnValueOnce(false);
|
.mockReturnValueOnce(false);
|
||||||
|
|
||||||
const isFormFieldViewable = await domElementVisibilityService.isFormFieldViewable(
|
const isFormFieldViewable =
|
||||||
usernameElement
|
await domElementVisibilityService.isFormFieldViewable(usernameElement);
|
||||||
);
|
|
||||||
|
|
||||||
expect(isFormFieldViewable).toEqual(false);
|
expect(isFormFieldViewable).toEqual(false);
|
||||||
expect(usernameElement.getBoundingClientRect).toHaveBeenCalled();
|
expect(usernameElement.getBoundingClientRect).toHaveBeenCalled();
|
||||||
expect(domElementVisibilityService["isElementOutsideViewportBounds"]).toHaveBeenCalledWith(
|
expect(domElementVisibilityService["isElementOutsideViewportBounds"]).toHaveBeenCalledWith(
|
||||||
usernameElement,
|
usernameElement,
|
||||||
usernameElement.getBoundingClientRect()
|
usernameElement.getBoundingClientRect(),
|
||||||
);
|
);
|
||||||
expect(domElementVisibilityService["isElementHiddenByCss"]).toHaveBeenCalledWith(
|
expect(domElementVisibilityService["isElementHiddenByCss"]).toHaveBeenCalledWith(
|
||||||
usernameElement
|
usernameElement,
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
domElementVisibilityService["formFieldIsNotHiddenBehindAnotherElement"]
|
domElementVisibilityService["formFieldIsNotHiddenBehindAnotherElement"],
|
||||||
).toHaveBeenCalledWith(usernameElement, usernameElement.getBoundingClientRect());
|
).toHaveBeenCalledWith(usernameElement, usernameElement.getBoundingClientRect());
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -130,21 +127,20 @@ describe("DomElementVisibilityService", () => {
|
|||||||
.spyOn(domElementVisibilityService as any, "formFieldIsNotHiddenBehindAnotherElement")
|
.spyOn(domElementVisibilityService as any, "formFieldIsNotHiddenBehindAnotherElement")
|
||||||
.mockReturnValueOnce(true);
|
.mockReturnValueOnce(true);
|
||||||
|
|
||||||
const isFormFieldViewable = await domElementVisibilityService.isFormFieldViewable(
|
const isFormFieldViewable =
|
||||||
usernameElement
|
await domElementVisibilityService.isFormFieldViewable(usernameElement);
|
||||||
);
|
|
||||||
|
|
||||||
expect(isFormFieldViewable).toEqual(true);
|
expect(isFormFieldViewable).toEqual(true);
|
||||||
expect(usernameElement.getBoundingClientRect).toHaveBeenCalled();
|
expect(usernameElement.getBoundingClientRect).toHaveBeenCalled();
|
||||||
expect(domElementVisibilityService["isElementOutsideViewportBounds"]).toHaveBeenCalledWith(
|
expect(domElementVisibilityService["isElementOutsideViewportBounds"]).toHaveBeenCalledWith(
|
||||||
usernameElement,
|
usernameElement,
|
||||||
usernameElement.getBoundingClientRect()
|
usernameElement.getBoundingClientRect(),
|
||||||
);
|
);
|
||||||
expect(domElementVisibilityService["isElementHiddenByCss"]).toHaveBeenCalledWith(
|
expect(domElementVisibilityService["isElementHiddenByCss"]).toHaveBeenCalledWith(
|
||||||
usernameElement
|
usernameElement,
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
domElementVisibilityService["formFieldIsNotHiddenBehindAnotherElement"]
|
domElementVisibilityService["formFieldIsNotHiddenBehindAnotherElement"],
|
||||||
).toHaveBeenCalledWith(usernameElement, usernameElement.getBoundingClientRect());
|
).toHaveBeenCalledWith(usernameElement, usernameElement.getBoundingClientRect());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -186,12 +182,12 @@ describe("DomElementVisibilityService", () => {
|
|||||||
expect(isUsernameElementHidden).toEqual(true);
|
expect(isUsernameElementHidden).toEqual(true);
|
||||||
expect(usernameElement.style.getPropertyValue).toHaveBeenCalled();
|
expect(usernameElement.style.getPropertyValue).toHaveBeenCalled();
|
||||||
expect(usernameElement.ownerDocument.defaultView.getComputedStyle).toHaveBeenCalledWith(
|
expect(usernameElement.ownerDocument.defaultView.getComputedStyle).toHaveBeenCalledWith(
|
||||||
usernameElement
|
usernameElement,
|
||||||
);
|
);
|
||||||
expect(isPasswordElementHidden).toEqual(true);
|
expect(isPasswordElementHidden).toEqual(true);
|
||||||
expect(passwordElement.style.getPropertyValue).toHaveBeenCalled();
|
expect(passwordElement.style.getPropertyValue).toHaveBeenCalled();
|
||||||
expect(passwordElement.ownerDocument.defaultView.getComputedStyle).toHaveBeenCalledWith(
|
expect(passwordElement.ownerDocument.defaultView.getComputedStyle).toHaveBeenCalledWith(
|
||||||
passwordElement
|
passwordElement,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -391,7 +387,7 @@ describe("DomElementVisibilityService", () => {
|
|||||||
expect(formFieldIsNotHiddenBehindAnotherElement).toEqual(true);
|
expect(formFieldIsNotHiddenBehindAnotherElement).toEqual(true);
|
||||||
expect(document.elementFromPoint).toHaveBeenCalledWith(
|
expect(document.elementFromPoint).toHaveBeenCalledWith(
|
||||||
mockBoundingRect.left + mockBoundingRect.width / 2,
|
mockBoundingRect.left + mockBoundingRect.width / 2,
|
||||||
mockBoundingRect.top + mockBoundingRect.height / 2
|
mockBoundingRect.top + mockBoundingRect.height / 2,
|
||||||
);
|
);
|
||||||
expect(usernameElement.getBoundingClientRect).not.toHaveBeenCalled();
|
expect(usernameElement.getBoundingClientRect).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -67,7 +67,7 @@ class DomElementVisibilityService implements domElementVisibilityServiceInterfac
|
|||||||
private getElementStyle(element: HTMLElement, styleProperty: string): string {
|
private getElementStyle(element: HTMLElement, styleProperty: string): string {
|
||||||
if (!this.cachedComputedStyle) {
|
if (!this.cachedComputedStyle) {
|
||||||
this.cachedComputedStyle = (element.ownerDocument.defaultView || window).getComputedStyle(
|
this.cachedComputedStyle = (element.ownerDocument.defaultView || window).getComputedStyle(
|
||||||
element
|
element,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ class DomElementVisibilityService implements domElementVisibilityServiceInterfac
|
|||||||
*/
|
*/
|
||||||
private isElementOutsideViewportBounds(
|
private isElementOutsideViewportBounds(
|
||||||
targetElement: HTMLElement,
|
targetElement: HTMLElement,
|
||||||
targetElementBoundingClientRect: DOMRectReadOnly | null = null
|
targetElementBoundingClientRect: DOMRectReadOnly | null = null,
|
||||||
): boolean {
|
): boolean {
|
||||||
const documentElement = targetElement.ownerDocument.documentElement;
|
const documentElement = targetElement.ownerDocument.documentElement;
|
||||||
const documentElementWidth = documentElement.scrollWidth;
|
const documentElementWidth = documentElement.scrollWidth;
|
||||||
@ -171,7 +171,7 @@ class DomElementVisibilityService implements domElementVisibilityServiceInterfac
|
|||||||
*/
|
*/
|
||||||
private formFieldIsNotHiddenBehindAnotherElement(
|
private formFieldIsNotHiddenBehindAnotherElement(
|
||||||
targetElement: FormFieldElement,
|
targetElement: FormFieldElement,
|
||||||
targetElementBoundingClientRect: DOMRectReadOnly | null = null
|
targetElementBoundingClientRect: DOMRectReadOnly | null = null,
|
||||||
): boolean {
|
): boolean {
|
||||||
const elementBoundingClientRect =
|
const elementBoundingClientRect =
|
||||||
targetElementBoundingClientRect || targetElement.getBoundingClientRect();
|
targetElementBoundingClientRect || targetElement.getBoundingClientRect();
|
||||||
@ -180,7 +180,7 @@ class DomElementVisibilityService implements domElementVisibilityServiceInterfac
|
|||||||
elementRootNode instanceof ShadowRoot ? elementRootNode : targetElement.ownerDocument;
|
elementRootNode instanceof ShadowRoot ? elementRootNode : targetElement.ownerDocument;
|
||||||
const elementAtCenterPoint = rootElement.elementFromPoint(
|
const elementAtCenterPoint = rootElement.elementFromPoint(
|
||||||
elementBoundingClientRect.left + elementBoundingClientRect.width / 2,
|
elementBoundingClientRect.left + elementBoundingClientRect.width / 2,
|
||||||
elementBoundingClientRect.top + elementBoundingClientRect.height / 2
|
elementBoundingClientRect.top + elementBoundingClientRect.height / 2,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (elementAtCenterPoint === targetElement) {
|
if (elementAtCenterPoint === targetElement) {
|
||||||
|
@ -41,8 +41,8 @@ const initEventCount = Object.freeze(
|
|||||||
...eventCounts,
|
...eventCounts,
|
||||||
[eventName]: 0,
|
[eventName]: 0,
|
||||||
}),
|
}),
|
||||||
{}
|
{},
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let confirmSpy: jest.SpyInstance<boolean, [message?: string]>;
|
let confirmSpy: jest.SpyInstance<boolean, [message?: string]>;
|
||||||
@ -68,7 +68,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
const autofillOverlayContentService = new AutofillOverlayContentService();
|
const autofillOverlayContentService = new AutofillOverlayContentService();
|
||||||
const collectAutofillContentService = new CollectAutofillContentService(
|
const collectAutofillContentService = new CollectAutofillContentService(
|
||||||
domElementVisibilityService,
|
domElementVisibilityService,
|
||||||
autofillOverlayContentService
|
autofillOverlayContentService,
|
||||||
);
|
);
|
||||||
let insertAutofillContentService: InsertAutofillContentService;
|
let insertAutofillContentService: InsertAutofillContentService;
|
||||||
let fillScript: AutofillScript;
|
let fillScript: AutofillScript;
|
||||||
@ -79,7 +79,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
windowSpy = jest.spyOn(window, "window", "get");
|
windowSpy = jest.spyOn(window, "window", "get");
|
||||||
insertAutofillContentService = new InsertAutofillContentService(
|
insertAutofillContentService = new InsertAutofillContentService(
|
||||||
domElementVisibilityService,
|
domElementVisibilityService,
|
||||||
collectAutofillContentService
|
collectAutofillContentService,
|
||||||
);
|
);
|
||||||
fillScript = {
|
fillScript = {
|
||||||
script: [
|
script: [
|
||||||
@ -117,10 +117,10 @@ describe("InsertAutofillContentService", () => {
|
|||||||
|
|
||||||
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).not.toHaveBeenCalled();
|
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).not.toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["userCancelledInsecureUrlAutofill"]
|
insertAutofillContentService["userCancelledInsecureUrlAutofill"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["userCancelledUntrustedIframeAutofill"]
|
insertAutofillContentService["userCancelledUntrustedIframeAutofill"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(insertAutofillContentService["runFillScriptAction"]).not.toHaveBeenCalled();
|
expect(insertAutofillContentService["runFillScriptAction"]).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -137,10 +137,10 @@ describe("InsertAutofillContentService", () => {
|
|||||||
|
|
||||||
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).toHaveBeenCalled();
|
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["userCancelledInsecureUrlAutofill"]
|
insertAutofillContentService["userCancelledInsecureUrlAutofill"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["userCancelledUntrustedIframeAutofill"]
|
insertAutofillContentService["userCancelledUntrustedIframeAutofill"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(insertAutofillContentService["runFillScriptAction"]).not.toHaveBeenCalled();
|
expect(insertAutofillContentService["runFillScriptAction"]).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -160,7 +160,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).toHaveBeenCalled();
|
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).toHaveBeenCalled();
|
||||||
expect(insertAutofillContentService["userCancelledInsecureUrlAutofill"]).toHaveBeenCalled();
|
expect(insertAutofillContentService["userCancelledInsecureUrlAutofill"]).toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["userCancelledUntrustedIframeAutofill"]
|
insertAutofillContentService["userCancelledUntrustedIframeAutofill"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
expect(insertAutofillContentService["runFillScriptAction"]).not.toHaveBeenCalled();
|
expect(insertAutofillContentService["runFillScriptAction"]).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -182,7 +182,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).toHaveBeenCalled();
|
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).toHaveBeenCalled();
|
||||||
expect(insertAutofillContentService["userCancelledInsecureUrlAutofill"]).toHaveBeenCalled();
|
expect(insertAutofillContentService["userCancelledInsecureUrlAutofill"]).toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["userCancelledUntrustedIframeAutofill"]
|
insertAutofillContentService["userCancelledUntrustedIframeAutofill"],
|
||||||
).toHaveBeenCalled();
|
).toHaveBeenCalled();
|
||||||
expect(insertAutofillContentService["runFillScriptAction"]).not.toHaveBeenCalled();
|
expect(insertAutofillContentService["runFillScriptAction"]).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -204,26 +204,26 @@ describe("InsertAutofillContentService", () => {
|
|||||||
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).toHaveBeenCalled();
|
expect(insertAutofillContentService["fillingWithinSandboxedIframe"]).toHaveBeenCalled();
|
||||||
expect(insertAutofillContentService["userCancelledInsecureUrlAutofill"]).toHaveBeenCalled();
|
expect(insertAutofillContentService["userCancelledInsecureUrlAutofill"]).toHaveBeenCalled();
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["userCancelledUntrustedIframeAutofill"]
|
insertAutofillContentService["userCancelledUntrustedIframeAutofill"],
|
||||||
).toHaveBeenCalled();
|
).toHaveBeenCalled();
|
||||||
expect(insertAutofillContentService["runFillScriptAction"]).toHaveBeenCalledTimes(3);
|
expect(insertAutofillContentService["runFillScriptAction"]).toHaveBeenCalledTimes(3);
|
||||||
expect(insertAutofillContentService["runFillScriptAction"]).toHaveBeenNthCalledWith(
|
expect(insertAutofillContentService["runFillScriptAction"]).toHaveBeenNthCalledWith(
|
||||||
1,
|
1,
|
||||||
fillScript.script[0],
|
fillScript.script[0],
|
||||||
0,
|
0,
|
||||||
fillScript.script
|
fillScript.script,
|
||||||
);
|
);
|
||||||
expect(insertAutofillContentService["runFillScriptAction"]).toHaveBeenNthCalledWith(
|
expect(insertAutofillContentService["runFillScriptAction"]).toHaveBeenNthCalledWith(
|
||||||
2,
|
2,
|
||||||
fillScript.script[1],
|
fillScript.script[1],
|
||||||
1,
|
1,
|
||||||
fillScript.script
|
fillScript.script,
|
||||||
);
|
);
|
||||||
expect(insertAutofillContentService["runFillScriptAction"]).toHaveBeenNthCalledWith(
|
expect(insertAutofillContentService["runFillScriptAction"]).toHaveBeenNthCalledWith(
|
||||||
3,
|
3,
|
||||||
fillScript.script[2],
|
fillScript.script[2],
|
||||||
2,
|
2,
|
||||||
fillScript.script
|
fillScript.script,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -432,7 +432,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
jest.advanceTimersByTime(20);
|
jest.advanceTimersByTime(20);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["autofillInsertActions"][action]
|
insertAutofillContentService["autofillInsertActions"][action],
|
||||||
).toHaveBeenCalledWith({
|
).toHaveBeenCalledWith({
|
||||||
opid,
|
opid,
|
||||||
value,
|
value,
|
||||||
@ -451,18 +451,18 @@ describe("InsertAutofillContentService", () => {
|
|||||||
textInput.value = value;
|
textInput.value = value;
|
||||||
jest.spyOn(
|
jest.spyOn(
|
||||||
insertAutofillContentService["collectAutofillContentService"],
|
insertAutofillContentService["collectAutofillContentService"],
|
||||||
"getAutofillFieldElementByOpid"
|
"getAutofillFieldElementByOpid",
|
||||||
);
|
);
|
||||||
jest.spyOn(insertAutofillContentService as any, "insertValueIntoField");
|
jest.spyOn(insertAutofillContentService as any, "insertValueIntoField");
|
||||||
|
|
||||||
insertAutofillContentService["handleFillFieldByOpidAction"](opid, value);
|
insertAutofillContentService["handleFillFieldByOpidAction"](opid, value);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["collectAutofillContentService"].getAutofillFieldElementByOpid
|
insertAutofillContentService["collectAutofillContentService"].getAutofillFieldElementByOpid,
|
||||||
).toHaveBeenCalledWith(opid);
|
).toHaveBeenCalledWith(opid);
|
||||||
expect(insertAutofillContentService["insertValueIntoField"]).toHaveBeenCalledWith(
|
expect(insertAutofillContentService["insertValueIntoField"]).toHaveBeenCalledWith(
|
||||||
textInput,
|
textInput,
|
||||||
value
|
value,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -483,17 +483,17 @@ describe("InsertAutofillContentService", () => {
|
|||||||
textInput.addEventListener("click", clickEventHandler);
|
textInput.addEventListener("click", clickEventHandler);
|
||||||
jest.spyOn(
|
jest.spyOn(
|
||||||
insertAutofillContentService["collectAutofillContentService"],
|
insertAutofillContentService["collectAutofillContentService"],
|
||||||
"getAutofillFieldElementByOpid"
|
"getAutofillFieldElementByOpid",
|
||||||
);
|
);
|
||||||
jest.spyOn(insertAutofillContentService as any, "triggerClickOnElement");
|
jest.spyOn(insertAutofillContentService as any, "triggerClickOnElement");
|
||||||
|
|
||||||
insertAutofillContentService["handleClickOnFieldByOpidAction"]("__1");
|
insertAutofillContentService["handleClickOnFieldByOpidAction"]("__1");
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["collectAutofillContentService"].getAutofillFieldElementByOpid
|
insertAutofillContentService["collectAutofillContentService"].getAutofillFieldElementByOpid,
|
||||||
).toBeCalledWith("__1");
|
).toBeCalledWith("__1");
|
||||||
expect((insertAutofillContentService as any)["triggerClickOnElement"]).toHaveBeenCalledWith(
|
expect((insertAutofillContentService as any)["triggerClickOnElement"]).toHaveBeenCalledWith(
|
||||||
textInput
|
textInput,
|
||||||
);
|
);
|
||||||
expect(clickEventCount).toBe(expectedClickEventCount);
|
expect(clickEventCount).toBe(expectedClickEventCount);
|
||||||
|
|
||||||
@ -544,20 +544,20 @@ describe("InsertAutofillContentService", () => {
|
|||||||
});
|
});
|
||||||
jest.spyOn(
|
jest.spyOn(
|
||||||
insertAutofillContentService["collectAutofillContentService"],
|
insertAutofillContentService["collectAutofillContentService"],
|
||||||
"getAutofillFieldElementByOpid"
|
"getAutofillFieldElementByOpid",
|
||||||
);
|
);
|
||||||
jest.spyOn(
|
jest.spyOn(
|
||||||
insertAutofillContentService as any,
|
insertAutofillContentService as any,
|
||||||
"simulateUserMouseClickAndFocusEventInteractions"
|
"simulateUserMouseClickAndFocusEventInteractions",
|
||||||
);
|
);
|
||||||
|
|
||||||
insertAutofillContentService["handleFocusOnFieldByOpidAction"]("__0");
|
insertAutofillContentService["handleFocusOnFieldByOpidAction"]("__0");
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["collectAutofillContentService"].getAutofillFieldElementByOpid
|
insertAutofillContentService["collectAutofillContentService"].getAutofillFieldElementByOpid,
|
||||||
).toBeCalledWith("__0");
|
).toBeCalledWith("__0");
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["simulateUserMouseClickAndFocusEventInteractions"]
|
insertAutofillContentService["simulateUserMouseClickAndFocusEventInteractions"],
|
||||||
).toHaveBeenCalledWith(targetInput, true);
|
).toHaveBeenCalledWith(targetInput, true);
|
||||||
expect(elementEventCount).toEqual(expectedElementEventCount);
|
expect(elementEventCount).toEqual(expectedElementEventCount);
|
||||||
});
|
});
|
||||||
@ -572,7 +572,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
insertAutofillContentService["insertValueIntoField"](element, value);
|
insertAutofillContentService["insertValueIntoField"](element, value);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"]
|
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
insertAutofillContentService["insertValueIntoField"](element, value);
|
insertAutofillContentService["insertValueIntoField"](element, value);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"]
|
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"],
|
||||||
).not.toHaveBeenCalled();
|
).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -598,7 +598,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
|
|
||||||
expect(element.innerText).toBe(value);
|
expect(element.innerText).toBe(value);
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"]
|
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"],
|
||||||
).toHaveBeenCalledWith(element, expect.any(Function));
|
).toHaveBeenCalledWith(element, expect.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -616,10 +616,10 @@ describe("InsertAutofillContentService", () => {
|
|||||||
expect(checkboxElement.checked).toBe(true);
|
expect(checkboxElement.checked).toBe(true);
|
||||||
expect(radioElement.checked).toBe(true);
|
expect(radioElement.checked).toBe(true);
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"]
|
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"],
|
||||||
).toHaveBeenCalledWith(checkboxElement, expect.any(Function));
|
).toHaveBeenCalledWith(checkboxElement, expect.any(Function));
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"]
|
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"],
|
||||||
).toHaveBeenCalledWith(radioElement, expect.any(Function));
|
).toHaveBeenCalledWith(radioElement, expect.any(Function));
|
||||||
|
|
||||||
checkboxElement.checked = false;
|
checkboxElement.checked = false;
|
||||||
@ -641,14 +641,14 @@ describe("InsertAutofillContentService", () => {
|
|||||||
|
|
||||||
expect(textInputElement.value).toBe(value1);
|
expect(textInputElement.value).toBe(value1);
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"]
|
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"],
|
||||||
).toHaveBeenCalledWith(textInputElement, expect.any(Function));
|
).toHaveBeenCalledWith(textInputElement, expect.any(Function));
|
||||||
|
|
||||||
insertAutofillContentService["insertValueIntoField"](textareaElement, value2);
|
insertAutofillContentService["insertValueIntoField"](textareaElement, value2);
|
||||||
|
|
||||||
expect(textareaElement.value).toBe(value2);
|
expect(textareaElement.value).toBe(value2);
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"]
|
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"],
|
||||||
).toHaveBeenCalledWith(textareaElement, expect.any(Function));
|
).toHaveBeenCalledWith(textareaElement, expect.any(Function));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -661,23 +661,23 @@ describe("InsertAutofillContentService", () => {
|
|||||||
jest.spyOn(insertAutofillContentService as any, "triggerPostInsertEventsOnElement");
|
jest.spyOn(insertAutofillContentService as any, "triggerPostInsertEventsOnElement");
|
||||||
jest.spyOn(insertAutofillContentService as any, "triggerFillAnimationOnElement");
|
jest.spyOn(insertAutofillContentService as any, "triggerFillAnimationOnElement");
|
||||||
const valueChangeCallback = jest.fn(
|
const valueChangeCallback = jest.fn(
|
||||||
() => ((element as FillableFormFieldElement).value = value)
|
() => ((element as FillableFormFieldElement).value = value),
|
||||||
);
|
);
|
||||||
|
|
||||||
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"](
|
insertAutofillContentService["handleInsertValueAndTriggerSimulatedEvents"](
|
||||||
element,
|
element,
|
||||||
valueChangeCallback
|
valueChangeCallback,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(insertAutofillContentService["triggerPreInsertEventsOnElement"]).toHaveBeenCalledWith(
|
expect(insertAutofillContentService["triggerPreInsertEventsOnElement"]).toHaveBeenCalledWith(
|
||||||
element
|
element,
|
||||||
);
|
);
|
||||||
expect(valueChangeCallback).toHaveBeenCalled();
|
expect(valueChangeCallback).toHaveBeenCalled();
|
||||||
expect(insertAutofillContentService["triggerPostInsertEventsOnElement"]).toHaveBeenCalledWith(
|
expect(insertAutofillContentService["triggerPostInsertEventsOnElement"]).toHaveBeenCalledWith(
|
||||||
element
|
element,
|
||||||
);
|
);
|
||||||
expect(insertAutofillContentService["triggerFillAnimationOnElement"]).toHaveBeenCalledWith(
|
expect(insertAutofillContentService["triggerFillAnimationOnElement"]).toHaveBeenCalledWith(
|
||||||
element
|
element,
|
||||||
);
|
);
|
||||||
expect((element as FillableFormFieldElement).value).toBe(value);
|
expect((element as FillableFormFieldElement).value).toBe(value);
|
||||||
});
|
});
|
||||||
@ -690,17 +690,17 @@ describe("InsertAutofillContentService", () => {
|
|||||||
const element = document.getElementById("username") as FillableFormFieldElement;
|
const element = document.getElementById("username") as FillableFormFieldElement;
|
||||||
jest.spyOn(
|
jest.spyOn(
|
||||||
insertAutofillContentService as any,
|
insertAutofillContentService as any,
|
||||||
"simulateUserMouseClickAndFocusEventInteractions"
|
"simulateUserMouseClickAndFocusEventInteractions",
|
||||||
);
|
);
|
||||||
jest.spyOn(insertAutofillContentService as any, "simulateUserKeyboardEventInteractions");
|
jest.spyOn(insertAutofillContentService as any, "simulateUserKeyboardEventInteractions");
|
||||||
|
|
||||||
insertAutofillContentService["triggerPreInsertEventsOnElement"](element);
|
insertAutofillContentService["triggerPreInsertEventsOnElement"](element);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["simulateUserMouseClickAndFocusEventInteractions"]
|
insertAutofillContentService["simulateUserMouseClickAndFocusEventInteractions"],
|
||||||
).toHaveBeenCalledWith(element);
|
).toHaveBeenCalledWith(element);
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["simulateUserKeyboardEventInteractions"]
|
insertAutofillContentService["simulateUserKeyboardEventInteractions"],
|
||||||
).toHaveBeenCalledWith(element);
|
).toHaveBeenCalledWith(element);
|
||||||
expect(element.value).toBe(initialElementValue);
|
expect(element.value).toBe(initialElementValue);
|
||||||
});
|
});
|
||||||
@ -718,10 +718,10 @@ describe("InsertAutofillContentService", () => {
|
|||||||
insertAutofillContentService["triggerPostInsertEventsOnElement"](element);
|
insertAutofillContentService["triggerPostInsertEventsOnElement"](element);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["simulateUserKeyboardEventInteractions"]
|
insertAutofillContentService["simulateUserKeyboardEventInteractions"],
|
||||||
).toHaveBeenCalledWith(element);
|
).toHaveBeenCalledWith(element);
|
||||||
expect(insertAutofillContentService["simulateInputElementChangedEvent"]).toHaveBeenCalledWith(
|
expect(insertAutofillContentService["simulateInputElementChangedEvent"]).toHaveBeenCalledWith(
|
||||||
element
|
element,
|
||||||
);
|
);
|
||||||
expect(element.blur).toHaveBeenCalled();
|
expect(element.blur).toHaveBeenCalled();
|
||||||
expect(element.value).toBe(elementValue);
|
expect(element.value).toBe(elementValue);
|
||||||
@ -738,7 +738,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
it("the element is a non-hidden hidden input type", async () => {
|
it("the element is a non-hidden hidden input type", async () => {
|
||||||
document.body.innerHTML = mockLoginForm + '<input type="hidden" />';
|
document.body.innerHTML = mockLoginForm + '<input type="hidden" />';
|
||||||
const testElement = document.querySelector(
|
const testElement = document.querySelector(
|
||||||
'input[type="hidden"]'
|
'input[type="hidden"]',
|
||||||
) as FillableFormFieldElement;
|
) as FillableFormFieldElement;
|
||||||
jest.spyOn(testElement.classList, "add");
|
jest.spyOn(testElement.classList, "add");
|
||||||
jest.spyOn(testElement.classList, "remove");
|
jest.spyOn(testElement.classList, "remove");
|
||||||
@ -778,7 +778,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
|
|
||||||
it("the element has a `visibility: hidden;` CSS rule applied to it", () => {
|
it("the element has a `visibility: hidden;` CSS rule applied to it", () => {
|
||||||
const testElement = document.querySelector(
|
const testElement = document.querySelector(
|
||||||
'input[type="password"]'
|
'input[type="password"]',
|
||||||
) as FillableFormFieldElement;
|
) as FillableFormFieldElement;
|
||||||
testElement.style.visibility = "hidden";
|
testElement.style.visibility = "hidden";
|
||||||
jest.spyOn(testElement.classList, "add");
|
jest.spyOn(testElement.classList, "add");
|
||||||
@ -793,7 +793,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
|
|
||||||
it("the element has a `display: none;` CSS rule applied to it", () => {
|
it("the element has a `display: none;` CSS rule applied to it", () => {
|
||||||
const testElement = document.querySelector(
|
const testElement = document.querySelector(
|
||||||
'input[type="password"]'
|
'input[type="password"]',
|
||||||
) as FillableFormFieldElement;
|
) as FillableFormFieldElement;
|
||||||
testElement.style.display = "none";
|
testElement.style.display = "none";
|
||||||
jest.spyOn(testElement.classList, "add");
|
jest.spyOn(testElement.classList, "add");
|
||||||
@ -810,7 +810,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
document.body.innerHTML =
|
document.body.innerHTML =
|
||||||
mockLoginForm + '<div style="opacity: 0;"><input type="email" /></div>';
|
mockLoginForm + '<div style="opacity: 0;"><input type="email" /></div>';
|
||||||
const testElement = document.querySelector(
|
const testElement = document.querySelector(
|
||||||
'input[type="email"]'
|
'input[type="email"]',
|
||||||
) as FillableFormFieldElement;
|
) as FillableFormFieldElement;
|
||||||
jest.spyOn(testElement.classList, "add");
|
jest.spyOn(testElement.classList, "add");
|
||||||
jest.spyOn(testElement.classList, "remove");
|
jest.spyOn(testElement.classList, "remove");
|
||||||
@ -826,11 +826,11 @@ describe("InsertAutofillContentService", () => {
|
|||||||
describe("will trigger the animation when...", () => {
|
describe("will trigger the animation when...", () => {
|
||||||
it("the element is a non-hidden password field", () => {
|
it("the element is a non-hidden password field", () => {
|
||||||
const testElement = document.querySelector(
|
const testElement = document.querySelector(
|
||||||
'input[type="password"]'
|
'input[type="password"]',
|
||||||
) as FillableFormFieldElement;
|
) as FillableFormFieldElement;
|
||||||
jest.spyOn(
|
jest.spyOn(
|
||||||
insertAutofillContentService["domElementVisibilityService"],
|
insertAutofillContentService["domElementVisibilityService"],
|
||||||
"isElementHiddenByCss"
|
"isElementHiddenByCss",
|
||||||
);
|
);
|
||||||
jest.spyOn(testElement.classList, "add");
|
jest.spyOn(testElement.classList, "add");
|
||||||
jest.spyOn(testElement.classList, "remove");
|
jest.spyOn(testElement.classList, "remove");
|
||||||
@ -839,20 +839,20 @@ describe("InsertAutofillContentService", () => {
|
|||||||
jest.advanceTimersByTime(200);
|
jest.advanceTimersByTime(200);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
insertAutofillContentService["domElementVisibilityService"].isElementHiddenByCss
|
insertAutofillContentService["domElementVisibilityService"].isElementHiddenByCss,
|
||||||
).toHaveBeenCalledWith(testElement);
|
).toHaveBeenCalledWith(testElement);
|
||||||
expect(testElement.classList.add).toHaveBeenCalledWith(
|
expect(testElement.classList.add).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the element is a non-hidden email input", () => {
|
it("the element is a non-hidden email input", () => {
|
||||||
document.body.innerHTML = mockLoginForm + '<input type="email" />';
|
document.body.innerHTML = mockLoginForm + '<input type="email" />';
|
||||||
const testElement = document.querySelector(
|
const testElement = document.querySelector(
|
||||||
'input[type="email"]'
|
'input[type="email"]',
|
||||||
) as FillableFormFieldElement;
|
) as FillableFormFieldElement;
|
||||||
jest.spyOn(testElement.classList, "add");
|
jest.spyOn(testElement.classList, "add");
|
||||||
jest.spyOn(testElement.classList, "remove");
|
jest.spyOn(testElement.classList, "remove");
|
||||||
@ -861,17 +861,17 @@ describe("InsertAutofillContentService", () => {
|
|||||||
jest.advanceTimersByTime(200);
|
jest.advanceTimersByTime(200);
|
||||||
|
|
||||||
expect(testElement.classList.add).toHaveBeenCalledWith(
|
expect(testElement.classList.add).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the element is a non-hidden text input", () => {
|
it("the element is a non-hidden text input", () => {
|
||||||
document.body.innerHTML = mockLoginForm + '<input type="text" />';
|
document.body.innerHTML = mockLoginForm + '<input type="text" />';
|
||||||
const testElement = document.querySelector(
|
const testElement = document.querySelector(
|
||||||
'input[type="text"]'
|
'input[type="text"]',
|
||||||
) as FillableFormFieldElement;
|
) as FillableFormFieldElement;
|
||||||
jest.spyOn(testElement.classList, "add");
|
jest.spyOn(testElement.classList, "add");
|
||||||
jest.spyOn(testElement.classList, "remove");
|
jest.spyOn(testElement.classList, "remove");
|
||||||
@ -880,17 +880,17 @@ describe("InsertAutofillContentService", () => {
|
|||||||
jest.advanceTimersByTime(200);
|
jest.advanceTimersByTime(200);
|
||||||
|
|
||||||
expect(testElement.classList.add).toHaveBeenCalledWith(
|
expect(testElement.classList.add).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("the element is a non-hidden number input", () => {
|
it("the element is a non-hidden number input", () => {
|
||||||
document.body.innerHTML = mockLoginForm + '<input type="number" />';
|
document.body.innerHTML = mockLoginForm + '<input type="number" />';
|
||||||
const testElement = document.querySelector(
|
const testElement = document.querySelector(
|
||||||
'input[type="number"]'
|
'input[type="number"]',
|
||||||
) as FillableFormFieldElement;
|
) as FillableFormFieldElement;
|
||||||
jest.spyOn(testElement.classList, "add");
|
jest.spyOn(testElement.classList, "add");
|
||||||
jest.spyOn(testElement.classList, "remove");
|
jest.spyOn(testElement.classList, "remove");
|
||||||
@ -899,10 +899,10 @@ describe("InsertAutofillContentService", () => {
|
|||||||
jest.advanceTimersByTime(200);
|
jest.advanceTimersByTime(200);
|
||||||
|
|
||||||
expect(testElement.classList.add).toHaveBeenCalledWith(
|
expect(testElement.classList.add).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -916,10 +916,10 @@ describe("InsertAutofillContentService", () => {
|
|||||||
jest.advanceTimersByTime(200);
|
jest.advanceTimersByTime(200);
|
||||||
|
|
||||||
expect(testElement.classList.add).toHaveBeenCalledWith(
|
expect(testElement.classList.add).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -933,10 +933,10 @@ describe("InsertAutofillContentService", () => {
|
|||||||
jest.advanceTimersByTime(200);
|
jest.advanceTimersByTime(200);
|
||||||
|
|
||||||
expect(testElement.classList.add).toHaveBeenCalledWith(
|
expect(testElement.classList.add).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -950,10 +950,10 @@ describe("InsertAutofillContentService", () => {
|
|||||||
jest.advanceTimersByTime(200);
|
jest.advanceTimersByTime(200);
|
||||||
|
|
||||||
expect(testElement.classList.add).toHaveBeenCalledWith(
|
expect(testElement.classList.add).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
expect(testElement.classList.remove).toHaveBeenCalledWith(
|
||||||
"com-bitwarden-browser-animated-fill"
|
"com-bitwarden-browser-animated-fill",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1009,11 +1009,11 @@ describe("InsertAutofillContentService", () => {
|
|||||||
insertAutofillContentService["simulateUserMouseClickAndFocusEventInteractions"](inputElement);
|
insertAutofillContentService["simulateUserMouseClickAndFocusEventInteractions"](inputElement);
|
||||||
|
|
||||||
expect(insertAutofillContentService["triggerClickOnElement"]).toHaveBeenCalledWith(
|
expect(insertAutofillContentService["triggerClickOnElement"]).toHaveBeenCalledWith(
|
||||||
inputElement
|
inputElement,
|
||||||
);
|
);
|
||||||
expect(insertAutofillContentService["triggerFocusOnElement"]).toHaveBeenCalledWith(
|
expect(insertAutofillContentService["triggerFocusOnElement"]).toHaveBeenCalledWith(
|
||||||
inputElement,
|
inputElement,
|
||||||
false
|
false,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1027,7 +1027,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
|
|
||||||
[EVENTS.KEYDOWN, EVENTS.KEYPRESS, EVENTS.KEYUP].forEach((eventName) => {
|
[EVENTS.KEYDOWN, EVENTS.KEYPRESS, EVENTS.KEYUP].forEach((eventName) => {
|
||||||
expect(inputElement.dispatchEvent).toHaveBeenCalledWith(
|
expect(inputElement.dispatchEvent).toHaveBeenCalledWith(
|
||||||
new KeyboardEvent(eventName, { bubbles: true })
|
new KeyboardEvent(eventName, { bubbles: true }),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1042,7 +1042,7 @@ describe("InsertAutofillContentService", () => {
|
|||||||
|
|
||||||
[EVENTS.INPUT, EVENTS.CHANGE].forEach((eventName) => {
|
[EVENTS.INPUT, EVENTS.CHANGE].forEach((eventName) => {
|
||||||
expect(inputElement.dispatchEvent).toHaveBeenCalledWith(
|
expect(inputElement.dispatchEvent).toHaveBeenCalledWith(
|
||||||
new Event(eventName, { bubbles: true })
|
new Event(eventName, { bubbles: true }),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ class InsertAutofillContentService implements InsertAutofillContentServiceInterf
|
|||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
domElementVisibilityService: DomElementVisibilityService,
|
domElementVisibilityService: DomElementVisibilityService,
|
||||||
collectAutofillContentService: CollectAutofillContentService
|
collectAutofillContentService: CollectAutofillContentService,
|
||||||
) {
|
) {
|
||||||
this.domElementVisibilityService = domElementVisibilityService;
|
this.domElementVisibilityService = domElementVisibilityService;
|
||||||
this.collectAutofillContentService = collectAutofillContentService;
|
this.collectAutofillContentService = collectAutofillContentService;
|
||||||
@ -97,8 +97,8 @@ class InsertAutofillContentService implements InsertAutofillContentServiceInterf
|
|||||||
this.collectAutofillContentService.queryAllTreeWalkerNodes(
|
this.collectAutofillContentService.queryAllTreeWalkerNodes(
|
||||||
document.documentElement,
|
document.documentElement,
|
||||||
(node: Node) => node instanceof HTMLInputElement && node.type === "password",
|
(node: Node) => node instanceof HTMLInputElement && node.type === "password",
|
||||||
false
|
false,
|
||||||
)?.length
|
)?.length,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class InsertAutofillContentService implements InsertAutofillContentServiceInterf
|
|||||||
*/
|
*/
|
||||||
private runFillScriptAction = (
|
private runFillScriptAction = (
|
||||||
[action, opid, value]: FillScript,
|
[action, opid, value]: FillScript,
|
||||||
actionIndex: number
|
actionIndex: number,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
if (!opid || !this.autofillInsertActions[action]) {
|
if (!opid || !this.autofillInsertActions[action]) {
|
||||||
return;
|
return;
|
||||||
@ -150,7 +150,7 @@ class InsertAutofillContentService implements InsertAutofillContentServiceInterf
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.autofillInsertActions[action]({ opid, value });
|
this.autofillInsertActions[action]({ opid, value });
|
||||||
resolve();
|
resolve();
|
||||||
}, delayActionsInMilliseconds * actionIndex)
|
}, delayActionsInMilliseconds * actionIndex),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ class InsertAutofillContentService implements InsertAutofillContentServiceInterf
|
|||||||
*/
|
*/
|
||||||
private handleInsertValueAndTriggerSimulatedEvents(
|
private handleInsertValueAndTriggerSimulatedEvents(
|
||||||
element: FormFieldElement,
|
element: FormFieldElement,
|
||||||
valueChangeCallback: CallableFunction
|
valueChangeCallback: CallableFunction,
|
||||||
): void {
|
): void {
|
||||||
this.triggerPreInsertEventsOnElement(element);
|
this.triggerPreInsertEventsOnElement(element);
|
||||||
valueChangeCallback();
|
valueChangeCallback();
|
||||||
@ -341,7 +341,7 @@ class InsertAutofillContentService implements InsertAutofillContentServiceInterf
|
|||||||
*/
|
*/
|
||||||
private simulateUserMouseClickAndFocusEventInteractions(
|
private simulateUserMouseClickAndFocusEventInteractions(
|
||||||
element: FormFieldElement,
|
element: FormFieldElement,
|
||||||
shouldResetValue = false
|
shouldResetValue = false,
|
||||||
): void {
|
): void {
|
||||||
this.triggerClickOnElement(element);
|
this.triggerClickOnElement(element);
|
||||||
this.triggerFocusOnElement(element, shouldResetValue);
|
this.triggerFocusOnElement(element, shouldResetValue);
|
||||||
|
@ -52,7 +52,7 @@ describe("setElementStyles", () => {
|
|||||||
const domParser = new DOMParser();
|
const domParser = new DOMParser();
|
||||||
const testDivDOM = domParser.parseFromString(
|
const testDivDOM = domParser.parseFromString(
|
||||||
"<div>This is an unexciting div.</div>",
|
"<div>This is an unexciting div.</div>",
|
||||||
"text/html"
|
"text/html",
|
||||||
);
|
);
|
||||||
const testDiv = testDivDOM.querySelector("div");
|
const testDiv = testDivDOM.querySelector("div");
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ describe("setElementStyles", () => {
|
|||||||
const domParser = new DOMParser();
|
const domParser = new DOMParser();
|
||||||
const testDivDOM = domParser.parseFromString(
|
const testDivDOM = domParser.parseFromString(
|
||||||
"<div>This is an unexciting div.</div>",
|
"<div>This is an unexciting div.</div>",
|
||||||
"text/html"
|
"text/html",
|
||||||
);
|
);
|
||||||
const testDiv = testDivDOM.querySelector("div");
|
const testDiv = testDivDOM.querySelector("div");
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ describe("setElementStyles", () => {
|
|||||||
const domParser = new DOMParser();
|
const domParser = new DOMParser();
|
||||||
const testDivDOM = domParser.parseFromString(
|
const testDivDOM = domParser.parseFromString(
|
||||||
"<div>This is an unexciting div.</div>",
|
"<div>This is an unexciting div.</div>",
|
||||||
"text/html"
|
"text/html",
|
||||||
);
|
);
|
||||||
const testDiv = testDivDOM.querySelector("div");
|
const testDiv = testDivDOM.querySelector("div");
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ describe("setElementStyles", () => {
|
|||||||
const domParser = new DOMParser();
|
const domParser = new DOMParser();
|
||||||
const testDivDOM = domParser.parseFromString(
|
const testDivDOM = domParser.parseFromString(
|
||||||
"<div>This is an unexciting div.</div>",
|
"<div>This is an unexciting div.</div>",
|
||||||
"text/html"
|
"text/html",
|
||||||
);
|
);
|
||||||
const testDiv = testDivDOM.querySelector("div");
|
const testDiv = testDivDOM.querySelector("div");
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ function buildSvgDomElement(svgString: string, ariaHidden = true): HTMLElement {
|
|||||||
*/
|
*/
|
||||||
async function sendExtensionMessage(
|
async function sendExtensionMessage(
|
||||||
command: string,
|
command: string,
|
||||||
options: Record<string, any> = {}
|
options: Record<string, any> = {},
|
||||||
): Promise<any | void> {
|
): Promise<any | void> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
chrome.runtime.sendMessage(Object.assign({ command }, options), (response) => {
|
chrome.runtime.sendMessage(Object.assign({ command }, options), (response) => {
|
||||||
@ -88,7 +88,7 @@ async function sendExtensionMessage(
|
|||||||
function setElementStyles(
|
function setElementStyles(
|
||||||
element: HTMLElement,
|
element: HTMLElement,
|
||||||
styles: Partial<CSSStyleDeclaration>,
|
styles: Partial<CSSStyleDeclaration>,
|
||||||
priority?: boolean
|
priority?: boolean,
|
||||||
) {
|
) {
|
||||||
if (!element || !styles || !Object.keys(styles).length) {
|
if (!element || !styles || !Object.keys(styles).length) {
|
||||||
return;
|
return;
|
||||||
@ -98,7 +98,7 @@ function setElementStyles(
|
|||||||
element.style.setProperty(
|
element.style.setProperty(
|
||||||
styleProperty.replace(/([a-z])([A-Z])/g, "$1-$2"), // Convert camelCase to kebab-case
|
styleProperty.replace(/([a-z])([A-Z])/g, "$1-$2"), // Convert camelCase to kebab-case
|
||||||
styles[styleProperty],
|
styles[styleProperty],
|
||||||
priority ? "important" : undefined
|
priority ? "important" : undefined,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ export default class CommandsBackground {
|
|||||||
private passwordGenerationService: PasswordGenerationServiceAbstraction,
|
private passwordGenerationService: PasswordGenerationServiceAbstraction,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private vaultTimeoutService: VaultTimeoutService,
|
private vaultTimeoutService: VaultTimeoutService,
|
||||||
private authService: AuthService
|
private authService: AuthService,
|
||||||
) {
|
) {
|
||||||
this.isSafari = this.platformUtilsService.isSafari();
|
this.isSafari = this.platformUtilsService.isSafari();
|
||||||
this.isVivaldi = this.platformUtilsService.isVivaldi();
|
this.isVivaldi = this.platformUtilsService.isVivaldi();
|
||||||
@ -85,7 +85,7 @@ export default class CommandsBackground {
|
|||||||
await BrowserApi.tabSendMessageData(
|
await BrowserApi.tabSendMessageData(
|
||||||
tab,
|
tab,
|
||||||
"addToLockedVaultPendingNotifications",
|
"addToLockedVaultPendingNotifications",
|
||||||
retryMessage
|
retryMessage,
|
||||||
);
|
);
|
||||||
|
|
||||||
await openUnlockPopout(tab);
|
await openUnlockPopout(tab);
|
||||||
|
@ -14,7 +14,7 @@ export default class IdleBackground {
|
|||||||
constructor(
|
constructor(
|
||||||
private vaultTimeoutService: VaultTimeoutService,
|
private vaultTimeoutService: VaultTimeoutService,
|
||||||
private stateService: BrowserStateService,
|
private stateService: BrowserStateService,
|
||||||
private notificationsService: NotificationsService
|
private notificationsService: NotificationsService,
|
||||||
) {
|
) {
|
||||||
this.idle = chrome.idle || (browser != null ? browser.idle : null);
|
this.idle = chrome.idle || (browser != null ? browser.idle : null);
|
||||||
}
|
}
|
||||||
|
@ -284,17 +284,17 @@ export default class MainBackground {
|
|||||||
BrowserApi.manifestVersion === 3
|
BrowserApi.manifestVersion === 3
|
||||||
? new LocalBackedSessionStorageService(
|
? new LocalBackedSessionStorageService(
|
||||||
new EncryptServiceImplementation(this.cryptoFunctionService, this.logService, false),
|
new EncryptServiceImplementation(this.cryptoFunctionService, this.logService, false),
|
||||||
new KeyGenerationService(this.cryptoFunctionService)
|
new KeyGenerationService(this.cryptoFunctionService),
|
||||||
)
|
)
|
||||||
: new BackgroundMemoryStorageService();
|
: new BackgroundMemoryStorageService();
|
||||||
this.globalStateProvider = new DefaultGlobalStateProvider(
|
this.globalStateProvider = new DefaultGlobalStateProvider(
|
||||||
this.memoryStorageService as BackgroundMemoryStorageService,
|
this.memoryStorageService as BackgroundMemoryStorageService,
|
||||||
this.storageService as BrowserLocalStorageService
|
this.storageService as BrowserLocalStorageService,
|
||||||
);
|
);
|
||||||
this.accountService = new AccountServiceImplementation(
|
this.accountService = new AccountServiceImplementation(
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.logService,
|
this.logService,
|
||||||
this.globalStateProvider
|
this.globalStateProvider,
|
||||||
);
|
);
|
||||||
this.stateService = new BrowserStateService(
|
this.stateService = new BrowserStateService(
|
||||||
this.storageService,
|
this.storageService,
|
||||||
@ -302,7 +302,7 @@ export default class MainBackground {
|
|||||||
this.memoryStorageService,
|
this.memoryStorageService,
|
||||||
this.logService,
|
this.logService,
|
||||||
new StateFactory(GlobalState, Account),
|
new StateFactory(GlobalState, Account),
|
||||||
this.accountService
|
this.accountService,
|
||||||
);
|
);
|
||||||
this.platformUtilsService = new BrowserPlatformUtilsService(
|
this.platformUtilsService = new BrowserPlatformUtilsService(
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
@ -324,14 +324,14 @@ export default class MainBackground {
|
|||||||
return promise.then((result) => result.response === "unlocked");
|
return promise.then((result) => result.response === "unlocked");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
window
|
window,
|
||||||
);
|
);
|
||||||
this.i18nService = new BrowserI18nService(BrowserApi.getUILanguage(), this.stateService);
|
this.i18nService = new BrowserI18nService(BrowserApi.getUILanguage(), this.stateService);
|
||||||
this.encryptService = flagEnabled("multithreadDecryption")
|
this.encryptService = flagEnabled("multithreadDecryption")
|
||||||
? new MultithreadEncryptServiceImplementation(
|
? new MultithreadEncryptServiceImplementation(
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.logService,
|
this.logService,
|
||||||
true
|
true,
|
||||||
)
|
)
|
||||||
: new EncryptServiceImplementation(this.cryptoFunctionService, this.logService, true);
|
: new EncryptServiceImplementation(this.cryptoFunctionService, this.logService, true);
|
||||||
this.cryptoService = new BrowserCryptoService(
|
this.cryptoService = new BrowserCryptoService(
|
||||||
@ -339,7 +339,7 @@ export default class MainBackground {
|
|||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.logService,
|
this.logService,
|
||||||
this.stateService
|
this.stateService,
|
||||||
);
|
);
|
||||||
this.tokenService = new TokenService(this.stateService);
|
this.tokenService = new TokenService(this.stateService);
|
||||||
this.appIdService = new AppIdService(this.storageService);
|
this.appIdService = new AppIdService(this.storageService);
|
||||||
@ -349,20 +349,20 @@ export default class MainBackground {
|
|||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.environmentService,
|
this.environmentService,
|
||||||
this.appIdService,
|
this.appIdService,
|
||||||
(expired: boolean) => this.logout(expired)
|
(expired: boolean) => this.logout(expired),
|
||||||
);
|
);
|
||||||
this.settingsService = new BrowserSettingsService(this.stateService);
|
this.settingsService = new BrowserSettingsService(this.stateService);
|
||||||
this.fileUploadService = new FileUploadService(this.logService);
|
this.fileUploadService = new FileUploadService(this.logService);
|
||||||
this.cipherFileUploadService = new CipherFileUploadService(
|
this.cipherFileUploadService = new CipherFileUploadService(
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.fileUploadService
|
this.fileUploadService,
|
||||||
);
|
);
|
||||||
this.searchService = new SearchService(this.logService, this.i18nService);
|
this.searchService = new SearchService(this.logService, this.i18nService);
|
||||||
|
|
||||||
this.collectionService = new CollectionService(
|
this.collectionService = new CollectionService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.stateService
|
this.stateService,
|
||||||
);
|
);
|
||||||
this.syncNotifierService = new SyncNotifierService();
|
this.syncNotifierService = new SyncNotifierService();
|
||||||
this.organizationService = new BrowserOrganizationService(this.stateService);
|
this.organizationService = new BrowserOrganizationService(this.stateService);
|
||||||
@ -370,7 +370,7 @@ export default class MainBackground {
|
|||||||
this.policyApiService = new PolicyApiService(
|
this.policyApiService = new PolicyApiService(
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.stateService
|
this.stateService,
|
||||||
);
|
);
|
||||||
this.keyConnectorService = new KeyConnectorService(
|
this.keyConnectorService = new KeyConnectorService(
|
||||||
this.stateService,
|
this.stateService,
|
||||||
@ -380,7 +380,7 @@ export default class MainBackground {
|
|||||||
this.logService,
|
this.logService,
|
||||||
this.organizationService,
|
this.organizationService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
logoutCallback
|
logoutCallback,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.passwordStrengthService = new PasswordStrengthService();
|
this.passwordStrengthService = new PasswordStrengthService();
|
||||||
@ -388,7 +388,7 @@ export default class MainBackground {
|
|||||||
this.passwordGenerationService = new PasswordGenerationService(
|
this.passwordGenerationService = new PasswordGenerationService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.stateService
|
this.stateService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.twoFactorService = new TwoFactorService(this.i18nService, this.platformUtilsService);
|
this.twoFactorService = new TwoFactorService(this.i18nService, this.platformUtilsService);
|
||||||
@ -412,7 +412,7 @@ export default class MainBackground {
|
|||||||
this.appIdService,
|
this.appIdService,
|
||||||
this.devicesApiService,
|
this.devicesApiService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.platformUtilsService
|
this.platformUtilsService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.devicesService = new DevicesServiceImplementation(this.devicesApiService);
|
this.devicesService = new DevicesServiceImplementation(this.devicesApiService);
|
||||||
@ -436,7 +436,7 @@ export default class MainBackground {
|
|||||||
this.passwordStrengthService,
|
this.passwordStrengthService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.deviceTrustCryptoService,
|
this.deviceTrustCryptoService,
|
||||||
this.authRequestCryptoService
|
this.authRequestCryptoService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.userVerificationApiService = new UserVerificationApiService(this.apiService);
|
this.userVerificationApiService = new UserVerificationApiService(this.apiService);
|
||||||
@ -445,7 +445,7 @@ export default class MainBackground {
|
|||||||
this.stateService,
|
this.stateService,
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.userVerificationApiService
|
this.userVerificationApiService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.configApiService = new ConfigApiService(this.apiService, this.authService);
|
this.configApiService = new ConfigApiService(this.apiService, this.authService);
|
||||||
@ -456,7 +456,7 @@ export default class MainBackground {
|
|||||||
this.authService,
|
this.authService,
|
||||||
this.environmentService,
|
this.environmentService,
|
||||||
this.logService,
|
this.logService,
|
||||||
true
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.cipherService = new CipherService(
|
this.cipherService = new CipherService(
|
||||||
@ -468,13 +468,13 @@ export default class MainBackground {
|
|||||||
this.stateService,
|
this.stateService,
|
||||||
this.encryptService,
|
this.encryptService,
|
||||||
this.cipherFileUploadService,
|
this.cipherFileUploadService,
|
||||||
this.configService
|
this.configService,
|
||||||
);
|
);
|
||||||
this.folderService = new BrowserFolderService(
|
this.folderService = new BrowserFolderService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.stateService
|
this.stateService,
|
||||||
);
|
);
|
||||||
this.folderApiService = new FolderApiService(this.folderService, this.apiService);
|
this.folderApiService = new FolderApiService(this.folderService, this.apiService);
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ export default class MainBackground {
|
|||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.userVerificationService
|
this.userVerificationService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.vaultFilterService = new VaultFilterService(
|
this.vaultFilterService = new VaultFilterService(
|
||||||
@ -492,7 +492,7 @@ export default class MainBackground {
|
|||||||
this.folderService,
|
this.folderService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
this.policyService
|
this.policyService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.vaultTimeoutService = new VaultTimeoutService(
|
this.vaultTimeoutService = new VaultTimeoutService(
|
||||||
@ -507,19 +507,19 @@ export default class MainBackground {
|
|||||||
this.authService,
|
this.authService,
|
||||||
this.vaultTimeoutSettingsService,
|
this.vaultTimeoutSettingsService,
|
||||||
lockedCallback,
|
lockedCallback,
|
||||||
logoutCallback
|
logoutCallback,
|
||||||
);
|
);
|
||||||
this.containerService = new ContainerService(this.cryptoService, this.encryptService);
|
this.containerService = new ContainerService(this.cryptoService, this.encryptService);
|
||||||
this.sendService = new BrowserSendService(
|
this.sendService = new BrowserSendService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.stateService
|
this.stateService,
|
||||||
);
|
);
|
||||||
this.sendApiService = new SendApiService(
|
this.sendApiService = new SendApiService(
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.fileUploadService,
|
this.fileUploadService,
|
||||||
this.sendService
|
this.sendService,
|
||||||
);
|
);
|
||||||
this.providerService = new ProviderService(this.stateService);
|
this.providerService = new ProviderService(this.stateService);
|
||||||
this.syncService = new SyncService(
|
this.syncService = new SyncService(
|
||||||
@ -539,18 +539,18 @@ export default class MainBackground {
|
|||||||
this.folderApiService,
|
this.folderApiService,
|
||||||
this.organizationService,
|
this.organizationService,
|
||||||
this.sendApiService,
|
this.sendApiService,
|
||||||
logoutCallback
|
logoutCallback,
|
||||||
);
|
);
|
||||||
this.eventUploadService = new EventUploadService(
|
this.eventUploadService = new EventUploadService(
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.logService
|
this.logService,
|
||||||
);
|
);
|
||||||
this.eventCollectionService = new EventCollectionService(
|
this.eventCollectionService = new EventCollectionService(
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.organizationService,
|
this.organizationService,
|
||||||
this.eventUploadService
|
this.eventUploadService,
|
||||||
);
|
);
|
||||||
this.totpService = new TotpService(this.cryptoFunctionService, this.logService);
|
this.totpService = new TotpService(this.cryptoFunctionService, this.logService);
|
||||||
|
|
||||||
@ -561,7 +561,7 @@ export default class MainBackground {
|
|||||||
this.eventCollectionService,
|
this.eventCollectionService,
|
||||||
this.logService,
|
this.logService,
|
||||||
this.settingsService,
|
this.settingsService,
|
||||||
this.userVerificationService
|
this.userVerificationService,
|
||||||
);
|
);
|
||||||
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ export default class MainBackground {
|
|||||||
this.importApiService,
|
this.importApiService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
this.cryptoService
|
this.cryptoService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.exportService = new VaultExportService(
|
this.exportService = new VaultExportService(
|
||||||
@ -582,7 +582,7 @@ export default class MainBackground {
|
|||||||
this.apiService,
|
this.apiService,
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.stateService
|
this.stateService,
|
||||||
);
|
);
|
||||||
this.notificationsService = new NotificationsService(
|
this.notificationsService = new NotificationsService(
|
||||||
this.logService,
|
this.logService,
|
||||||
@ -593,7 +593,7 @@ export default class MainBackground {
|
|||||||
logoutCallback,
|
logoutCallback,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.authService,
|
this.authService,
|
||||||
this.messagingService
|
this.messagingService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.fido2UserInterfaceService = new BrowserFido2UserInterfaceService(this.authService);
|
this.fido2UserInterfaceService = new BrowserFido2UserInterfaceService(this.authService);
|
||||||
@ -601,14 +601,14 @@ export default class MainBackground {
|
|||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.fido2UserInterfaceService,
|
this.fido2UserInterfaceService,
|
||||||
this.syncService,
|
this.syncService,
|
||||||
this.logService
|
this.logService,
|
||||||
);
|
);
|
||||||
this.fido2ClientService = new Fido2ClientService(
|
this.fido2ClientService = new Fido2ClientService(
|
||||||
this.fido2AuthenticatorService,
|
this.fido2AuthenticatorService,
|
||||||
this.configService,
|
this.configService,
|
||||||
this.authService,
|
this.authService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.logService
|
this.logService,
|
||||||
);
|
);
|
||||||
|
|
||||||
const systemUtilsServiceReloadCallback = () => {
|
const systemUtilsServiceReloadCallback = () => {
|
||||||
@ -624,7 +624,7 @@ export default class MainBackground {
|
|||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
systemUtilsServiceReloadCallback,
|
systemUtilsServiceReloadCallback,
|
||||||
this.stateService
|
this.stateService,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Other fields
|
// Other fields
|
||||||
@ -642,7 +642,7 @@ export default class MainBackground {
|
|||||||
this.environmentService,
|
this.environmentService,
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.logService,
|
this.logService,
|
||||||
this.configService
|
this.configService,
|
||||||
);
|
);
|
||||||
this.nativeMessagingBackground = new NativeMessagingBackground(
|
this.nativeMessagingBackground = new NativeMessagingBackground(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
@ -654,14 +654,14 @@ export default class MainBackground {
|
|||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.logService,
|
this.logService,
|
||||||
this.authService
|
this.authService,
|
||||||
);
|
);
|
||||||
this.commandsBackground = new CommandsBackground(
|
this.commandsBackground = new CommandsBackground(
|
||||||
this,
|
this,
|
||||||
this.passwordGenerationService,
|
this.passwordGenerationService,
|
||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.vaultTimeoutService,
|
this.vaultTimeoutService,
|
||||||
this.authService
|
this.authService,
|
||||||
);
|
);
|
||||||
this.notificationBackground = new NotificationBackground(
|
this.notificationBackground = new NotificationBackground(
|
||||||
this.autofillService,
|
this.autofillService,
|
||||||
@ -670,7 +670,7 @@ export default class MainBackground {
|
|||||||
this.policyService,
|
this.policyService,
|
||||||
this.folderService,
|
this.folderService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.environmentService
|
this.environmentService,
|
||||||
);
|
);
|
||||||
this.overlayBackground = new OverlayBackground(
|
this.overlayBackground = new OverlayBackground(
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
@ -679,12 +679,12 @@ export default class MainBackground {
|
|||||||
this.environmentService,
|
this.environmentService,
|
||||||
this.settingsService,
|
this.settingsService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.i18nService
|
this.i18nService,
|
||||||
);
|
);
|
||||||
this.tabsBackground = new TabsBackground(
|
this.tabsBackground = new TabsBackground(
|
||||||
this,
|
this,
|
||||||
this.notificationBackground,
|
this.notificationBackground,
|
||||||
this.overlayBackground
|
this.overlayBackground,
|
||||||
);
|
);
|
||||||
if (!this.popupOnlyContext) {
|
if (!this.popupOnlyContext) {
|
||||||
const contextMenuClickedHandler = new ContextMenuClickedHandler(
|
const contextMenuClickedHandler = new ContextMenuClickedHandler(
|
||||||
@ -712,7 +712,7 @@ export default class MainBackground {
|
|||||||
this.stateService,
|
this.stateService,
|
||||||
this.totpService,
|
this.totpService,
|
||||||
this.eventCollectionService,
|
this.eventCollectionService,
|
||||||
this.userVerificationService
|
this.userVerificationService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.contextMenusBackground = new ContextMenusBackground(contextMenuClickedHandler);
|
this.contextMenusBackground = new ContextMenusBackground(contextMenuClickedHandler);
|
||||||
@ -721,18 +721,18 @@ export default class MainBackground {
|
|||||||
this.idleBackground = new IdleBackground(
|
this.idleBackground = new IdleBackground(
|
||||||
this.vaultTimeoutService,
|
this.vaultTimeoutService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.notificationsService
|
this.notificationsService,
|
||||||
);
|
);
|
||||||
this.webRequestBackground = new WebRequestBackground(
|
this.webRequestBackground = new WebRequestBackground(
|
||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.authService
|
this.authService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.usernameGenerationService = new UsernameGenerationService(
|
this.usernameGenerationService = new UsernameGenerationService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.apiService
|
this.apiService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.avatarUpdateService = new AvatarUpdateService(this.apiService, this.stateService);
|
this.avatarUpdateService = new AvatarUpdateService(this.apiService, this.stateService);
|
||||||
@ -741,13 +741,13 @@ export default class MainBackground {
|
|||||||
this.mainContextMenuHandler = new MainContextMenuHandler(
|
this.mainContextMenuHandler = new MainContextMenuHandler(
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.logService
|
this.logService,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.cipherContextMenuHandler = new CipherContextMenuHandler(
|
this.cipherContextMenuHandler = new CipherContextMenuHandler(
|
||||||
this.mainContextMenuHandler,
|
this.mainContextMenuHandler,
|
||||||
this.authService,
|
this.authService,
|
||||||
this.cipherService
|
this.cipherService,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -928,7 +928,7 @@ export default class MainBackground {
|
|||||||
tab: tab,
|
tab: tab,
|
||||||
sender: sender,
|
sender: sender,
|
||||||
},
|
},
|
||||||
options
|
options,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ export class NativeMessagingBackground {
|
|||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private authService: AuthService
|
private authService: AuthService,
|
||||||
) {
|
) {
|
||||||
this.stateService.setBiometricFingerprintValidated(false);
|
this.stateService.setBiometricFingerprintValidated(false);
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ export class NativeMessagingBackground {
|
|||||||
const decrypted = await this.cryptoFunctionService.rsaDecrypt(
|
const decrypted = await this.cryptoFunctionService.rsaDecrypt(
|
||||||
encrypted,
|
encrypted,
|
||||||
this.privateKey,
|
this.privateKey,
|
||||||
EncryptionAlgorithm
|
EncryptionAlgorithm,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.validatingFingerprint) {
|
if (this.validatingFingerprint) {
|
||||||
@ -278,7 +278,7 @@ export class NativeMessagingBackground {
|
|||||||
let message = rawMessage as ReceiveMessage;
|
let message = rawMessage as ReceiveMessage;
|
||||||
if (!this.platformUtilsService.isSafari()) {
|
if (!this.platformUtilsService.isSafari()) {
|
||||||
message = JSON.parse(
|
message = JSON.parse(
|
||||||
await this.cryptoService.decryptToUtf8(rawMessage as EncString, this.sharedSecret)
|
await this.cryptoService.decryptToUtf8(rawMessage as EncString, this.sharedSecret),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ export class NativeMessagingBackground {
|
|||||||
try {
|
try {
|
||||||
if (message.userKeyB64) {
|
if (message.userKeyB64) {
|
||||||
const userKey = new SymmetricCryptoKey(
|
const userKey = new SymmetricCryptoKey(
|
||||||
Utils.fromB64ToArray(message.userKeyB64)
|
Utils.fromB64ToArray(message.userKeyB64),
|
||||||
) as UserKey;
|
) as UserKey;
|
||||||
await this.cryptoService.setUserKey(userKey);
|
await this.cryptoService.setUserKey(userKey);
|
||||||
} else if (message.keyB64) {
|
} else if (message.keyB64) {
|
||||||
@ -340,11 +340,11 @@ export class NativeMessagingBackground {
|
|||||||
throw new Error("No encrypted user key found");
|
throw new Error("No encrypted user key found");
|
||||||
}
|
}
|
||||||
const masterKey = new SymmetricCryptoKey(
|
const masterKey = new SymmetricCryptoKey(
|
||||||
Utils.fromB64ToArray(message.keyB64)
|
Utils.fromB64ToArray(message.keyB64),
|
||||||
) as MasterKey;
|
) as MasterKey;
|
||||||
const userKey = await this.cryptoService.decryptUserKeyWithMasterKey(
|
const userKey = await this.cryptoService.decryptUserKeyWithMasterKey(
|
||||||
masterKey,
|
masterKey,
|
||||||
new EncString(encUserKey)
|
new EncString(encUserKey),
|
||||||
);
|
);
|
||||||
await this.cryptoService.setMasterKey(masterKey);
|
await this.cryptoService.setMasterKey(masterKey);
|
||||||
await this.cryptoService.setUserKey(userKey);
|
await this.cryptoService.setUserKey(userKey);
|
||||||
@ -424,7 +424,7 @@ export class NativeMessagingBackground {
|
|||||||
private async showFingerprintDialog() {
|
private async showFingerprintDialog() {
|
||||||
const fingerprint = await this.cryptoService.getFingerprint(
|
const fingerprint = await this.cryptoService.getFingerprint(
|
||||||
await this.stateService.getUserId(),
|
await this.stateService.getUserId(),
|
||||||
this.publicKey
|
this.publicKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.messagingService.send("showNativeMessagingFinterprintDialog", {
|
this.messagingService.send("showNativeMessagingFinterprintDialog", {
|
||||||
|
@ -41,7 +41,7 @@ export default class RuntimeBackground {
|
|||||||
private environmentService: BrowserEnvironmentService,
|
private environmentService: BrowserEnvironmentService,
|
||||||
private messagingService: MessagingService,
|
private messagingService: MessagingService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private configService: ConfigServiceAbstraction
|
private configService: ConfigServiceAbstraction,
|
||||||
) {
|
) {
|
||||||
// onInstalled listener must be wired up before anything else, so we do it in the ctor
|
// onInstalled listener must be wired up before anything else, so we do it in the ctor
|
||||||
chrome.runtime.onInstalled.addListener((details: any) => {
|
chrome.runtime.onInstalled.addListener((details: any) => {
|
||||||
@ -58,7 +58,7 @@ export default class RuntimeBackground {
|
|||||||
const backgroundMessageListener = (
|
const backgroundMessageListener = (
|
||||||
msg: any,
|
msg: any,
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
sendResponse: any
|
sendResponse: any,
|
||||||
) => {
|
) => {
|
||||||
const messagesWithResponse = [
|
const messagesWithResponse = [
|
||||||
"checkFido2FeatureEnabled",
|
"checkFido2FeatureEnabled",
|
||||||
@ -69,7 +69,7 @@ export default class RuntimeBackground {
|
|||||||
if (messagesWithResponse.includes(msg.command)) {
|
if (messagesWithResponse.includes(msg.command)) {
|
||||||
this.processMessage(msg, sender).then(
|
this.processMessage(msg, sender).then(
|
||||||
(value) => sendResponse({ result: value }),
|
(value) => sendResponse({ result: value }),
|
||||||
(error) => sendResponse({ error: { ...error, message: error.message } })
|
(error) => sendResponse({ error: { ...error, message: error.message } }),
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ export default class RuntimeBackground {
|
|||||||
await BrowserApi.tabSendMessageData(
|
await BrowserApi.tabSendMessageData(
|
||||||
item.commandToRetry.sender.tab,
|
item.commandToRetry.sender.tab,
|
||||||
"unlockCompleted",
|
"unlockCompleted",
|
||||||
item
|
item,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -134,7 +134,7 @@ export default class RuntimeBackground {
|
|||||||
await this.autofillService.injectAutofillScripts(
|
await this.autofillService.injectAutofillScripts(
|
||||||
sender,
|
sender,
|
||||||
await this.configService.getFeatureFlag<boolean>(FeatureFlag.AutofillV2),
|
await this.configService.getFeatureFlag<boolean>(FeatureFlag.AutofillV2),
|
||||||
await this.configService.getFeatureFlag<boolean>(FeatureFlag.AutofillOverlay)
|
await this.configService.getFeatureFlag<boolean>(FeatureFlag.AutofillOverlay),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "bgCollectPageDetails":
|
case "bgCollectPageDetails":
|
||||||
@ -163,7 +163,7 @@ export default class RuntimeBackground {
|
|||||||
details: msg.details,
|
details: msg.details,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
msg.sender === "autofill_cmd"
|
msg.sender === "autofill_cmd",
|
||||||
);
|
);
|
||||||
if (totpCode != null) {
|
if (totpCode != null) {
|
||||||
this.platformUtilsService.copyToClipboard(totpCode, { window: window });
|
this.platformUtilsService.copyToClipboard(totpCode, { window: window });
|
||||||
@ -180,7 +180,7 @@ export default class RuntimeBackground {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
false,
|
false,
|
||||||
CipherType.Card
|
CipherType.Card,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ export default class RuntimeBackground {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
false,
|
false,
|
||||||
CipherType.Identity
|
CipherType.Identity,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -270,13 +270,13 @@ export default class RuntimeBackground {
|
|||||||
return await this.main.fido2ClientService.createCredential(
|
return await this.main.fido2ClientService.createCredential(
|
||||||
msg.data,
|
msg.data,
|
||||||
sender.tab,
|
sender.tab,
|
||||||
abortController
|
abortController,
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
await BrowserApi.focusTab(sender.tab.id);
|
await BrowserApi.focusTab(sender.tab.id);
|
||||||
await BrowserApi.focusWindow(sender.tab.windowId);
|
await BrowserApi.focusWindow(sender.tab.windowId);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
case "fido2GetCredentialRequest":
|
case "fido2GetCredentialRequest":
|
||||||
return await this.abortManager.runWithAbortController(
|
return await this.abortManager.runWithAbortController(
|
||||||
@ -286,13 +286,13 @@ export default class RuntimeBackground {
|
|||||||
return await this.main.fido2ClientService.assertCredential(
|
return await this.main.fido2ClientService.assertCredential(
|
||||||
msg.data,
|
msg.data,
|
||||||
sender.tab,
|
sender.tab,
|
||||||
abortController
|
abortController,
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
await BrowserApi.focusTab(sender.tab.id);
|
await BrowserApi.focusTab(sender.tab.id);
|
||||||
await BrowserApi.focusWindow(sender.tab.windowId);
|
await BrowserApi.focusWindow(sender.tab.windowId);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
case "switchAccount": {
|
case "switchAccount": {
|
||||||
await this.main.switchAccount(msg.userId);
|
await this.main.switchAccount(msg.userId);
|
||||||
|
@ -23,7 +23,7 @@ export type CipherFileUploadServiceInitOptions = CipherFileUploadServiceFactoyOp
|
|||||||
|
|
||||||
export function cipherFileUploadServiceFactory(
|
export function cipherFileUploadServiceFactory(
|
||||||
cache: { cipherFileUploadService?: CipherFileUploadServiceAbstraction } & CachedServices,
|
cache: { cipherFileUploadService?: CipherFileUploadServiceAbstraction } & CachedServices,
|
||||||
opts: CipherFileUploadServiceInitOptions
|
opts: CipherFileUploadServiceInitOptions,
|
||||||
): Promise<CipherFileUploadServiceAbstraction> {
|
): Promise<CipherFileUploadServiceAbstraction> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -32,7 +32,7 @@ export function cipherFileUploadServiceFactory(
|
|||||||
async () =>
|
async () =>
|
||||||
new CipherFileUploadService(
|
new CipherFileUploadService(
|
||||||
await apiServiceFactory(cache, opts),
|
await apiServiceFactory(cache, opts),
|
||||||
await fileUploadServiceFactory(cache, opts)
|
await fileUploadServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export type CipherFileUploadServiceInitOptions = CipherFileUploadServiceFactoyOp
|
|||||||
|
|
||||||
export function cipherFileUploadServiceFactory(
|
export function cipherFileUploadServiceFactory(
|
||||||
cache: { cipherFileUploadService?: CipherFileUploadServiceAbstraction } & CachedServices,
|
cache: { cipherFileUploadService?: CipherFileUploadServiceAbstraction } & CachedServices,
|
||||||
opts: CipherFileUploadServiceInitOptions
|
opts: CipherFileUploadServiceInitOptions,
|
||||||
): Promise<CipherFileUploadServiceAbstraction> {
|
): Promise<CipherFileUploadServiceAbstraction> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -32,7 +32,7 @@ export function cipherFileUploadServiceFactory(
|
|||||||
async () =>
|
async () =>
|
||||||
new CipherFileUploadService(
|
new CipherFileUploadService(
|
||||||
await apiServiceFactory(cache, opts),
|
await apiServiceFactory(cache, opts),
|
||||||
await fileUploadServiceFactory(cache, opts)
|
await fileUploadServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@ export type DevicesApiServiceInitOptions = DevicesApiServiceFactoryOptions & Api
|
|||||||
|
|
||||||
export function devicesApiServiceFactory(
|
export function devicesApiServiceFactory(
|
||||||
cache: { devicesApiService?: DevicesApiServiceAbstraction } & CachedServices,
|
cache: { devicesApiService?: DevicesApiServiceAbstraction } & CachedServices,
|
||||||
opts: DevicesApiServiceInitOptions
|
opts: DevicesApiServiceInitOptions,
|
||||||
): Promise<DevicesApiServiceAbstraction> {
|
): Promise<DevicesApiServiceAbstraction> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
"devicesApiService",
|
"devicesApiService",
|
||||||
opts,
|
opts,
|
||||||
async () => new DevicesApiServiceImplementation(await apiServiceFactory(cache, opts))
|
async () => new DevicesApiServiceImplementation(await apiServiceFactory(cache, opts)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export type EventCollectionServiceInitOptions = EventCollectionServiceOptions &
|
|||||||
|
|
||||||
export function eventCollectionServiceFactory(
|
export function eventCollectionServiceFactory(
|
||||||
cache: { eventCollectionService?: AbstractEventCollectionService } & CachedServices,
|
cache: { eventCollectionService?: AbstractEventCollectionService } & CachedServices,
|
||||||
opts: EventCollectionServiceInitOptions
|
opts: EventCollectionServiceInitOptions,
|
||||||
): Promise<AbstractEventCollectionService> {
|
): Promise<AbstractEventCollectionService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -45,7 +45,7 @@ export function eventCollectionServiceFactory(
|
|||||||
await cipherServiceFactory(cache, opts),
|
await cipherServiceFactory(cache, opts),
|
||||||
await stateServiceFactory(cache, opts),
|
await stateServiceFactory(cache, opts),
|
||||||
await organizationServiceFactory(cache, opts),
|
await organizationServiceFactory(cache, opts),
|
||||||
await eventUploadServiceFactory(cache, opts)
|
await eventUploadServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ export type EventUploadServiceInitOptions = EventUploadServiceOptions &
|
|||||||
|
|
||||||
export function eventUploadServiceFactory(
|
export function eventUploadServiceFactory(
|
||||||
cache: { eventUploadService?: AbstractEventUploadService } & CachedServices,
|
cache: { eventUploadService?: AbstractEventUploadService } & CachedServices,
|
||||||
opts: EventUploadServiceInitOptions
|
opts: EventUploadServiceInitOptions,
|
||||||
): Promise<AbstractEventUploadService> {
|
): Promise<AbstractEventUploadService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -38,7 +38,7 @@ export function eventUploadServiceFactory(
|
|||||||
new EventUploadService(
|
new EventUploadService(
|
||||||
await apiServiceFactory(cache, opts),
|
await apiServiceFactory(cache, opts),
|
||||||
await stateServiceFactory(cache, opts),
|
await stateServiceFactory(cache, opts),
|
||||||
await logServiceFactory(cache, opts)
|
await logServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ export type PasswordGenerationServiceInitOptions = PasswordGenerationServiceFact
|
|||||||
|
|
||||||
export function passwordGenerationServiceFactory(
|
export function passwordGenerationServiceFactory(
|
||||||
cache: { passwordGenerationService?: PasswordGenerationServiceAbstraction } & CachedServices,
|
cache: { passwordGenerationService?: PasswordGenerationServiceAbstraction } & CachedServices,
|
||||||
opts: PasswordGenerationServiceInitOptions
|
opts: PasswordGenerationServiceInitOptions,
|
||||||
): Promise<PasswordGenerationServiceAbstraction> {
|
): Promise<PasswordGenerationServiceAbstraction> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -40,7 +40,7 @@ export function passwordGenerationServiceFactory(
|
|||||||
new PasswordGenerationService(
|
new PasswordGenerationService(
|
||||||
await cryptoServiceFactory(cache, opts),
|
await cryptoServiceFactory(cache, opts),
|
||||||
await policyServiceFactory(cache, opts),
|
await policyServiceFactory(cache, opts),
|
||||||
await stateServiceFactory(cache, opts)
|
await stateServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,16 @@ export type SearchServiceInitOptions = SearchServiceFactoryOptions &
|
|||||||
|
|
||||||
export function searchServiceFactory(
|
export function searchServiceFactory(
|
||||||
cache: { searchService?: AbstractSearchService } & CachedServices,
|
cache: { searchService?: AbstractSearchService } & CachedServices,
|
||||||
opts: SearchServiceInitOptions
|
opts: SearchServiceInitOptions,
|
||||||
): Promise<AbstractSearchService> {
|
): Promise<AbstractSearchService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
"searchService",
|
"searchService",
|
||||||
opts,
|
opts,
|
||||||
async () =>
|
async () =>
|
||||||
new SearchService(await logServiceFactory(cache, opts), await i18nServiceFactory(cache, opts))
|
new SearchService(
|
||||||
|
await logServiceFactory(cache, opts),
|
||||||
|
await i18nServiceFactory(cache, opts),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ export type SendServiceInitOptions = SendServiceFactoryOptions &
|
|||||||
|
|
||||||
export function sendServiceFactory(
|
export function sendServiceFactory(
|
||||||
cache: { sendService?: InternalSendService } & CachedServices,
|
cache: { sendService?: InternalSendService } & CachedServices,
|
||||||
opts: SendServiceInitOptions
|
opts: SendServiceInitOptions,
|
||||||
): Promise<InternalSendService> {
|
): Promise<InternalSendService> {
|
||||||
return factory(
|
return factory(
|
||||||
cache,
|
cache,
|
||||||
@ -40,7 +40,7 @@ export function sendServiceFactory(
|
|||||||
await cryptoServiceFactory(cache, opts),
|
await cryptoServiceFactory(cache, opts),
|
||||||
await i18nServiceFactory(cache, opts),
|
await i18nServiceFactory(cache, opts),
|
||||||
await cryptoFunctionServiceFactory(cache, opts),
|
await cryptoFunctionServiceFactory(cache, opts),
|
||||||
await stateServiceFactory(cache, opts)
|
await stateServiceFactory(cache, opts),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user