1import { test, expect } from "@playwright/test";23import { loadPopup, makeContext } from "./helpers/vault";45test("PB-26-016: real content-script sender cannot read local storage or bulk entries", async () => {6 const context = await makeContext("pb26016-sender");7 try {8 const page = await context.newPage();9 await page.goto("https://example.com/");10 const { popup } = await loadPopup(context);1112 const result = await popup.evaluate(async () => {13 const tabs = await chrome.tabs.query({ url: "https://example.com/*" });14 const tab = tabs.find((candidate) => candidate.id !== undefined);15 if (tab?.id === undefined) throw new Error("test page tab was not found");1617 const executions = await chrome.scripting.executeScript({18 target: { tabId: tab.id },19 func: async () => {20 let localStorageReadable = true;21 try {22 await chrome.storage.local.get("peach_recovery_pending");23 } catch {24 localStorageReadable = false;25 }26 const response = await chrome.runtime.sendMessage({ type: "GET_ENTRIES" });27 return { localStorageReadable, response };28 },29 });30 return executions[0]?.result as {31 localStorageReadable: boolean;32 response: { ok?: boolean; error?: string };33 } | undefined;34 });3536 expect(result?.localStorageReadable).toBe(false);37 expect(result?.response).toEqual({ ok: false, error: "invalid_sender" });38 } finally {39 await context.close();40 }41});