mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-01 02:17:53 +01:00
Fix Firefox account consent for 4.0.6
This commit is contained in:
1 parent
e500088e65
commit
ee20c7437c
20 files changed
+606
-331
No files matched your search
@@ -1,9 +1,4 @@
|
||||
jest.mock("../common/vote-client", () => ({ createVoteClient: jest.fn() }));
|
||||
jest.mock("./src/data-collection-permissions", () => ({
|
||||
hasAuthenticationDataPermission: jest.fn(),
|
||||
onAuthenticationDataPermissionRemoved: jest.fn(),
|
||||
usesFirefoxDataCollectionConsent: jest.fn(),
|
||||
}));
|
||||
|
||||
const flushPromises = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||
const startData = () => {
|
||||
@@ -45,18 +40,23 @@ describe("background account consent lifecycle", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
const permissions = require("./src/data-collection-permissions");
|
||||
permissions.usesFirefoxDataCollectionConsent.mockReturnValue(true);
|
||||
permissions.hasAuthenticationDataPermission.mockImplementation(() => Promise.resolve(consent));
|
||||
permissions.onAuthenticationDataPermissionRemoved.mockImplementation((listener) => (removeConsent = listener));
|
||||
require("../common/vote-client").createVoteClient.mockReturnValue({ ensureRegistered: () => Promise.resolve({}) });
|
||||
global.__RYD_LIVE_TEST_BUILD__ = false;
|
||||
global.chrome = {
|
||||
runtime: {
|
||||
getManifest: () => ({ version: "4.0.5" }),
|
||||
getManifest: () => require("./manifest-firefox.json"),
|
||||
onMessage: { addListener: (listener) => (messageListener = listener) },
|
||||
onInstalled: { addListener: jest.fn() },
|
||||
},
|
||||
permissions: {
|
||||
getAll: jest.fn(() => Promise.resolve({ data_collection: consent ? ["authenticationInfo"] : [] })),
|
||||
contains: jest.fn().mockResolvedValue(true),
|
||||
onRemoved: {
|
||||
addListener: (listener) => {
|
||||
removeConsent = () => listener({ data_collection: ["authenticationInfo"] });
|
||||
},
|
||||
},
|
||||
},
|
||||
identity: {
|
||||
getRedirectURL: () => "https://extension.example/callback",
|
||||
launchWebAuthFlow: jest.fn(() => Promise.resolve("https://extension.example/callback?code=test&state=test")),
|
||||
@@ -108,6 +108,19 @@ describe("background account consent lifecycle", () => {
|
||||
},
|
||||
);
|
||||
|
||||
test.each(["patreon_oauth_login", "github_oauth_login"])(
|
||||
"%s sends nothing when Firefox does not expose built-in data consent",
|
||||
async (message) => {
|
||||
chrome.permissions.getAll.mockResolvedValue({ permissions: ["identity"], origins: [] });
|
||||
const response = jest.fn();
|
||||
messageListener({ message }, {}, response);
|
||||
await flushPromises();
|
||||
expect(fetch).not.toHaveBeenCalled();
|
||||
expect(chrome.identity.launchWebAuthFlow).not.toHaveBeenCalled();
|
||||
expect(response).toHaveBeenCalledWith(expect.objectContaining({ success: false }));
|
||||
},
|
||||
);
|
||||
|
||||
test.each(["patreon_oauth_login", "github_oauth_login"])(
|
||||
"%s does not open OAuth after consent is revoked during startup",
|
||||
async (message) => {
|
||||
|
||||
Reference in new issue
Block a user