fix fonts
Release Firefox and Chromium extensions / Package and attach browser extensions (release) Successful in 4s
Release Firefox and Chromium extensions / Package and attach browser extensions (release) Successful in 4s
This commit is contained in:
@@ -192,6 +192,17 @@ async function packageExtension({
|
||||
for (const relativePath of archiveFiles) {
|
||||
let contents = await readFile(path.join(rootDirectory, relativePath));
|
||||
|
||||
if (target === "chromium" && relativePath === "content.css") {
|
||||
contents = Buffer.from(
|
||||
contents
|
||||
.toString("utf8")
|
||||
.replaceAll(
|
||||
'url("fonts/',
|
||||
'url("chrome-extension://__MSG_@@extension_id__/fonts/'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (relativePath === "manifest.json") {
|
||||
const manifest = createManifest(contents, version, target);
|
||||
contents = Buffer.from(`${JSON.stringify(manifest, null, 2)}\n`);
|
||||
|
||||
@@ -74,6 +74,10 @@ test("builds a deterministic unsigned XPI with the release version and runtime f
|
||||
|
||||
assert.equal(first.archiveName, "glagolify-9.8.7.xpi");
|
||||
assert.deepEqual([...entries.keys()], [...FIREFOX_ARCHIVE_FILES]);
|
||||
assert.deepEqual(
|
||||
entries.get("content.css"),
|
||||
await readFile(path.join(rootDirectory, "content.css"))
|
||||
);
|
||||
const manifest = JSON.parse(entries.get("manifest.json"));
|
||||
assert.equal(manifest.version, "9.8.7");
|
||||
assert.equal(manifest.manifest_version, 2);
|
||||
@@ -127,6 +131,22 @@ test("builds a Chromium MV3 ZIP with Chromium manifest fields and raster icons",
|
||||
]);
|
||||
assert.equal(manifest.icons["128"], "icons/icon-128.png");
|
||||
|
||||
const contentCss = entries.get("content.css").toString("utf8");
|
||||
const fontUrls = [...contentCss.matchAll(/src: url\("([^"]+)"\)/g)].map(
|
||||
(match) => match[1]
|
||||
);
|
||||
const extensionUrl = "chrome-extension://__MSG_@@extension_id__/";
|
||||
assert.equal(fontUrls.length, 4);
|
||||
for (const fontUrl of fontUrls) {
|
||||
assert.equal(fontUrl.startsWith(extensionUrl), true);
|
||||
const relativePath = fontUrl.slice(extensionUrl.length);
|
||||
assert.equal(entries.has(relativePath), true);
|
||||
assert.equal(
|
||||
manifest.web_accessible_resources[0].resources.includes(relativePath),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
for (const relativePath of CHROMIUM_ARCHIVE_FILES.filter((name) =>
|
||||
name.endsWith(".png")
|
||||
)) {
|
||||
|
||||
Reference in New Issue
Block a user