const cases = { internal: '', external: '', }; const loaded = new Promise(resolve => { window.addEventListener('load', resolve); }); Object.entries(cases).forEach(([k, v]) => { const xsltSrc = `
${v}
`; const processor = new XSLTProcessor(); const parser = new DOMParser(); processor.importStylesheet( parser.parseFromString(xsltSrc, 'application/xml') ); document.body.appendChild( processor.transformToFragment( parser.parseFromString('', 'application/xml'), document ) ); promise_test(async () => { await loaded; assert_true( window[`${k}Script`], 'script element from XSLTProcessor.transformToFragment() is evaluated' ); }, `${k} script`); })