tor-browser

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

duplicate-name-order.html (1911B)


      1 <!DOCTYPE html>
      2 <title>Duplicate name lookup order</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="/common/utils.js"></script>
      6 <script src="/common/dispatcher/dispatcher.js"></script>
      7 <script src="/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js"></script>
      8 
      9 <body>
     10 <script>
     11 
     12 promise_test(async t => {
     13  const rcHelper = new RemoteContextHelper();
     14  const rcMain = await rcHelper.addWindow();
     15 
     16  const rcPopupA = await rcHelper.addWindow(undefined, { target: 'A' });
     17  const rcPopupB = await rcHelper.addWindow(undefined, { target: 'B' });
     18  const rcPopupC = await rcHelper.addWindow(undefined, { target: 'C' });
     19 
     20  const rcSiblingA = await rcMain.addIframe(undefined, { name: 'A' });
     21  const rcSiblingB = await rcMain.addIframe(undefined, { name: 'B' });
     22 
     23  const rcRequestor = await rcMain.addIframe();
     24 
     25  const rcChildA = await rcRequestor.addIframe(undefined, { name: 'A' });
     26 
     27  const windowIdentifiers = {
     28   'Main': rcMain,
     29   'PopupA': rcPopupA,
     30   'PopupB': rcPopupB,
     31   'PopupC': rcPopupC,
     32   'SiblingA': rcSiblingA,
     33   'SiblingB': rcSiblingB,
     34   'Requestor': rcRequestor,
     35   'ChildA': rcChildA,
     36  };
     37  for (const [windowIdentifier, remote] of Object.entries(windowIdentifiers)) {
     38    await remote.executeScript((windowIdentifier) => {
     39      window.windowIdentifier = windowIdentifier;
     40    }, [windowIdentifier]);
     41  }
     42 
     43  function performLookup(targetName) {
     44    return rcRequestor.executeScript((targetName) => {
     45        return window.open('', targetName).windowIdentifier;
     46      }, [targetName]);
     47  }
     48 
     49  assert_equals(await performLookup('A'), 'ChildA', 'subtree first');
     50  assert_equals(await performLookup('B'), 'SiblingB', 'then the rest of the tree');
     51  assert_equals(await performLookup('C'), 'PopupC', 'then other pages');
     52 }, 'Duplicate name lookup order');
     53 
     54 </script>
     55 </body>