tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

addWindow-extra-config.window.js (1451B)


      1 // META: title=RemoteContextHelper addWindow with extra config
      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 promise_test(async t => {
     12  const header1Name = 'x-wpt-test-header1';
     13  const header1Value = 'test-escaping1()';
     14  const rcHelper = new RemoteContextHelper({
     15    origin: 'HTTP_REMOTE_ORIGIN',
     16    scripts: ['/common/get-host-info.sub.js', './resources/test-script.js'],
     17    headers: [[header1Name, header1Value]],
     18  });
     19 
     20  const header2Name = 'x-wpt-test-header2';
     21  const header2Value = 'test-escaping2()';
     22  const main = await rcHelper.addWindow(
     23      {
     24        origin: location.origin,
     25        scripts: [new URL('./resources/test-script2.js', location).toString()],
     26        headers: [[header2Name, header2Value]],
     27      },
     28  );
     29 
     30  await assertSimplestScriptRuns(main);
     31  await assertFunctionRuns(main, () => testFunction(), 'testFunction exists');
     32  await assertFunctionRuns(main, () => testFunction2(), 'testFunction2 exists');
     33  await assertOriginIsAsExpected(main, location.origin);
     34  await assertHeaderIsAsExpected(main, header1Name, header1Value);
     35  await assertHeaderIsAsExpected(main, header2Name, header2Value);
     36 });