image-object-fit-dyn-1.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE html>
  2. <!--
  3. Any copyright is dedicated to the Public Domain.
  4. http://creativecommons.org/publicdomain/zero/1.0/
  5. -->
  6. <!--
  7. This testcase ensures that we repaint correctly when "object-fit" is
  8. adjusted on a replaced element with SVG content. We start with
  9. "object-fit: contain", which lets some of the red background show through
  10. as we fit the SVG's square aspect-ratio into the wide rectangular
  11. container elements. We then change dynamically to "object-fit: cover",
  12. which should scale our SVG content to cover each replaced element's
  13. content-box. No red should ultimately be visible in the reftest snapshot.
  14. -->
  15. <html class="reftest-wait">
  16. <head>
  17. <meta charset="utf-8">
  18. <style type="text/css">
  19. embed, img, object, video {
  20. object-fit: contain;
  21. background: red;
  22. width: 50px;
  23. height: 30px;
  24. }
  25. </style>
  26. <script>
  27. function go() {
  28. var elemsToTweak = ["embed", "img", "object", "video"];
  29. elemsToTweak.forEach(tweakElemObjectFit);
  30. document.documentElement.removeAttribute("class");
  31. }
  32. function tweakElemObjectFit(tagName) {
  33. var elem = document.getElementsByTagName(tagName)[0];
  34. elem.style.objectFit = "cover";
  35. }
  36. document.addEventListener("MozReftestInvalidate", go);
  37. </script>
  38. </head>
  39. <body>
  40. <embed src="500.svg">
  41. <img src="500.svg">
  42. <object data="500.svg"></object>
  43. <video poster="500.svg"></video>
  44. </body>
  45. </html>