Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Capture prior gate state before write and avoid script sanitization regexp in tests
Emre Sokullu4de1838f75f2
diff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.jsindex 97a8cc970..75f9bae05 100644--- a/src/chrome/src/ui/sidepanel.js+++ b/src/chrome/src/ui/sidepanel.js@@ -1815,8 +1815,8 @@ function renderPermissionGateControl() {function setPermissionGateFromHeader(askBefore) {const write = permissionGateWriteQueue.then(async () => {- await chrome.storage.local.set({ [PERMISSION_GATE_KEY]: askBefore });const changed = askBeforeConsequential !== askBefore;+ await chrome.storage.local.set({ [PERMISSION_GATE_KEY]: askBefore });askBeforeConsequential = askBefore;updateActWarning();updateInputPlaceholder();diff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.jsindex 70450376e..ecbb30dae 100644--- a/src/firefox/src/ui/sidepanel.js+++ b/src/firefox/src/ui/sidepanel.js@@ -1990,8 +1990,8 @@ function renderPermissionGateControl() {function setPermissionGateFromHeader(askBefore) {const write = permissionGateWriteQueue.then(async () => {- await browser.storage.local.set({ [PERMISSION_GATE_KEY]: askBefore });const changed = askBeforeConsequential !== askBefore;+ await browser.storage.local.set({ [PERMISSION_GATE_KEY]: askBefore });askBeforeConsequential = askBefore;updateActWarning();updateInputPlaceholder();diff --git a/test/sidepanel-permission-gate-ui.mjs b/test/sidepanel-permission-gate-ui.mjsindex 8e88dcf4e..9efa575d9 100644--- a/test/sidepanel-permission-gate-ui.mjs+++ b/test/sidepanel-permission-gate-ui.mjs@@ -18,7 +18,10 @@ for (const [build, engine, api] of [['chrome', chromium, 'chrome'], ['firefox',const end = source.indexOf('\nrenderPermissionGateControl();\n', start);assert.ok(start >= 0 && end > start, 'Use the entire production switch block.');block = source.slice(start, end + '\nrenderPermissionGateControl();\n'.length);- html = (await read(build, 'src/ui/sidepanel.html')).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, '');+ html = (await read(build, 'src/ui/sidepanel.html'))+ .split('\n')+ .filter((line) => !line.trim().startsWith('<script'))+ .join('\n');});after(async () => { await browser?.close(); });@@ -50,6 +53,10 @@ for (const [build, engine, api] of [['chrome', chromium, 'chrome'], ['firefox',storage: { local: { async set(values) {if (failNextWrite) { failNextWrite = false; throw new Error('storage unavailable'); }log.writes.push(values);+ if (PERMISSION_GATE_KEY in values) {+ // Chromium dispatches storage.onChanged before the set() callback resumes+ askBeforeConsequential = values[PERMISSION_GATE_KEY] !== false;+ }} } },runtime: { getURL: (path) => 'ext://webbrain/' + path, openOptionsPage() { log.opened.push('options'); } },tabs: { async create({ url }) { log.opened.push(url); } },