This allows to get the container for a given element at a specific condition index, which will be passed from DevTools code. Differential Revision: https://phabricator.services.mozilla.com/D291211
73 lines
2.7 KiB
HTML
73 lines
2.7 KiB
HTML
<!doctype html>
|
|
<title>Test for bug 1789191</title>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
|
|
<style>
|
|
@container (min-width: 0px) {
|
|
}
|
|
|
|
@container name (min-width: 0px) {
|
|
}
|
|
|
|
@container (min-height: 0px) {
|
|
}
|
|
|
|
@container name (min-width: 0px), (width > 1px) {
|
|
}
|
|
|
|
div {
|
|
width: 100px;
|
|
height: 100px;
|
|
background-color: blue;
|
|
margin: 10px;
|
|
}
|
|
|
|
.container-height {
|
|
container-type: size;
|
|
}
|
|
|
|
.container-unnamed {
|
|
container-type: inline-size;
|
|
}
|
|
|
|
.container-named {
|
|
container-type: inline-size;
|
|
container-name: name;
|
|
}
|
|
</style>
|
|
|
|
<div id="child1"></div>
|
|
|
|
<div class="container-height" id="unnamedSizeContainer">
|
|
<div class="container-named" id="namedInlineSizeContainer">
|
|
<div class="container-unnamed" id="unnamedInlineSizeContainer">
|
|
<div id="child2"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let sheet = document.querySelector("style").sheet;
|
|
let withoutFilter = SpecialPowers.wrap(sheet.cssRules[0]);
|
|
let withFilter = SpecialPowers.wrap(sheet.cssRules[1]);
|
|
let heightQuery = SpecialPowers.wrap(sheet.cssRules[2]);
|
|
let withMultipleConditions = SpecialPowers.wrap(sheet.cssRules[3]);
|
|
|
|
// Container query selection requires up-to-date layout information.
|
|
document.body.getBoundingClientRect();
|
|
|
|
is(withoutFilter.queryContainerFor(child1, 0), null, "No filter, no container");
|
|
is(withFilter.queryContainerFor(child1, 0), null, "Filter, no container");
|
|
is(heightQuery.queryContainerFor(child1, 0), null, "Height, no container");
|
|
is(withMultipleConditions.queryContainerFor(child1, 0), null, "Multiple conditions, no container for first condition");
|
|
is(withMultipleConditions.queryContainerFor(child1, 1), null, "Multiple conditions, no container for second condition");
|
|
is(withMultipleConditions.queryContainerFor(child1, 2), null, "Multiple conditions, no container for unexisting condition index");
|
|
|
|
is(SpecialPowers.unwrap(withoutFilter.queryContainerFor(child2, 0)), unnamedInlineSizeContainer, "No filter, container");
|
|
is(SpecialPowers.unwrap(withFilter.queryContainerFor(child2, 0)), namedInlineSizeContainer, "Filter container");
|
|
is(SpecialPowers.unwrap(heightQuery.queryContainerFor(child2, 0)), unnamedSizeContainer, "Height");
|
|
is(SpecialPowers.unwrap(withMultipleConditions.queryContainerFor(child2, 0)), namedInlineSizeContainer, "Multiple conditions, container for first condition (Filter)");
|
|
is(SpecialPowers.unwrap(withMultipleConditions.queryContainerFor(child2, 1)), unnamedInlineSizeContainer, "Multiple conditions, container for second condition (No Filter)");
|
|
is(SpecialPowers.unwrap(withMultipleConditions.queryContainerFor(child2, 2)), null, "Multiple conditions, no container for unexisting condition index");
|
|
</script>
|