Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,33 @@ jobs:
run: cargo test -p dynwinrt
- name: Test dynwinrt-codegen
run: cargo test -p dynwinrt-codegen
- name: Enforce Classic COM coverage baseline
shell: pwsh
run: |
$json = cargo run -p dynwinrt-codegen --quiet -- com-census `
--winmd $env:DYNWINRT_WIN32_WINMD `
--json
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$result = $json | ConvertFrom-Json
if ($result.eligible_interfaces -ne 7929) {
throw "Classic COM census denominator changed: $($result.eligible_interfaces)"
}
if ($result.complete_interfaces -lt 5560) {
throw "Classic COM complete coverage regressed: $($result.complete_interfaces)"
}
if ($result.coverage_percent -lt 70.0) {
throw "Classic COM coverage fell below 70%: $($result.coverage_percent)"
}
Write-Host "Classic COM coverage: $($result.complete_interfaces)/$($result.eligible_interfaces) ($($result.coverage_percent)%)"
- name: Test Classic COM failure cleanup contracts
run: |
cargo test -p dynwinrt failing_hresult_releases_written_interface_output
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cargo test -p dynwinrt automation_validation_failure_cleans_other_owned_outputs
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cargo test -p dynwinrt bstr_in_out_failure_cleans_unchanged_replaced_and_null_slots
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cargo test -p dynwinrt excep_info_deferred_fill_runs_once_and_cleans_on_every_failure_path
- name: Check x86 Classic COM runtime
run: cargo check -p jswinrt_rs --target i686-pc-windows-msvc

Expand Down Expand Up @@ -161,3 +188,5 @@ jobs:
bindings/js/dist/winrt.d.ts
bindings/js/dist/com.js
bindings/js/dist/com.d.ts
bindings/js/dist/com-unsafe.js
bindings/js/dist/com-unsafe.d.ts
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions bindings/js/__test__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ test('Classic COM is isolated from the WinRT root entrypoint', (t) => {
t.false(Object.prototype.hasOwnProperty.call(comRuntime, 'DynComMethodSig'))
t.false(Object.prototype.hasOwnProperty.call(comRuntime, 'DynComInterface'))
t.false(Object.prototype.hasOwnProperty.call(comRuntime, 'DynComType'))
t.false(Object.prototype.hasOwnProperty.call(comRuntime, 'DynWinRTValue'))
t.false(Object.prototype.hasOwnProperty.call(comRuntime, 'WinGUID'))
t.is(typeof comRuntime.initializeCom, 'function')
t.truthy(DynCom)
t.truthy(DynComUnsafe)
Expand All @@ -52,6 +54,8 @@ test('Classic COM is isolated from the WinRT root entrypoint', (t) => {
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'DynComMethodSig'), false);" +
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'DynComInterface'), false);" +
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'DynComType'), false);" +
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'DynWinRTValue'), false);" +
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'WinGUID'), false);" +
"assert.equal(typeof winrt.DynWinRtType, 'function');" +
"assert.equal(typeof com.DynComVariant, 'function');" +
"assert.equal(typeof com.initializeCom, 'function');" +
Expand All @@ -75,6 +79,8 @@ test('Classic COM is isolated from the WinRT root entrypoint', (t) => {
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'DynComMethodSig'), false);" +
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'DynComInterface'), false);" +
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'DynComType'), false);" +
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'DynWinRTValue'), false);" +
"assert.equal(Object.prototype.hasOwnProperty.call(com, 'WinGUID'), false);" +
"assert.equal(typeof winrt.DynWinRtType, 'function');" +
"assert.equal(typeof com.DynComVariant, 'function');" +
"assert.equal(typeof com.initializeCom, 'function');" +
Expand Down Expand Up @@ -130,6 +136,29 @@ test('DynCom rejects pointers after their TypedArray backing store is detached',
t.regex(error.message, /backing ArrayBuffer is detached/)
})

test('Generated COM pointer helpers reject arbitrary numeric addresses', (t) => {
t.truthy(DynCom.safeDataPointer(Buffer.alloc(8)))
t.truthy(DynCom.safeDataPointer(new Uint8Array(8)))
t.throws(
() =>
(DynCom.safeDataPointer as unknown as (value: bigint) => unknown)(0x1234n),
{ message: /arbitrary numeric addresses/ },
)

t.truthy(DynCom.safeWideStringPointer('wide'))
t.truthy(DynCom.safeAnsiStringPointer('ansi'))
t.throws(
() =>
(DynCom.safeWideStringPointer as unknown as (value: bigint) => unknown)(0x1234n),
{ message: /arbitrary numeric addresses/ },
)
t.throws(
() =>
(DynCom.safeAnsiStringPointer as unknown as (value: number) => unknown)(0x1234),
{ message: /arbitrary numeric addresses/ },
)
})

test('DynCom rejects detached counted buffers and accepts typed backing widths', (t) => {
const detached = new Uint8Array(16)
structuredClone(detached.buffer, { transfer: [detached.buffer] })
Expand Down
7 changes: 3 additions & 4 deletions bindings/js/scripts/generate-entrypoints.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ const comExports = new Set([
'DynComSafeArray',
'DynComVariant',
'DynWinRtValue',
'DynWinRTValue',
'WinGuid',
'WinGUID',
'initializeCom',
])
const comTypeExports = [...comExports, 'DynComSafeArrayBound']
const comTypeAliases = ['DynWinRTValue', 'WinGUID']
const comTypeExports = [...comExports, ...comTypeAliases, 'DynComSafeArrayBound']
const comUnsafeExports = new Set([
...comExports,
'DynCom',
Expand All @@ -43,7 +42,7 @@ const comUnsafeExports = new Set([
'DynComUnsafe',
'DynComUnsafeInterface',
])
const comUnsafeTypeExports = [...comUnsafeExports, 'DynComSafeArrayBound']
const comUnsafeTypeExports = [...comUnsafeExports, ...comTypeAliases, 'DynComSafeArrayBound']

writeFacade(
'winrt',
Expand Down
Loading
Loading