test_video_object_fit.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=1065766
  5. -->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Test for Bug 1065766</title>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  11. </head>
  12. <body>
  13. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1065766">Mozilla Bug 1065766</a>
  14. <div id="content" style="display: none">
  15. <video id="myVideo"></video>
  16. </div>
  17. <pre id="test">
  18. <script type="application/javascript">
  19. "use strict";
  20. /**
  21. * Test for Bug 1065766
  22. *
  23. * This test verifies that <video> has 'object-fit:contain' by default, set via
  24. * a UA stylesheet. (This is different from the property's initial value, which
  25. * is "fill".)
  26. *
  27. * Spec reference:
  28. * https://html.spec.whatwg.org/multipage/rendering.html#video-object-fit
  29. */
  30. function checkStyle(elem, expectedVal, message) {
  31. is(window.getComputedStyle(elem, "").objectFit, expectedVal, message);
  32. }
  33. function main() {
  34. const videoElem = document.getElementById("myVideo");
  35. checkStyle(videoElem, "contain",
  36. "<video> should have 'object-fit:contain' by default");
  37. // Make sure we can override this behavior (i.e. that the UA stylesheet
  38. // doesn't use "!important" to make this style mandatory):
  39. videoElem.style.objectFit = "cover";
  40. checkStyle(videoElem, "cover",
  41. "<video> should honor 'object-fit:cover' in inline style");
  42. }
  43. main();
  44. </script>
  45. </pre>
  46. </body>
  47. </html>