Skip to content

Commit 2ccda94

Browse files
Fix up Firefox build
1 parent 6e6466e commit 2ccda94

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

unit-test/verify-artifacts.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { join, relative } from 'node:path'
2-
import { statSync } from 'node:fs'
2+
import { readFileSync, statSync } from 'node:fs'
33
import { cwd } from '../scripts/script-utils.js'
44

55
// path helpers
66
const ROOT = join(cwd(import.meta.url), '..')
77
const BUILD = join(ROOT, 'build')
88
const APPLE_BUILD = join(ROOT, 'Sources/ContentScopeScripts/dist')
9-
const CSS_OUTPUT_SIZE = 512000
9+
const CSS_OUTPUT_SIZE = 530000
1010
const CSS_OUTPUT_SIZE_CHROME = CSS_OUTPUT_SIZE * 1.45 // 45% larger for Chrome MV2 due to base64 encoding
1111

1212
const checks = {
@@ -17,10 +17,12 @@ const checks = {
1717
{ kind: 'maxFileSize', value: CSS_OUTPUT_SIZE_CHROME, path: join(BUILD, 'chrome/inject.js') }
1818
],
1919
'chrome-mv3': [
20-
{ kind: 'maxFileSize', value: CSS_OUTPUT_SIZE, path: join(BUILD, 'chrome-mv3/inject.js') }
20+
{ kind: 'maxFileSize', value: CSS_OUTPUT_SIZE, path: join(BUILD, 'chrome-mv3/inject.js') },
21+
{ kind: 'containsString', text: 'cloneInto(', path: join(BUILD, 'chrome-mv3/inject.js'), includes: false }
2122
],
2223
firefox: [
23-
{ kind: 'maxFileSize', value: CSS_OUTPUT_SIZE, path: join(BUILD, 'firefox/inject.js') }
24+
{ kind: 'maxFileSize', value: CSS_OUTPUT_SIZE, path: join(BUILD, 'firefox/inject.js') },
25+
{ kind: 'containsString', text: 'cloneInto(', path: join(BUILD, 'firefox/inject.js'), includes: true }
2426
],
2527
integration: [
2628
{ kind: 'maxFileSize', value: CSS_OUTPUT_SIZE, path: join(BUILD, 'integration/contentScope.js') }
@@ -36,13 +38,24 @@ const checks = {
3638
describe('checks', () => {
3739
for (const [platformName, platformChecks] of Object.entries(checks)) {
3840
for (const check of platformChecks) {
41+
const localPath = relative(ROOT, check.path)
3942
if (check.kind === 'maxFileSize') {
40-
const localPath = relative(ROOT, check.path)
4143
it(`${platformName}: '${localPath}' is smaller than ${check.value}`, () => {
4244
const stats = statSync(check.path)
4345
expect(stats.size).toBeLessThan(check.value)
4446
})
4547
}
48+
if (check.kind === 'containsString') {
49+
it(`${platformName}: '${localPath}' contains ${check.text}`, () => {
50+
const fileContents = readFileSync(localPath).toString()
51+
const includes = fileContents.includes(check.text)
52+
if (check.includes) {
53+
expect(includes).toBeTrue()
54+
} else {
55+
expect(includes).toBeFalse()
56+
}
57+
})
58+
}
4659
}
4760
}
4861
})

0 commit comments

Comments
 (0)