import { test, expect } from "@playwright/test"; import { loadPopup, makeContext } from "./helpers/vault"; test("PB-26-016: real content-script sender cannot read local storage or bulk entries", async () => { const context = await makeContext("pb26016-sender"); try { const page = await context.newPage(); await page.goto("https://example.com/"); const { popup } = await loadPopup(context); const result = await popup.evaluate(async () => { const tabs = await chrome.tabs.query({ url: "https://example.com/*" }); const tab = tabs.find((candidate) => candidate.id !== undefined); if (tab?.id === undefined) throw new Error("test page tab was not found"); const executions = await chrome.scripting.executeScript({ target: { tabId: tab.id }, func: async () => { let localStorageReadable = true; try { await chrome.storage.local.get("peach_recovery_pending"); } catch { localStorageReadable = false; } const response = await chrome.runtime.sendMessage({ type: "GET_ENTRIES" }); return { localStorageReadable, response }; }, }); return executions[0]?.result as { localStorageReadable: boolean; response: { ok?: boolean; error?: string }; } | undefined; }); expect(result?.localStorageReadable).toBe(false); expect(result?.response).toEqual({ ok: false, error: "invalid_sender" }); } finally { await context.close(); } });