| <!DOCTYPE HTML> |
| <script src="../resources/js-test.js"></script> |
| <iframe id="i" frameborder="0" style="margin-top: 10px"></iframe> |
| <div id="content" style="display: none"> |
| <div id="block1" style='background-color: #ccc'>100% width</div><br> |
| <div style='background-color: #ddf; width: 400px; height: 300px'></div> |
| </div> |
| <script> |
| |
| var idoc = document.querySelector("#i").contentDocument; |
| var sheet = idoc.head.appendChild(idoc.createElement("style")).sheet; |
| |
| idoc.body.style.margin = '0'; |
| idoc.body.innerHTML = document.querySelector('#content').innerHTML; |
| |
| var block = idoc.querySelector("#block1"); |
| var origWidth = block.offsetWidth; |
| |
| sheet.insertRule("::-webkit-scrollbar { width: 50px; height: 20px; }", 0); |
| sheet.insertRule("::-webkit-scrollbar-thumb { background: #cce; }", 1); |
| |
| var width = block.offsetWidth; |
| |
| shouldBe("250", String(width)); |
| shouldBeTrue("width < origWidth"); |
| |
| </script> |