Skip to content

Commit ca62a15

Browse files
Release build 4.10.0 [ci release]
1 parent 97bd840 commit ca62a15

File tree

4 files changed

+112
-21
lines changed

4 files changed

+112
-21
lines changed

build/firefox/inject.js

Lines changed: 86 additions & 9 deletions
Large diffs are not rendered by default.

scripts/inject.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { rollupScript } from './utils/build.js'
22
import { parseArgs, write } from './script-utils.js'
3+
import { camelcase } from '../src/utils.js'
34

45
const contentScopePath = 'src/content-scope-features.js'
56
const contentScopeName = 'contentScopeFeatures'
@@ -40,7 +41,9 @@ const builds = {
4041
}
4142

4243
async function initOther (injectScriptPath, platformName) {
43-
const injectScript = await rollupScript(injectScriptPath, `inject${platformName}`)
44+
const supportsMozProxies = platformName === 'firefox'
45+
const identName = `inject${camelcase(platformName)}`
46+
const injectScript = await rollupScript(injectScriptPath, identName, supportsMozProxies)
4447
const outputScript = injectScript
4548
return outputScript
4649
}
@@ -73,7 +76,7 @@ async function init () {
7376
if (args.platform === 'chrome') {
7477
output = await initChrome(build.input)
7578
} else {
76-
output = await initOther(build.input)
79+
output = await initOther(build.input, args.platform)
7780
}
7881

7982
// bundle and write the output

scripts/utils/build.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ function runtimeInjections () {
4343
}
4444
}
4545

46-
export async function rollupScript (scriptPath, name, supportsMozProxies = true) {
47-
let mozProxies = false
46+
export async function rollupScript (scriptPath, name, supportsMozProxies = false) {
4847
// The code is using a global, that we define here which means once tree shaken we get a browser specific output.
49-
if (process.argv[2] === 'firefox' && supportsMozProxies) {
50-
mozProxies = true
51-
}
48+
const mozProxies = supportsMozProxies
49+
5250
const inputOptions = {
5351
input: scriptPath,
5452
plugins: [

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)