From e6f025335ab34072ca31663c5bba9e221bc44786 Mon Sep 17 00:00:00 2001 From: Jacek Wielemborek Date: Sun, 26 Oct 2025 18:13:48 +0100 Subject: [PATCH] fix: remove test content script from production manifest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed content_scripts entry that injected test code into all pages - Modified test-lib.js to dynamically inject content script only during tests - Test code no longer affects production users 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- manifest.json | 7 ------- tests/test-lib.js | 28 +++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/manifest.json b/manifest.json index e8fe3ec..9e82282 100644 --- a/manifest.json +++ b/manifest.json @@ -26,13 +26,6 @@ "32": "assets/icon-addon.svg", "64": "assets/icon-addon.svg" }, - "content_scripts": [ - { - "matches": [""], - "js": ["lib/tests/test-content-script.js"], - "run_at": "document_end" - } - ], "permissions": [ "proxy", "storage", diff --git a/tests/test-lib.js b/tests/test-lib.js index 893a92c..6ab61d4 100644 --- a/tests/test-lib.js +++ b/tests/test-lib.js @@ -1,14 +1,36 @@ // Test library for Marionette-based extension verification // This JavaScript code runs in the browser context via Marionette +/** + * Inject test content script into the page + * @returns {Promise} - True if injection successful + */ +async function injectTestContentScript() { + // Read the content script file + const response = await fetch(browser.runtime.getURL('lib/tests/test-content-script.js')); + const scriptCode = await response.text(); + + // Inject it into the page + const script = document.createElement('script'); + script.textContent = scriptCode; + document.documentElement.appendChild(script); + script.remove(); + + // Wait a bit for script to initialize + await new Promise(resolve => setTimeout(resolve, 100)); + + return document.body.getAttribute('data-rentgen-injected') === 'true'; +} + /** * Test that background script performs computation correctly * @param {number} testValue - Input value for computation * @returns {Promise} - Computed result or null on failure */ -function testBackgroundComputation(testValue) { - // Check if content script loaded - if (!document.body.getAttribute('data-rentgen-injected')) { +async function testBackgroundComputation(testValue) { + // Inject content script first + const injected = await injectTestContentScript(); + if (!injected) { return -1; // Content script not loaded }