Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/e2e/e2e-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,25 @@ export async function setSettings(
);
}

/**
* True when a stored setting is not equal to its value in `settings`. It also
* finds writes from extension pages and commands, which `setSettings` does not see.
*/
export async function storedSettingsDiffer(
worker: BackgroundContext,
settings: Record<string, unknown>,
): Promise<boolean> {
const stored = await withWorker(worker, (context) =>
context.evaluate(
(keys) => chrome.storage.local.get(keys),
Object.keys(settings).map((key) => `${SETTINGS_PREFIX}${key}`),
),
);
return Object.entries(settings).some(
([key, value]) => stored[`${SETTINGS_PREFIX}${key}`] !== JSON.stringify(value),
);
}

export async function setSetting(
worker: BackgroundContext,
key: string,
Expand Down
Loading
Loading