Skip to content

Commit

Permalink
Avoid asserting default sizes in {progress,meter}-native-computed-sty…
Browse files Browse the repository at this point in the history
…le.optional.html writing mode tests (#41997)

These tests currently assume that the default inline and block sizes of <progress>
and <meter> are the same across all browsers. That is not the case, and is irrelevant
to the purpose of the test, which is to assert that the block size should match
height/width and inline size should match width/height depending on the writing mode.

Replace the exact value assertions with assertions that test for an appropriate
aspect ratio (inline size greater than block size).
  • Loading branch information
pxlcoder committed Sep 16, 2023
1 parent ea143f2 commit cfdfe71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
test(() => {
const meter = document.querySelector(`meter[style="writing-mode: horizontal-tb"]`);
const style = getComputedStyle(meter);
assert_equals(style.blockSize, "16px");
assert_equals(style.inlineSize, "80px");
const blockSize = parseInt(style.blockSize, 10);
const inlineSize = parseInt(style.inlineSize, 10);
assert_not_equals(blockSize, 0);
assert_not_equals(inlineSize, 0);
assert_greater_than(inlineSize, blockSize);
assert_equals(style.blockSize, style.height);
assert_equals(style.inlineSize, style.width);
}, `meter[style="writing-mode: horizontal-tb"] block size should match height and inline size should match width`);
Expand All @@ -23,8 +26,11 @@
test(() => {
const meter = document.querySelector(`meter[style="writing-mode: ${writingMode}"]`);
const style = getComputedStyle(meter);
assert_equals(style.blockSize, "16px");
assert_equals(style.inlineSize, "80px");
const blockSize = parseInt(style.blockSize, 10);
const inlineSize = parseInt(style.inlineSize, 10);
assert_not_equals(blockSize, 0);
assert_not_equals(inlineSize, 0);
assert_greater_than(inlineSize, blockSize);
assert_equals(style.blockSize, style.width);
assert_equals(style.inlineSize, style.height);
}, `meter[style="writing-mode: ${writingMode}"] block size should match width and inline size should match height`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
test(() => {
const progress = document.querySelector(`progress[style="writing-mode: horizontal-tb"]`);
const style = getComputedStyle(progress);
assert_equals(style.blockSize, "16px");
assert_equals(style.inlineSize, "160px");
const blockSize = parseInt(style.blockSize, 10);
const inlineSize = parseInt(style.inlineSize, 10);
assert_not_equals(blockSize, 0);
assert_not_equals(inlineSize, 0);
assert_greater_than(inlineSize, blockSize);
assert_equals(style.blockSize, style.height);
assert_equals(style.inlineSize, style.width);
}, `progress[style="writing-mode: horizontal-tb"] block size should match height and inline size should match width`);
Expand All @@ -23,8 +26,11 @@
test(() => {
const progress = document.querySelector(`progress[style="writing-mode: ${writingMode}"]`);
const style = getComputedStyle(progress);
assert_equals(style.blockSize, "16px");
assert_equals(style.inlineSize, "160px");
const blockSize = parseInt(style.blockSize, 10);
const inlineSize = parseInt(style.inlineSize, 10);
assert_not_equals(blockSize, 0);
assert_not_equals(inlineSize, 0);
assert_greater_than(inlineSize, blockSize);
assert_equals(style.blockSize, style.width);
assert_equals(style.inlineSize, style.height);
}, `progress[style="writing-mode: ${writingMode}"] block size should match width and inline size should match height`);
Expand Down

0 comments on commit cfdfe71

Please sign in to comment.