@@ -158,10 +158,6 @@ async function runTest(filePath) {
158158 // Build sandbox with linkedom's DOM — use actual test HTML so querySelector finds inline script elements
159159 let { window : domWin , document } = parseHTML ( html )
160160
161- // Ensure elements testharness.js output handler expects (Bun needs these)
162- if ( ! document . getElementById ( 'log' ) ) { let el = document . createElement ( 'div' ) ; el . id = 'log' ; document . body ?. appendChild ( el ) }
163- if ( ! document . getElementById ( 'rerun' ) ) { let el = document . createElement ( 'button' ) ; el . id = 'rerun' ; document . body ?. appendChild ( el ) }
164-
165161 // Fix linkedom's innerText on script elements: linkedom collapses newlines,
166162 // but script content must preserve them (single-line // comments break otherwise)
167163 for ( let el of document . querySelectorAll ( 'script' ) )
@@ -189,7 +185,7 @@ async function runTest(filePath) {
189185 sandbox . window = sandbox
190186 sandbox . parent = sandbox
191187 sandbox . top = sandbox
192- sandbox . location = { href : 'https://localhost/' , protocol : 'https:' , search : '' , pathname : '/' }
188+ sandbox . location = { href : 'https://localhost/' , protocol : 'https:' , search : '' , pathname : '/' , toString ( ) { return this . href } }
193189
194190 // --- Browser API shims ---
195191
@@ -332,6 +328,9 @@ async function runTest(filePath) {
332328 CustomEvent : typeof CustomEvent !== 'undefined' ? CustomEvent : class CustomEvent extends Event {
333329 constructor ( type , opts = { } ) { super ( type , opts ) ; this . detail = opts . detail ?? null }
334330 } ,
331+ ErrorEvent : typeof ErrorEvent !== 'undefined' ? ErrorEvent : class ErrorEvent extends Event {
332+ constructor ( type , opts = { } ) { super ( type , opts ) ; this . message = opts . message ?? '' ; this . filename = opts . filename ?? '' ; this . lineno = opts . lineno ?? 0 ; this . colno = opts . colno ?? 0 ; this . error = opts . error ?? null }
333+ } ,
335334 Blob,
336335 URL : Object . assign ( function WPTUrl ( ...a ) { return new URL ( ...a ) } , {
337336 createObjectURL ( blob ) {
@@ -561,8 +560,9 @@ async function runTest(filePath) {
561560 sandbox . Array = vm . runInContext ( '[].constructor' , ctx )
562561
563562 try {
564- // Run testharness.js
563+ // Run testharness.js, disable DOM output (we capture results via callbacks)
565564 vm . runInContext ( testharnessCode , ctx , { filename : 'testharness.js' } )
565+ vm . runInContext ( 'setup({ output: false })' , ctx )
566566
567567 // Patch assert_throws_dom to check by name (our DOMExceptions come from a different realm)
568568 vm . runInContext ( `
0 commit comments