ext(sw): add get_active_tab_url popup handler
This commit is contained in:
@@ -921,3 +921,36 @@ describe('parse_lastpass_csv / import_lastpass_commit sender check', () => {
|
||||
expect(result).toEqual({ ok: false, error: 'unauthorized_sender' });
|
||||
});
|
||||
});
|
||||
|
||||
// --- get_active_tab_url ---
|
||||
|
||||
describe('get_active_tab_url', () => {
|
||||
it('get_active_tab_url returns active tab url + title', async () => {
|
||||
// happy-dom does not provide chrome.tabs; stub it.
|
||||
(globalThis as any).chrome = {
|
||||
...((globalThis as any).chrome ?? {}),
|
||||
tabs: {
|
||||
query: (q: any, cb: (tabs: any[]) => void) => {
|
||||
cb([{ url: 'https://github.com/login', title: 'Sign in to GitHub' }]);
|
||||
},
|
||||
},
|
||||
};
|
||||
const resp = await route({ type: 'get_active_tab_url' } as any, makeState(), makePopupSender());
|
||||
expect(resp.ok).toBe(true);
|
||||
expect(resp.data).toEqual({ url: 'https://github.com/login', title: 'Sign in to GitHub' });
|
||||
});
|
||||
|
||||
it('get_active_tab_url returns null for chrome:// pages', async () => {
|
||||
(globalThis as any).chrome = {
|
||||
...((globalThis as any).chrome ?? {}),
|
||||
tabs: {
|
||||
query: (q: any, cb: (tabs: any[]) => void) => {
|
||||
cb([{ url: 'chrome://newtab/', title: 'New Tab' }]);
|
||||
},
|
||||
},
|
||||
};
|
||||
const resp = await route({ type: 'get_active_tab_url' } as any, makeState(), makePopupSender());
|
||||
expect(resp.ok).toBe(true);
|
||||
expect(resp.data).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user