Skip to content

Commit

Permalink
use disabled URIs service state as a preemptive conditon to injecting…
Browse files Browse the repository at this point in the history
… content scripts
  • Loading branch information
jprusik committed Nov 1, 2024
1 parent d5370ad commit e8ddd67
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 4 deletions.
6 changes: 5 additions & 1 deletion apps/browser/src/autofill/services/autofill.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ describe("AutofillService", () => {
let messageListener: MockProxy<MessageListener>;

beforeEach(() => {
scriptInjectorService = new BrowserScriptInjectorService(platformUtilsService, logService);
scriptInjectorService = new BrowserScriptInjectorService(
domainSettingsService,
platformUtilsService,
logService,
);
inlineMenuVisibilityMock$ = new BehaviorSubject(AutofillOverlayVisibility.OnFieldFocus);
showInlineMenuCardsMock$ = new BehaviorSubject(false);
showInlineMenuIdentitiesMock$ = new BehaviorSubject(false);
Expand Down
1 change: 1 addition & 0 deletions apps/browser/src/background/main.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ export default class MainBackground {
this.totpService = new TotpService(this.cryptoFunctionService, this.logService);

this.scriptInjectorService = new BrowserScriptInjectorService(
this.domainSettingsService,
this.platformUtilsService,
this.logService,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mock } from "jest-mock-extended";

import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";

Expand All @@ -25,11 +26,16 @@ describe("ScriptInjectorService", () => {
let scriptInjectorService: BrowserScriptInjectorService;
jest.spyOn(BrowserApi, "executeScriptInTab").mockImplementation();
jest.spyOn(BrowserApi, "isManifestVersion");
const domainSettingsService = mock<DomainSettingsService>();
const platformUtilsService = mock<PlatformUtilsService>();
const logService = mock<LogService>();

beforeEach(() => {
scriptInjectorService = new BrowserScriptInjectorService(platformUtilsService, logService);
scriptInjectorService = new BrowserScriptInjectorService(
domainSettingsService,
platformUtilsService,
logService,
);
});

describe("inject", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { Subject, takeUntil } from "rxjs";

import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
import { NeverDomains } from "@bitwarden/common/models/domain/domain-service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";

Expand All @@ -10,11 +14,22 @@ import {
} from "./abstractions/script-injector.service";

export class BrowserScriptInjectorService extends ScriptInjectorService {
disabledDomains: Set<string> = null;

private destroy$ = new Subject<void>();

constructor(
private readonly domainSettingsService: DomainSettingsService,
private readonly platformUtilsService: PlatformUtilsService,
private readonly logService: LogService,
) {
super();

this.domainSettingsService.disabledInteractionsUris$

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService collectPageDetailsFromTab$ sends a `collectPageDetails` message to the passed tab ► AutofillService collectPageDetailsFromTab$ sends a `collectPageDetails` message to the passed tab

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService collectPageDetailsFromTab$ builds an array of page details from received `collectPageDetailsResponse` messages ► AutofillService collectPageDetailsFromTab$ builds an array of page details from received `collectPageDeta...

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService collectPageDetailsFromTab$ ignores messages from a different tab ► AutofillService collectPageDetailsFromTab$ ignores messages from a different tab

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService collectPageDetailsFromTab$ ignores messages from a different sender ► AutofillService collectPageDetailsFromTab$ ignores messages from a different sender

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService loadAutofillScriptsOnInstall queries all browser tabs and injects the autofill scripts into them ► AutofillService loadAutofillScriptsOnInstall queries all browser tabs and injects the autofill scripts into them

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService loadAutofillScriptsOnInstall skips injecting scripts into tabs that do not have an http(s) protocol ► AutofillService loadAutofillScriptsOnInstall skips injecting scripts into tabs that do not have an http(s) protocol

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService loadAutofillScriptsOnInstall sets up an extension runtime onConnect listener ► AutofillService loadAutofillScriptsOnInstall sets up an extension runtime onConnect listener

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService loadAutofillScriptsOnInstall handle inline menu visibility change returns early if the setting is being initialized ► AutofillService loadAutofillScriptsOnInstall handle inline menu visibility change returns early if t...

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService loadAutofillScriptsOnInstall handle inline menu visibility change returns early if the previous setting is equivalent to the new setting ► AutofillService loadAutofillScriptsOnInstall handle inline menu visibility chan...

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService loadAutofillScriptsOnInstall handle inline menu visibility change reloads the autofill scripts when changing the inline menu from a disabled setting to an enabled setting ► AutofillService loadAutofillScriptsOnInstall ...

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)

Check failure on line 28 in apps/browser/src/platform/services/browser-script-injector.service.ts

View workflow job for this annotation

GitHub Actions / Test Results

AutofillService ► AutofillService loadAutofillScriptsOnInstall handle inline menu visibility change reloads the autofill scripts when changing the inline menu from a enabled setting to a disabled setting ► AutofillService loadAutofillScriptsOnInstall h...

Failed test found in: junit.xml Error: TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
Raw output
TypeError: Cannot read properties of undefined (reading 'disabledInteractionsUris$')
    at new disabledInteractionsUris$ (/home/runner/work/clients/clients/apps/browser/src/platform/services/browser-script-injector.service.ts:28:32)
    at /home/runner/work/clients/clients/apps/browser/src/autofill/services/autofill.service.spec.ts:101:29
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:411:30)
    at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:300:43)
    at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:410:56)
    at Zone.Object.<anonymous>.Zone.run (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone.umd.js:165:47)
    at Object.wrappedFunc (/home/runner/work/clients/clients/node_modules/zone.js/bundles/zone-testing.umd.js:789:34)
    at Promise.then.completed (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/home/runner/work/clients/clients/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusHook (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:281:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at _runTest (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:246:5)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:121:9)
    at run (/home/runner/work/clients/clients/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/home/runner/work/clients/clients/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
.pipe(takeUntil(this.destroy$))
.subscribe(
(neverDomains: NeverDomains) => (this.disabledDomains = new Set(Object.keys(neverDomains))),
);
}

/**
Expand All @@ -30,6 +45,15 @@ export class BrowserScriptInjectorService extends ScriptInjectorService {
throw new Error("No file specified for script injection");
}

// Check if the tab URI is on the disabled URIs list
const tab = await BrowserApi.getTab(tabId);
const tabURL = tab.url ? new URL(tab.url) : null;
const injectionAllowedInTab = !(tabURL && this.disabledDomains?.has(tabURL.hostname));

if (!injectionAllowedInTab) {
throw new Error("This URI of this tab is on the disabled domains list.");
}

const injectionDetails = this.buildInjectionDetails(injectDetails, file);

if (BrowserApi.isManifestVersion(3)) {
Expand Down
2 changes: 1 addition & 1 deletion apps/browser/src/popup/services/services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ const safeProviders: SafeProvider[] = [
safeProvider({
provide: ScriptInjectorService,
useClass: BrowserScriptInjectorService,
deps: [PlatformUtilsService, LogService],
deps: [DomainSettingsService, PlatformUtilsService, LogService],
}),
safeProvider({
provide: VaultTimeoutService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { firstValueFrom } from "rxjs";
import { PolicyService } from "@bitwarden/common/admin-console/services/policy/policy.service";
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { AuthService } from "@bitwarden/common/auth/services/auth.service";
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand Down Expand Up @@ -35,6 +36,7 @@ jest.mock("rxjs", () => {
describe("FilelessImporterBackground ", () => {
let filelessImporterBackground: FilelessImporterBackground;
const configService = mock<ConfigService>();
const domainSettingsService = mock<DomainSettingsService>();
const authService = mock<AuthService>();
const policyService = mock<PolicyService>();
const notificationBackground = mock<NotificationBackground>();
Expand All @@ -45,7 +47,11 @@ describe("FilelessImporterBackground ", () => {
let scriptInjectorService: BrowserScriptInjectorService;

beforeEach(() => {
scriptInjectorService = new BrowserScriptInjectorService(platformUtilsService, logService);
scriptInjectorService = new BrowserScriptInjectorService(
domainSettingsService,
platformUtilsService,
logService,
);
filelessImporterBackground = new FilelessImporterBackground(
configService,
authService,
Expand Down

0 comments on commit e8ddd67

Please sign in to comment.