tor-browser

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

test_reframe_input.html (1566B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>Test for bug 1658302: We don't reframe for placeholder attribute value changes.</title>
      4 <link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
      5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6 <input id="input">
      7 <textarea id="textarea"></textarea>
      8 <script>
      9 SimpleTest.waitForExplicitFinish();
     10 const utils = SpecialPowers.DOMWindowUtils;
     11 
     12 function expectReframe(shouldHaveReframed, callback) {
     13  document.documentElement.offsetTop;
     14  const previousConstructCount = utils.framesConstructed;
     15  const previousReflowCount = utils.framesReflowed;
     16 
     17  callback();
     18 
     19  document.documentElement.offsetTop;
     20  isnot(previousReflowCount, utils.framesReflowed, "We should have reflowed");
     21  (shouldHaveReframed ? isnot : is)(previousConstructCount,
     22                                    utils.framesConstructed,
     23    `We should ${shouldHaveReframed ? "" : "not"} have reframed`);
     24 }
     25 
     26 for (const control of document.querySelectorAll("input, textarea")) {
     27  // Creating the placeholder attribute reframes right now.
     28  //
     29  // TODO: Could be avoided with some more work.
     30  expectReframe(true, () => {
     31    control.placeholder = "foo";
     32  });
     33 
     34  // Incrementally changing it should not reframe, just reflow.
     35  expectReframe(false, () => {
     36    control.placeholder = "bar";
     37  });
     38 
     39  // Removing the placeholder attribute reframes right now.
     40  //
     41  // TODO: Could maybe be avoided with some more work.
     42  expectReframe(true, () => {
     43    control.removeAttribute("placeholder");
     44  });
     45 }
     46 
     47 SimpleTest.finish();
     48 </script>