PageRenderTime 914ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/third_party/blink/web_tests/external/wpt/html/semantics/forms/the-selectmenu-element/selectmenu-popup-position-with-zoom.tentative.html

https://github.com/chromium/chromium
HTML | 135 lines | 115 code | 20 blank | 0 comment | 0 complexity | b17d286bbf40c6c1eb057a50aa1ec0a9 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0, BSD-3-Clause
  1. <!DOCTYPE html>
  2. <html>
  3. <title>HTMLSelectMenuElement Test: popup position with zoom</title>
  4. <link rel="author" title="Ionel Popescu" href="mailto:iopopesc@microsoft.com">
  5. <script src="/resources/testharness.js"></script>
  6. <script src="/resources/testharnessreport.js"></script>
  7. <script src="/resources/testdriver.js"></script>
  8. <script src="/resources/testdriver-actions.js"></script>
  9. <script src="/resources/testdriver-vendor.js"></script>
  10. <style>
  11. #selectMenu0 {
  12. position: absolute;
  13. top: 0px;
  14. left: 0px;
  15. zoom: 2;
  16. }
  17. #selectMenu1 {
  18. position: absolute;
  19. bottom: 0px;
  20. left: 0px;
  21. zoom: 1.5;
  22. }
  23. #selectMenu1-popup {
  24. zoom: 2;
  25. }
  26. #selectMenu2 {
  27. position: absolute;
  28. top: 0px;
  29. right: 0px;
  30. zoom: 3;
  31. }
  32. #selectMenu3 {
  33. position: absolute;
  34. bottom: 0px;
  35. right: 0px;
  36. zoom: 4;
  37. }
  38. #selectMenu3-popup {
  39. zoom: 1.5;
  40. }
  41. </style>
  42. <selectmenu id="selectMenu0">
  43. <div slot="button" behavior="button" id="selectMenu0-button">Custom bottom left</div>
  44. <div popup slot="listbox" behavior="listbox" id="selectMenu0-popup">
  45. <option>bottom left</option>
  46. <option>two</option>
  47. <option>three</option>
  48. </div>
  49. </selectmenu>
  50. <br>
  51. <selectmenu id="selectMenu1">
  52. <div slot="button" behavior="button" id="selectMenu1-button">Custom top left</div>
  53. <div popup slot="listbox" behavior="listbox" id="selectMenu1-popup">
  54. <option>top left</option>
  55. <option>two</option>
  56. <option>three</option>
  57. </div>
  58. </selectmenu>
  59. <selectmenu id="selectMenu2">
  60. <div slot="button" behavior="button" id="selectMenu2-button">Custom bottom right</div>
  61. <div popup slot="listbox" behavior="listbox" id="selectMenu2-popup">
  62. <option>bottom right</option>
  63. <option>two</option>
  64. <option>three</option>
  65. </div>
  66. </selectmenu>
  67. <selectmenu id="selectMenu3">
  68. <div slot="button" behavior="button" id="selectMenu3-button">Custom top right</div>
  69. <div popup slot="listbox" behavior="listbox" id="selectMenu3-popup">
  70. <option>top right</option>
  71. <option>two</option>
  72. <option>three</option>
  73. </div>
  74. </selectmenu>
  75. <script>
  76. function clickOn(element) {
  77. const actions = new test_driver.Actions();
  78. return actions.pointerMove(0, 0, {origin: element})
  79. .pointerDown({button: actions.ButtonType.LEFT})
  80. .pointerUp({button: actions.ButtonType.LEFT})
  81. .send();
  82. }
  83. promise_test(async () => {
  84. const selectMenu0 = document.getElementById("selectMenu0");
  85. const selectMenu0Popup = document.getElementById("selectMenu0-popup");
  86. const selectMenu0Button = document.getElementById("selectMenu0-button");
  87. await clickOn(selectMenu0);
  88. assert_equals(Math.abs(Math.trunc(selectMenu0.getBoundingClientRect().bottom - selectMenu0Popup.getBoundingClientRect().top)), 0);
  89. assert_equals(Math.abs(Math.trunc(selectMenu0.getBoundingClientRect().left - selectMenu0Popup.getBoundingClientRect().left)), 0);
  90. }, "The popup should be bottom left positioned");
  91. promise_test(async () => {
  92. const selectMenu1 = document.getElementById("selectMenu1");
  93. const selectMenu1Popup = document.getElementById("selectMenu1-popup");
  94. const selectMenu1Button = document.getElementById("selectMenu1-button");
  95. selectMenu1Button.click();
  96. assert_equals(Math.abs(Math.trunc(selectMenu1.getBoundingClientRect().top - selectMenu1Popup.getBoundingClientRect().bottom * 2)), 0);
  97. assert_equals(Math.abs(Math.trunc(selectMenu1.getBoundingClientRect().left - selectMenu1Popup.getBoundingClientRect().left * 2)), 0);
  98. }, "The popup should be top left positioned");
  99. promise_test(async () => {
  100. const selectMenu2 = document.getElementById("selectMenu2");
  101. const selectMenu2Popup = document.getElementById("selectMenu2-popup");
  102. const selectMenu2Button = document.getElementById("selectMenu2-button");
  103. selectMenu2Button.click();
  104. assert_equals(Math.abs(Math.trunc(selectMenu2.getBoundingClientRect().bottom - selectMenu2Popup.getBoundingClientRect().top)), 0);
  105. assert_equals(Math.abs(Math.trunc(selectMenu2.getBoundingClientRect().right - selectMenu2Popup.getBoundingClientRect().right)), 0);
  106. }, "The popup should be bottom right positioned");
  107. promise_test(async () => {
  108. const selectMenu3 = document.getElementById("selectMenu3");
  109. const selectMenu3Popup = document.getElementById("selectMenu3-popup");
  110. const selectMenu3Button = document.getElementById("selectMenu3-button");
  111. selectMenu3Button.click();
  112. assert_equals(Math.abs(Math.trunc(selectMenu3.getBoundingClientRect().top - selectMenu3Popup.getBoundingClientRect().bottom * 1.5)), 0);
  113. assert_equals(Math.abs(Math.trunc(selectMenu3.getBoundingClientRect().right - selectMenu3Popup.getBoundingClientRect().right * 1.5)), 0);
  114. }, "The popup should be top right positioned");
  115. </script>