mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-25 12:15:18 +01:00
609296ad2b
* [PM-5617] Re-Add Setting to Turn Off Default Browser Autofill * [PM-5617] Re-Add Setting to Turn Off Default Browser Autofill * [PM-5617] Removing the privacy optional permission from Firefox * [PM-5617] Adding jest tests to validate the behavior within BrowserApi * [PM-5617] Adjusting messaging based on feedback from design * [PM-5617] Adjusting messaging based on feedback from design * [PM-5617] Adjusting messaging based on feedback from design * [PM-5617] Removing unnecessary configService dependency
120 lines
2.0 KiB
TypeScript
120 lines
2.0 KiB
TypeScript
// Add chrome storage api
|
|
const QUOTA_BYTES = 10;
|
|
const storage = {
|
|
local: {
|
|
set: jest.fn(),
|
|
get: jest.fn(),
|
|
remove: jest.fn(),
|
|
QUOTA_BYTES,
|
|
getBytesInUse: jest.fn(),
|
|
clear: jest.fn(),
|
|
},
|
|
session: {
|
|
set: jest.fn(),
|
|
get: jest.fn(),
|
|
has: jest.fn(),
|
|
remove: jest.fn(),
|
|
},
|
|
};
|
|
|
|
const runtime = {
|
|
onMessage: {
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
},
|
|
sendMessage: jest.fn(),
|
|
getManifest: jest.fn(() => ({ version: 2 })),
|
|
getURL: jest.fn((path) => `chrome-extension://id/${path}`),
|
|
connect: jest.fn(),
|
|
onConnect: {
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
},
|
|
};
|
|
|
|
const contextMenus = {
|
|
create: jest.fn(),
|
|
removeAll: jest.fn(),
|
|
};
|
|
|
|
const i18n = {
|
|
getMessage: jest.fn(),
|
|
getUILanguage: jest.fn(),
|
|
};
|
|
|
|
const tabs = {
|
|
executeScript: jest.fn(),
|
|
sendMessage: jest.fn(),
|
|
query: jest.fn(),
|
|
onActivated: {
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
},
|
|
onReplaced: {
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
},
|
|
onUpdated: {
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
},
|
|
onRemoved: {
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
},
|
|
};
|
|
|
|
const scripting = {
|
|
executeScript: jest.fn(),
|
|
};
|
|
|
|
const windows = {
|
|
create: jest.fn(),
|
|
get: jest.fn(),
|
|
getCurrent: jest.fn(),
|
|
update: jest.fn(),
|
|
remove: jest.fn(),
|
|
onFocusChanged: {
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
},
|
|
};
|
|
|
|
const port = {
|
|
onMessage: {
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
},
|
|
postMessage: jest.fn(),
|
|
};
|
|
|
|
const privacy = {
|
|
services: {
|
|
autofillAddressEnabled: {
|
|
get: jest.fn(),
|
|
set: jest.fn(),
|
|
},
|
|
autofillCreditCardEnabled: {
|
|
get: jest.fn(),
|
|
set: jest.fn(),
|
|
},
|
|
passwordSavingEnabled: {
|
|
get: jest.fn(),
|
|
set: jest.fn(),
|
|
},
|
|
},
|
|
};
|
|
|
|
// set chrome
|
|
global.chrome = {
|
|
i18n,
|
|
storage,
|
|
runtime,
|
|
contextMenus,
|
|
tabs,
|
|
scripting,
|
|
windows,
|
|
port,
|
|
privacy,
|
|
} as any;
|