tor-browser

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

constructor.window.js (1275B)


      1 // META: title=RemoteContextHelper constructor
      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  // Precondition: Test was loaded from the HTTP_ORIGIN.
     13  assert_equals(
     14      location.origin, get_host_info()['HTTP_ORIGIN'],
     15      'test window was loaded on HTTP_ORIGIN');
     16 
     17  const headerName = 'x-wpt-test-header';
     18  const headerValue = 'test-escaping()';
     19  const rcHelper = new RemoteContextHelper({
     20    origin: 'HTTP_REMOTE_ORIGIN',
     21    scripts: [
     22      '/common/get-host-info.sub.js',
     23      './resources/test-script.js',
     24    ],
     25    headers: [[headerName, headerValue]],
     26  });
     27 
     28 
     29  const main = await rcHelper.addWindow();
     30 
     31  await assertSimplestScriptRuns(main);
     32  await assertFunctionRuns(main, () => testFunction(), 'testFunction exists');
     33 
     34  // Verify that the origin is different.
     35  await assertOriginIsAsExpected(main, get_host_info()['HTTP_REMOTE_ORIGIN']);
     36 
     37  await assertHeaderIsAsExpected(main, headerName, headerValue);
     38 });