From a03837120d398af5ab839301edfe111da1df44f0 Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Tue, 11 Feb 2025 10:22:54 -0500 Subject: [PATCH] Support Firefox MV3 (#13191) * Support Firefox MV3 * Offscreen API's aren't needed for firefox --- apps/browser/src/manifest.v3.json | 18 +++++++++++++++++- apps/browser/webpack.config.js | 31 ++++++++++++++++++------------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/apps/browser/src/manifest.v3.json b/apps/browser/src/manifest.v3.json index 8da048e04f2..2de32e7c4a7 100644 --- a/apps/browser/src/manifest.v3.json +++ b/apps/browser/src/manifest.v3.json @@ -63,6 +63,22 @@ "webRequestAuthProvider", "notifications" ], + "__firefox__permissions": [ + "activeTab", + "alarms", + "clipboardRead", + "clipboardWrite", + "contextMenus", + "idle", + "scripting", + "storage", + "tabs", + "unlimitedStorage", + "webNavigation", + "webRequest", + "webRequestAuthProvider", + "notifications" + ], "__safari__permissions": [ "activeTab", "alarms", @@ -86,7 +102,7 @@ "host_permissions": ["https://*/*", "http://*/*"], "content_security_policy": { "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'", - "sandbox": "sandbox allow-scripts; script-src 'self'" + "__chrome__sandbox": "sandbox allow-scripts; script-src 'self'" }, "sandbox": { "pages": [ diff --git a/apps/browser/webpack.config.js b/apps/browser/webpack.config.js index ba60a577a71..d077e54bb73 100644 --- a/apps/browser/webpack.config.js +++ b/apps/browser/webpack.config.js @@ -317,19 +317,24 @@ if (manifestVersion == 2) { configs.push(mainConfig); } else { - // Manifest v3 needs an extra helper for utilities in the content script. - // The javascript output of this should be added to manifest.v3.json - mainConfig.entry["content/misc-utils"] = "./src/autofill/content/misc-utils.ts"; - mainConfig.entry["offscreen-document/offscreen-document"] = - "./src/platform/offscreen-document/offscreen-document.ts"; + // Firefox does not use the offscreen API + if (browser !== "firefox") { + // Manifest v3 needs an extra helper for utilities in the content script. + // The javascript output of this should be added to manifest.v3.json + mainConfig.entry["content/misc-utils"] = "./src/autofill/content/misc-utils.ts"; + mainConfig.entry["offscreen-document/offscreen-document"] = + "./src/platform/offscreen-document/offscreen-document.ts"; - mainConfig.plugins.push( - new HtmlWebpackPlugin({ - template: "./src/platform/offscreen-document/index.html", - filename: "offscreen-document/index.html", - chunks: ["offscreen-document/offscreen-document"], - }), - ); + mainConfig.plugins.push( + new HtmlWebpackPlugin({ + template: "./src/platform/offscreen-document/index.html", + filename: "offscreen-document/index.html", + chunks: ["offscreen-document/offscreen-document"], + }), + ); + } + + const target = browser === "firefox" ? "web" : "webworker"; /** * @type {import("webpack").Configuration} @@ -339,7 +344,7 @@ if (manifestVersion == 2) { mode: ENV, devtool: false, entry: "./src/platform/background.ts", - target: "webworker", + target: target, output: { filename: "background.js", path: path.resolve(__dirname, "build"),