tor-browser

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

common.js (1983B)


      1 // Create a credentialless iframe. The new document will execute any scripts
      2 // sent toward the token it returns.
      3 const newIframeCredentialless = (child_origin, opt_headers) => {
      4  opt_headers ||= "";
      5  const sub_document_token = token();
      6  let iframe = document.createElement('iframe');
      7  iframe.src = child_origin + executor_path + opt_headers +
      8    `&uuid=${sub_document_token}`;
      9  iframe.credentialless = true;
     10  document.body.appendChild(iframe);
     11  return sub_document_token;
     12 };
     13 
     14 // Create a normal iframe. The new document will execute any scripts sent
     15 // toward the token it returns.
     16 const newIframe = (child_origin) => {
     17  const sub_document_token = token();
     18  let iframe = document.createElement('iframe');
     19  iframe.src = child_origin + executor_path + `&uuid=${sub_document_token}`;
     20  iframe.credentialless = false
     21  document.body.appendChild(iframe);
     22  return sub_document_token;
     23 };
     24 
     25 // Create a popup. The new document will execute any scripts sent toward the
     26 // token it returns.
     27 const newPopup = (test, origin) => {
     28  const popup_token = token();
     29  const popup = window.open(origin + executor_path + `&uuid=${popup_token}`);
     30  test.add_cleanup(() => popup.close());
     31  return popup_token;
     32 }
     33 
     34 // Create a fenced frame. The new document will execute any scripts sent
     35 // toward the token it returns.
     36 const newFencedFrame = async (child_origin) => {
     37  const support_loading_mode_fenced_frame =
     38    "|header(Supports-Loading-Mode,fenced-frame)";
     39  const sub_document_token = token();
     40  const url = child_origin + executor_path +
     41    support_loading_mode_fenced_frame +
     42    `&uuid=${sub_document_token}`;
     43  const urn = await generateURNFromFledge(url, []);
     44  attachFencedFrame(urn);
     45  return sub_document_token;
     46 };
     47 
     48 const importScript = (url) => {
     49  const script = document.createElement("script");
     50  script.type = "text/javascript";
     51  script.src = url;
     52  const loaded = new Promise(resolve => script.onload = resolve);
     53  document.body.appendChild(script);
     54  return loaded;
     55 }