Bug 1914685 - [wpt-sync] Update web-platform-tests to 26c88095d89792c886494e30c85aca3...
[gecko.git] / layout / style / test / test_reframe_input.html
blob2887548abf97829f5c467317ecc0a4ebf1fcb1cb
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;
12 function expectReframe(shouldHaveReframed, callback) {
13 document.documentElement.offsetTop;
14 const previousConstructCount = utils.framesConstructed;
15 const previousReflowCount = utils.framesReflowed;
17 callback();
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`);
26 for (const control of document.querySelectorAll("input, textarea")) {
27 // Creating the placeholder attribute reframes right now.
29 // TODO: Could be avoided with some more work.
30 expectReframe(true, () => {
31 control.placeholder = "foo";
32 });
34 // Incrementally changing it should not reframe, just reflow.
35 expectReframe(false, () => {
36 control.placeholder = "bar";
37 });
39 // Removing the placeholder attribute reframes right now.
41 // TODO: Could maybe be avoided with some more work.
42 expectReframe(true, () => {
43 control.removeAttribute("placeholder");
44 });
47 SimpleTest.finish();
48 </script>