- setThreadDpiAwareness checks SetThreadDpiAwarenessContext's return value
and cascades per-monitor-v2 -> per-monitor -> system-aware; DPI stays a
deliberate cosmetic best-effort - a host accepting none (or lacking the
API, pre-1607) still gets the modern dialog instead of a downgrade to the
legacy fallback chain over a cosmetic concern.
- The mocked-koffi world now uses a distinctive 4-byte pointer width and
rejects mis-sized out-buffers and mis-divided vtable offsets, so a
regression to hardcoded 8s fails the suite (the ia32 bug class).
- A keyless built-worker e2e guard loads lib/worker.cjs under plain
worker_threads on POSIX (the workflow-workerthread shape).
- The 'loaded lazily' module claims are reworded to attribute laziness to
the dynamic import('koffi') calls, and the discarded close-attempt
rejection is named at its catch.
32 lines
1.5 KiB
TypeScript
32 lines
1.5 KiB
TypeScript
/**
|
|
* Keyless built-artifact guard (the `dsh-workflow-workerthread` built-worker
|
|
* shape): plain `worker_threads` loads `lib/worker.cjs` and the bundle reaches
|
|
* its real koffi requires. POSIX hosts prove the load path end to end through
|
|
* the deterministic ole32 rejection; win32 skips (a real dialog would open),
|
|
* where the win32-only smoke in win32-dialog.spec.ts covers the source plane
|
|
* instead. Skips until a build produces the artifact.
|
|
*/
|
|
|
|
import { existsSync } from 'node:fs'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { Worker } from 'node:worker_threads'
|
|
import { describe, expect, it } from 'vitest'
|
|
import type { Win32DialogWorkerMessage } from '../src/win32-dialog-worker.ts'
|
|
|
|
const builtWorker = fileURLToPath(new URL('../lib/worker.cjs', import.meta.url))
|
|
|
|
describe.skipIf(!existsSync(builtWorker) || process.platform === 'win32')('built dialog worker (lib/worker.cjs)', () => {
|
|
it('loads under plain worker_threads and reports the native-surface failure', async () => {
|
|
const message = await new Promise<Win32DialogWorkerMessage>((resolve, reject) => {
|
|
const worker = new Worker(builtWorker, { workerData: { title: 'Built-artifact guard' } })
|
|
worker.on('message', resolve)
|
|
worker.on('error', reject)
|
|
worker.on('exit', (code) => {
|
|
reject(new Error(`worker exited (${code}) before reporting`))
|
|
})
|
|
})
|
|
expect(message.kind).toBe('error')
|
|
expect((message as { kind: 'error'; message: string }).message).toMatch(/ole32|koffi/i)
|
|
}, 30_000)
|
|
})
|