tor-browser

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

addEmbed.window.js (1467B)


      1 // META: title=RemoteContextWrapper addEmbed
      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 rcHelper = new RemoteContextHelper();
     18 
     19  const main = await rcHelper.addWindow();
     20 
     21  const headerName = 'x-wpt-test-header';
     22  const headerValue = 'test-escaping()';
     23  const iframe = await main.addEmbed(
     24      /*extraConfig=*/ {
     25        origin: 'HTTP_REMOTE_ORIGIN',
     26        scripts: ['/common/get-host-info.sub.js', './resources/test-script.js'],
     27        headers: [[headerName, headerValue]],
     28      },
     29      /*attributes=*/ {id: 'test-id'},
     30  );
     31 
     32  await assertSimplestScriptRuns(iframe);
     33  await assertFunctionRuns(iframe, () => testFunction(), 'testFunction exists');
     34  await assertOriginIsAsExpected(iframe, get_host_info()['HTTP_REMOTE_ORIGIN']);
     35  await assertHeaderIsAsExpected(iframe, headerName, headerValue);
     36 
     37  assert_equals(
     38      await main.executeScript(() => document.getElementById('test-id').id),
     39      'test-id', 'verify id');
     40 });