Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 131 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-anchor-position/try-tactic-position-area.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>CSS Anchor Positioning: try-tactic, position-area</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#typedef-position-try-fallbacks-try-tactic">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#cb {
position: absolute;
width: 400px;
height: 400px;
border: 1px solid black;
}
#anchor {
position: absolute;
left: 150px;
top: 150px;
width: 100px;
height: 50px;
background-color: coral;
}
#target {
position: absolute;
left: 450px; /* force fallback */
width: 40px;
height: 40px;
background-color: skyblue;
}
</style>
<style id=style>
</style>
<div id=cb>
<div id=target></div>
</div>
<script>
function test_computed_value(try_tactic, property, value, expected, direction, writing_mode) {
if (direction==undefined) {
direction = 'ltr';
}
if (writing_mode==undefined) {
writing_mode = 'horizontal-tb';
}
test((t) => {
t.add_cleanup(() => {
style.textContent = '';
document.documentElement.style = '';
});
document.documentElement.style.direction = direction;
document.documentElement.style.writingMode = writing_mode;
style.textContent = `
@position-try --pf {
inset: initial;
${property}:${value};
}
#target {
position-try-fallbacks: --pf ${try_tactic};
}
`;
assert_equals(getComputedStyle(target).getPropertyValue(property), expected);
}, `${try_tactic}, ${property}:${value}, ${direction} ${writing_mode}`);
}
// Physical:
test_computed_value('flip-inline', 'position-area', 'left top', 'right top');
test_computed_value('flip-inline', 'position-area', 'left bottom', 'right bottom');
test_computed_value('flip-inline', 'position-area', 'right bottom', 'left bottom');
test_computed_value('flip-inline', 'position-area', 'right top', 'left top');
test_computed_value('flip-block', 'position-area', 'left top', 'left bottom');
test_computed_value('flip-block', 'position-area', 'left bottom', 'left top');
test_computed_value('flip-block', 'position-area', 'right bottom', 'right top');
test_computed_value('flip-block', 'position-area', 'right top', 'right bottom');
test_computed_value('flip-block flip-inline', 'position-area', 'left top', 'right bottom');
test_computed_value('flip-block flip-inline', 'position-area', 'left bottom', 'right top');
test_computed_value('flip-block flip-inline', 'position-area', 'right bottom', 'left top');
test_computed_value('flip-block flip-inline', 'position-area', 'right top', 'left bottom');
test_computed_value('flip-start', 'position-area', 'left top', 'left top');
test_computed_value('flip-start', 'position-area', 'left bottom', 'right top');
test_computed_value('flip-start', 'position-area', 'right bottom', 'right bottom');
test_computed_value('flip-start', 'position-area', 'right top', 'left bottom');
test_computed_value('flip-block flip-start', 'position-area', 'left top', 'right top');
test_computed_value('flip-block flip-start', 'position-area', 'left bottom', 'left top');
test_computed_value('flip-block flip-start', 'position-area', 'right bottom', 'left bottom');
test_computed_value('flip-block flip-start', 'position-area', 'right top', 'right bottom');
test_computed_value('flip-inline flip-start', 'position-area', 'left top', 'left bottom');
test_computed_value('flip-inline flip-start', 'position-area', 'left bottom', 'right bottom');
test_computed_value('flip-inline flip-start', 'position-area', 'right bottom', 'right top');
test_computed_value('flip-inline flip-start', 'position-area', 'right top', 'left top');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'left top', 'right bottom');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'left bottom', 'left bottom');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'right bottom', 'left top');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'right top', 'right top');
// Variations:
test_computed_value('flip-block flip-inline', 'position-area', 'span-left span-top', 'span-right span-bottom');
// XY:
test_computed_value('flip-inline', 'position-area', 'x-start y-start', 'x-end y-start');
test_computed_value('flip-inline', 'position-area', 'x-start y-end', 'x-end y-end');
test_computed_value('flip-inline', 'position-area', 'x-end y-end', 'x-start y-end');
test_computed_value('flip-inline', 'position-area', 'x-end y-start', 'x-start y-start');
test_computed_value('flip-block', 'position-area', 'x-start y-start', 'x-start y-end');
test_computed_value('flip-block', 'position-area', 'x-start y-end', 'x-start y-start');
test_computed_value('flip-block', 'position-area', 'x-end y-end', 'x-end y-start');
test_computed_value('flip-block', 'position-area', 'x-end y-start', 'x-end y-end');
test_computed_value('flip-block flip-inline', 'position-area', 'x-start y-start', 'x-end y-end');
test_computed_value('flip-block flip-inline', 'position-area', 'x-start y-end', 'x-end y-start');
test_computed_value('flip-block flip-inline', 'position-area', 'x-end y-end', 'x-start y-start');
test_computed_value('flip-block flip-inline', 'position-area', 'x-end y-start', 'x-start y-end');
test_computed_value('flip-start', 'position-area', 'x-start y-start', 'x-start y-start');
test_computed_value('flip-start', 'position-area', 'x-start y-end', 'x-end y-start');
test_computed_value('flip-start', 'position-area', 'x-end y-end', 'x-end y-end');
test_computed_value('flip-start', 'position-area', 'x-end y-start', 'x-start y-end');
test_computed_value('flip-block flip-start', 'position-area', 'x-start y-start', 'x-end y-start');
test_computed_value('flip-block flip-start', 'position-area', 'x-start y-end', 'x-start y-start');
test_computed_value('flip-block flip-start', 'position-area', 'x-end y-end', 'x-start y-end');
test_computed_value('flip-block flip-start', 'position-area', 'x-end y-start', 'x-end y-end');
test_computed_value('flip-inline flip-start', 'position-area', 'x-start y-start', 'x-start y-end');
test_computed_value('flip-inline flip-start', 'position-area', 'x-start y-end', 'x-end y-end');
test_computed_value('flip-inline flip-start', 'position-area', 'x-end y-end', 'x-end y-start');
test_computed_value('flip-inline flip-start', 'position-area', 'x-end y-start', 'x-start y-start');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'x-start y-start', 'x-end y-end');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'x-start y-end', 'x-start y-end');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'x-end y-end', 'x-start y-start');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'x-end y-start', 'x-end y-start');
// Variations:
test_computed_value('flip-block flip-inline', 'position-area', 'span-x-start span-y-start', 'span-x-end span-y-end');
test_computed_value('flip-block flip-inline', 'position-area', 'x-self-start y-self-start', 'x-self-end y-self-end');
test_computed_value('flip-block flip-inline', 'position-area', 'span-x-self-start span-y-self-start', 'span-x-self-end span-y-self-end');
// Logical:
test_computed_value('flip-inline', 'position-area', 'block-start inline-start', 'block-start inline-end');
test_computed_value('flip-inline', 'position-area', 'block-end inline-start', 'block-end inline-end');
test_computed_value('flip-inline', 'position-area', 'block-end inline-end', 'block-end inline-start');
test_computed_value('flip-inline', 'position-area', 'block-start inline-end', 'block-start inline-start');
test_computed_value('flip-block', 'position-area', 'block-start inline-start', 'block-end inline-start');
test_computed_value('flip-block', 'position-area', 'block-end inline-start', 'block-start inline-start');
test_computed_value('flip-block', 'position-area', 'block-end inline-end', 'block-start inline-end');
test_computed_value('flip-block', 'position-area', 'block-start inline-end', 'block-end inline-end');
test_computed_value('flip-block flip-inline', 'position-area', 'block-start inline-start', 'block-end inline-end');
test_computed_value('flip-block flip-inline', 'position-area', 'block-end inline-start', 'block-start inline-end');
test_computed_value('flip-block flip-inline', 'position-area', 'block-end inline-end', 'block-start inline-start');
test_computed_value('flip-block flip-inline', 'position-area', 'block-start inline-end', 'block-end inline-start');
test_computed_value('flip-start', 'position-area', 'block-start inline-start', 'block-start inline-start');
test_computed_value('flip-start', 'position-area', 'block-end inline-start', 'block-start inline-end');
test_computed_value('flip-start', 'position-area', 'block-end inline-end', 'block-end inline-end');
test_computed_value('flip-start', 'position-area', 'block-start inline-end', 'block-end inline-start');
test_computed_value('flip-block flip-start', 'position-area', 'block-start inline-start', 'block-start inline-end');
test_computed_value('flip-block flip-start', 'position-area', 'block-end inline-start', 'block-start inline-start');
test_computed_value('flip-block flip-start', 'position-area', 'block-end inline-end', 'block-end inline-start');
test_computed_value('flip-block flip-start', 'position-area', 'block-start inline-end', 'block-end inline-end');
test_computed_value('flip-inline flip-start', 'position-area', 'block-start inline-start', 'block-end inline-start');
test_computed_value('flip-inline flip-start', 'position-area', 'block-end inline-start', 'block-end inline-end');
test_computed_value('flip-inline flip-start', 'position-area', 'block-end inline-end', 'block-start inline-end');
test_computed_value('flip-inline flip-start', 'position-area', 'block-start inline-end', 'block-start inline-start');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'block-start inline-start', 'block-end inline-end');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'block-end inline-start', 'block-end inline-start');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'block-end inline-end', 'block-start inline-start');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'block-start inline-end', 'block-start inline-end');
// Variations:
test_computed_value('flip-block flip-inline', 'position-area', 'span-block-start span-inline-start', 'span-block-end span-inline-end');
test_computed_value('flip-block flip-inline', 'position-area', 'self-block-start self-inline-start', 'self-block-end self-inline-end');
test_computed_value('flip-block flip-inline', 'position-area', 'span-self-block-start span-self-inline-start', 'span-self-block-end span-self-inline-end');
// start/end
test_computed_value('', 'position-area', 'start end', 'start end');
test_computed_value('flip-block', 'position-area', 'start end', 'end');
test_computed_value('flip-inline', 'position-area', 'start end', 'start');
test_computed_value('flip-block flip-inline', 'position-area', 'start end', 'end start');
test_computed_value('flip-start', 'position-area', 'start', 'start');
test_computed_value('flip-start', 'position-area', 'end', 'end');
test_computed_value('flip-start', 'position-area', 'start end', 'end start');
test_computed_value('flip-block flip-start', 'position-area', 'start end', 'end');
test_computed_value('flip-inline flip-start', 'position-area', 'start end', 'start');
test_computed_value('flip-block flip-inline flip-start', 'position-area', 'start end', 'start end');
// Variations:
test_computed_value('flip-block flip-inline', 'position-area', 'span-start span-end', 'span-end span-start');
test_computed_value('flip-block flip-inline', 'position-area', 'self-start self-end', 'self-end self-start');
test_computed_value('flip-block flip-inline', 'position-area', 'span-self-start span-self-end', 'span-self-end span-self-start');
// center
test_computed_value('flip-block', 'position-area', 'left center', 'left center');
test_computed_value('flip-block', 'position-area', 'center top', 'center bottom');
test_computed_value('flip-block', 'position-area', 'center', 'center');
test_computed_value('flip-block', 'position-area', 'start center', 'end center');
test_computed_value('flip-block', 'position-area', 'center start', 'center start');
test_computed_value('flip-inline', 'position-area', 'center start', 'center end');
test_computed_value('flip-start', 'position-area', 'center start', 'start center');
// span-all
test_computed_value('flip-block', 'position-area', 'left span-all', 'left');
test_computed_value('flip-block', 'position-area', 'span-all top', 'bottom');
test_computed_value('flip-block', 'position-area', 'span-all', 'span-all');
test_computed_value('flip-block', 'position-area', 'start span-all', 'end span-all');
test_computed_value('flip-block', 'position-area', 'span-all start', 'span-all start');
test_computed_value('flip-inline', 'position-area', 'span-all start', 'span-all end');
test_computed_value('flip-start', 'position-area', 'span-all start', 'start span-all');
// Span mix:
test_computed_value('flip-block', 'position-area', 'left span-top', 'left span-bottom');
test_computed_value('flip-inline', 'position-area', 'left span-top', 'right span-top');
test_computed_value('flip-start', 'position-area', 'span-block-start inline-end', 'block-end span-inline-start');
// Writing modes:
test_computed_value('flip-block', 'position-area', 'left top', 'right top', 'ltr', 'vertical-rl');
test_computed_value('', 'position-area', 'x-start y-start', 'x-start y-start', 'rtl');
test_computed_value('flip-block', 'position-area', 'x-start y-start', 'x-start y-end', 'rtl');
test_computed_value('flip-inline', 'position-area', 'x-start y-start', 'x-end y-start', 'rtl');
test_computed_value('flip-block', 'position-area', 'x-end y-start', 'x-start y-start', 'ltr', 'vertical-rl');
test_computed_value('flip-inline', 'position-area', 'x-end y-start', 'x-end y-end', 'ltr', 'vertical-rl');
test_computed_value('flip-inline', 'position-area', 'start end', 'start', 'rtl');
test_computed_value('flip-inline', 'position-area', 'start end', 'start', 'ltr', 'vertical-rl');
test_computed_value('flip-block', 'position-area', 'start end', 'end', 'rtl');
test_computed_value('flip-block', 'position-area', 'start end', 'end', 'ltr', 'vertical-rl');
</script>