tor-browser

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

browser_selectpopup_width.js (1291B)


      1 const PAGE = `
      2 <!doctype html>
      3 <select style="width: 600px">
      4  <option>ABC</option>
      5  <option>DEFG</option>
      6 </select>
      7 `;
      8 
      9 function tick() {
     10  return new Promise(r =>
     11    requestAnimationFrame(() => requestAnimationFrame(r))
     12  );
     13 }
     14 
     15 add_setup(async function () {
     16  await SpecialPowers.pushPrefEnv({
     17    set: [["test.wait300msAfterTabSwitch", true]],
     18  });
     19 });
     20 
     21 add_task(async function () {
     22  const url = "data:text/html," + encodeURI(PAGE);
     23  await BrowserTestUtils.withNewTab(
     24    {
     25      gBrowser,
     26      url,
     27    },
     28    async function () {
     29      let popup = await openSelectPopup("click");
     30      let arrowSB = popup.shadowRoot.querySelector(".menupopup-arrowscrollbox");
     31      is(
     32        arrowSB.getBoundingClientRect().width,
     33        600,
     34        "Should be the right size"
     35      );
     36 
     37      // Trigger a layout change that would cause us to layout the popup again,
     38      // and change our menulist to be zero-size so that the anchor rect
     39      // codepath is used. We should still use the anchor rect to expand our
     40      // size.
     41      await tick();
     42 
     43      popup.closest("menulist").style.width = "0";
     44      popup.style.minWidth = "2px";
     45 
     46      await tick();
     47 
     48      is(
     49        arrowSB.getBoundingClientRect().width,
     50        600,
     51        "Should be the right size"
     52      );
     53    }
     54  );
     55 });