tor-browser

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

top-layer.js (1147B)


      1 // This function is a version of test_driver.bless which works while there are
      2 // elements in the top layer:
      3 // https://github.com/web-platform-tests/wpt/issues/41218.
      4 // Pass it the element at the top of the top layer stack.
      5 window.blessTopLayer = async (topLayerElement) => {
      6  const button = document.createElement('button');
      7  topLayerElement.append(button);
      8  let wait_click = new Promise(resolve => button.addEventListener("click", resolve, {once: true}));
      9  await test_driver.click(button);
     10  await wait_click;
     11  button.remove();
     12 };
     13 
     14 window.isTopLayer = (el) => {
     15  // A bit of a hack. Just test a few properties of the ::backdrop pseudo
     16  // element that change when in the top layer.
     17  const properties = ['right','background'];
     18  const testEl = document.createElement('div');
     19  document.body.appendChild(testEl);
     20  const computedStyle = getComputedStyle(testEl, '::backdrop');
     21  const nonTopLayerValues = properties.map(p => computedStyle[p]);
     22  testEl.remove();
     23  for(let i=0;i<properties.length;++i) {
     24    if (getComputedStyle(el,'::backdrop')[properties[i]] !== nonTopLayerValues[i]) {
     25      return true;
     26    }
     27  }
     28  return false;
     29 };