tor-browser

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

navigateToNew.window.js (1275B)


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