getComputedStyle-layout-dependent-replaced-into-ib-split.html (1356B)
1 <!doctype html> 2 <title>getComputedStyle() returns the right style for layout-dependent properties for nodes that have been just inserted into the document, and that have an ancestor whose layout tree was recreated (like an IB-split)</title> 3 <link rel="help" href="https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle"> 4 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1585882"> 5 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> 6 <link rel="author" title="Mozilla" href="https://mozilla.org"> 7 <script src=/resources/testharness.js></script> 8 <script src=/resources/testharnessreport.js></script> 9 <style> 10 div { 11 width: 100%; 12 } 13 </style> 14 <span> 15 <div></div> 16 </span> 17 <script> 18 test(() => { 19 let oldDiv = document.querySelector("div"); 20 window.unused = oldDiv.getBoundingClientRect(); // update layout 21 22 let oldWidth = getComputedStyle(oldDiv).width; 23 assert_true(oldWidth.indexOf("px") !== -1, "Should return the used value for width"); 24 25 let newDiv = document.createElement("div"); 26 oldDiv.replaceWith(newDiv); 27 28 assert_equals(getComputedStyle(newDiv).width, oldWidth, "Should return the used value for width (just inserted into the document)"); 29 }, "getComputedStyle() should return used value correctly for nodes just inserted into the document, even if they're in an IB-split"); 30 </script>