addWorkerNull.window.js (1137B)
1 // META: title=RemoteContextWrapper addWorker no global variable 2 // META: script=/common/dispatcher/dispatcher.js 3 // META: script=/common/get-host-info.sub.js 4 // META: script=/common/utils.js 5 // META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js 6 // META: script=./resources/test-helper.js 7 8 'use strict'; 9 10 // This tests that arguments passed to the constructor are respected. 11 // Specifically `null` for the parameter `globalVariable`. 12 promise_test(async t => { 13 const rcHelper = new RemoteContextHelper(); 14 15 const main = await rcHelper.addWindow(); 16 17 const headerName = 'x-wpt-test-header'; 18 const headerValue = 'test-escaping()'; 19 const worker = await main.addWorker( 20 null, 21 { 22 scripts: ['/common/get-host-info.sub.js', './resources/test-script.js'], 23 headers: [[headerName, headerValue]], 24 }, 25 ); 26 27 await assertSimplestScriptRuns(worker); 28 await assertFunctionRuns(worker, () => testFunction(), 'testFunction exists'); 29 await assertOriginIsAsExpected(worker, location.origin); 30 await assertHeaderIsAsExpected(worker, headerName, headerValue); 31 });