Fix Firefox DevTools extension paths (#231)

This commit is contained in:
Paul Bakaus
2026-06-08 15:23:37 -07:00
committed by GitHub
parent 3d1be6238c
commit 9381269a82
3 changed files with 27 additions and 4 deletions
+3 -3
View File
@@ -8,13 +8,13 @@
chrome.devtools.panels.create(
'Impeccable',
'icons/icon-32.png',
'devtools/panel.html'
'/icons/icon-32.png',
'/devtools/panel.html'
);
// Sidebar pane in the Elements panel: shows findings for the currently selected element
chrome.devtools.panels.elements.createSidebarPane('Impeccable', (sidebar) => {
sidebar.setPage('devtools/sidebar.html');
sidebar.setPage('/devtools/sidebar.html');
sidebar.setHeight('200px');
});
+2 -1
View File
@@ -68,7 +68,7 @@ export const SUITES = {
/^extension\/(background|content|detector|devtools|popup|manifest\.json)/,
/^scripts\/(benchmark-detector|build-browser-detector|build-extension)\.js$/,
/^site\/(pages\/detector|public\/antipattern|data\/anti-patterns-catalog\.js)/,
/^tests\/(detect-antipatterns|fixtures\/antipatterns)/,
/^tests\/(detect-antipatterns|extension-build|fixtures\/antipatterns)/,
],
commands: [
{
@@ -81,6 +81,7 @@ export const SUITES = {
{
runner: 'node',
files: [
'tests/extension-build.test.mjs',
'tests/detect-antipatterns-fixtures.test.mjs',
'tests/detect-antipatterns-browser.test.mjs',
],
+22
View File
@@ -0,0 +1,22 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
describe('extension DevTools packaging', () => {
it('uses extension-root paths for DevTools panel pages', () => {
const source = readFileSync(path.join(ROOT, 'extension/devtools/devtools.js'), 'utf-8');
assert.match(
source,
/chrome\.devtools\.panels\.create\(\s*['"]Impeccable['"],\s*['"]\/icons\/icon-32\.png['"],\s*['"]\/devtools\/panel\.html['"]\s*\)/s,
'Firefox resolves DevTools URLs relative to devtools.html unless they start at the extension root',
);
assert.match(source, /sidebar\.setPage\(['"]\/devtools\/sidebar\.html['"]\)/);
assert.doesNotMatch(source, /['"]devtools\/(?:panel|sidebar)\.html['"]/);
assert.doesNotMatch(source, /['"]icons\/icon-32\.png['"]/);
});
});