Files
orca/config/scripts/electron-runtime-floor.test.ts
T
Jinjing 25908865b0 Bump Electron to 43.7.8 to fix find-in-page looping (#28909)
* Bump Electron to 43.7.8 to fix find-in-page looping

Find-in-page could loop when the host page contained iframes beside a
webview, so searches in the guest did not finish or wrap correctly.
Electron 43.7.8 includes the upstream fix (electron/electron#54199).

- Pin electron to 43.7.8 in package.json, pnpm-lock.yaml, and the
  Node runtime pin.
- Raise the runtime floor in electron-runtime-floor.test.ts to 43.7.8.
- Add an Electron regression test that runs a find traversal in a
  background window with host iframes before, after, and around a
  webview, checking forward and backward matches wrap correctly.

* rm junk file
2026-10-15 00:02:12 -07:00

50 lines
1.9 KiB
TypeScript

import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
/**
* Why a floor and not just a pin: Electron 43.5.0/43.6.0 set and unset `GDK_GL`
* around `gtk_init()` while FontConfig warmed up on a pool thread, and below
* glibc 2.41 that frees `environ` under a concurrent `getenv()` — a launch-time
* use-after-free on every Ubuntu we support (stablyai/orca#20081). 43.7.0 stops
* freeing the published `environ`. 43.7.0 itself threw `Invalid guestInstanceId` when a
* loaded `<webview>` left the DOM, which blanked browser tabs React re-inserted
* (electron/electron#53989); 43.7.4 fixes it. A downgrade past either re-ships the bug,
* and nothing else in the tree would notice.
*/
// 43.7.8 fixes find-in-page looping across host iframes (electron/electron#54199).
const MINIMUM_ELECTRON_VERSION = '43.7.8'
function parseVersion(specifier: string): [number, number, number] {
const match = /(\d+)\.(\d+)\.(\d+)/.exec(specifier)
if (!match) {
throw new Error(`unparseable Electron version: ${specifier}`)
}
return [Number(match[1]), Number(match[2]), Number(match[3])]
}
function meetsRuntimeFloor(specifier: string): boolean {
const version = parseVersion(specifier)
const floor = parseVersion(MINIMUM_ELECTRON_VERSION)
for (const [index, part] of version.entries()) {
if (part !== floor[index]) {
return part > floor[index]
}
}
return true
}
describe('electron runtime floor', () => {
it('pins Electron at or above the startup, webview-detach and find-in-page fixes', () => {
const packageJson = JSON.parse(
readFileSync(join(__dirname, '../../package.json'), 'utf-8')
) as { devDependencies: Record<string, string> }
const specifier = packageJson.devDependencies.electron
expect(
meetsRuntimeFloor(specifier),
`electron ${specifier} is below the ${MINIMUM_ELECTRON_VERSION} runtime floor`
).toBe(true)
})
})