test_bug1515822.html (1438B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test for Bug 1515822 - restore scroll position for display: contents children</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <style> 7 #shell { 8 display: contents; 9 } 10 #outer { 11 width: 200px; 12 height: 200px; 13 overflow: scroll; 14 } 15 #inner { 16 width: 400px; 17 height: 400px; 18 background: linear-gradient(to right bottom, white, black); 19 } 20 </style> 21 </head> 22 <body> 23 <div id="shell"> 24 <div id="outer"> 25 <div id="inner"> 26 </div> 27 </div> 28 </div> 29 <script> 30 SimpleTest.waitForExplicitFinish(); 31 32 SpecialPowers.pushPrefEnv({ 33 set: [ ["layout.disable-pixel-alignment", true] ] 34 }).then(() => { 35 const outer = document.querySelector('#outer'); 36 37 outer.scrollTop = 100; 38 outer.scrollLeft = 100; 39 document.body.offsetTop; // flush layout 40 is(outer.scrollTop, 100, 'scroll position should be moved'); 41 is(outer.scrollLeft, 100, 'scroll position should be moved'); 42 43 outer.parentElement.style.display = 'none'; 44 document.body.offsetTop; // flush layout 45 is(outer.scrollTop, 0, 'scroll position should be zero'); 46 is(outer.scrollLeft, 0, 'scroll position should be zero'); 47 48 outer.parentElement.style.display = ""; 49 document.body.offsetTop; // flush layout 50 is(outer.scrollTop, 100, 'scroll position should be restored'); 51 is(outer.scrollLeft, 100, 'scroll position should be restored'); 52 SimpleTest.finish(); 53 }); 54 </script>