mirror of
https://github.com/primedigitaltech/azon_seeker.git
synced 2026-10-05 07:13:06 +08:00
* feat: add Amazon collection metadata and reliable sync * fix: route extension sync through configured server * chore: release extension v0.7.13 * fix: handle extension ports across BFCache navigation * fix: classify bottom Sponsored Brands video placements * fix: exclude hidden Amazon ad cards * fix: derive Amazon result page from URL * fix: ignore hidden Amazon sponsored products * fix: preserve base Amazon product collection * fix: bind Amazon results to visible page * fix: classify visible Amazon ad formats * fix: wait for lazy Amazon ad modules * perf: reduce Amazon lazy-load scroll stops * fix: classify Amazon sponsored brand and video search ads Co-authored-by: Cursor <cursoragent@cursor.com> * fix: collect Shop by type thematic SP ads via redirect chains without data-asin Co-authored-by: Cursor <cursoragent@cursor.com> * fix: classify sponsored ads across new Amazon templates --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: PetrichorFun <127877748+PetrichorFun@users.noreply.github.com>
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { exec } from '../src/logic/execute-script';
|
|
|
|
const setBrowser = (
|
|
executeScript: () => Promise<unknown>,
|
|
getTab: () => Promise<{ status: string }> = async () => ({ status: 'complete' }),
|
|
) => {
|
|
Object.assign(globalThis, {
|
|
browser: {
|
|
tabs: { get: getTab },
|
|
scripting: { executeScript },
|
|
},
|
|
});
|
|
};
|
|
|
|
const main = async () => {
|
|
setBrowser(async () => {
|
|
throw new Error('Frame was removed');
|
|
});
|
|
const rejectionStarted = Date.now();
|
|
await exec(1, async () => true, undefined, { timeout: 1000 }).then(
|
|
() => {
|
|
throw new Error('Expected executeScript to reject');
|
|
},
|
|
(error) => {
|
|
if (!String(error).includes('Frame was removed')) throw error;
|
|
if (Date.now() - rejectionStarted >= 1000) {
|
|
throw new Error('The original executeScript error was delayed until the timeout');
|
|
}
|
|
},
|
|
);
|
|
|
|
setBrowser(async () => [{ result: 42 }]);
|
|
const result = await exec(1, async () => 42, undefined, { timeout: 1000 });
|
|
if (result !== 42) throw new Error(`Expected 42, received ${result}`);
|
|
|
|
let injectionAttempted = false;
|
|
setBrowser(
|
|
async () => {
|
|
injectionAttempted = true;
|
|
return [{ result: true }];
|
|
},
|
|
async () => ({ status: 'loading' }),
|
|
);
|
|
await exec(1, async () => true, undefined, { timeout: 100 }).then(
|
|
() => {
|
|
throw new Error('A perpetually loading page should time out before injection');
|
|
},
|
|
(error) => {
|
|
if (!String(error).includes('页面加载超时')) throw error;
|
|
},
|
|
);
|
|
if (injectionAttempted) throw new Error('Script was injected into a still-loading page');
|
|
|
|
console.log('Execute-script error propagation tests passed.');
|
|
};
|
|
|
|
void main();
|