1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
<!doctype html>
<title>Container Relative Units: Invalidation</title>
<link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-lengths">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/cq-testcommon.js"></script>
<style>
#inline { container-type: inline-size; }
#size, #outer { container-type: size; }
.h600 { height: 600px; }
.w500 { width: 500px; }
.h400 { height: 400px; }
.w300 { width: 300px; }
.child {
padding-left: 10cqi;
padding-right: 10cqb;
}
</style>
<div id=ref></div>
<div id=outer class="h600">
<div id=size class="w500 h400">
<div id=inline class="w300">
<div id=child class="child">Test</div>
<div><div id=deeper class="child">Test</div></div>
</div>
</div>
</div>
<script>
setup(() => assert_implements_size_container_queries());
function assert_cqi_equals(element, expected) {
assert_equals(getComputedStyle(element).paddingLeft, expected);
}
function assert_cqb_equals(element, expected) {
assert_equals(getComputedStyle(element).paddingRight, expected);
}
test(function(t) {
assert_cqi_equals(child, '30px');
assert_cqi_equals(deeper, '30px');
try {
inline.style.containerType = 'normal';
assert_cqi_equals(child, '50px');
assert_cqi_equals(deeper, '50px');
} finally {
inline.style = '';
}
assert_cqi_equals(child, '30px');
assert_cqi_equals(deeper, '30px');
}, `cqi respond when selected container changes type (inline-size -> normal)`);
test(function() {
assert_cqb_equals(child, '40px');
assert_cqb_equals(deeper, '40px');
try {
size.style.containerType = 'normal';
assert_cqb_equals(child, '60px');
assert_cqb_equals(deeper, '60px');
} finally {
size.style = '';
}
assert_cqb_equals(child, '40px');
assert_cqb_equals(deeper, '40px');
}, `cqb respond when selected container changes type (size -> normal)`);
test(function() {
assert_cqb_equals(child, '40px');
assert_cqb_equals(deeper, '40px');
try {
inline.style.containerType = 'size';
inline.style.height = '200px';
assert_cqb_equals(child, '20px');
assert_cqb_equals(deeper, '20px');
} finally {
inline.style = '';
}
assert_cqb_equals(child, '40px');
assert_cqb_equals(deeper, '40px');
}, `cqb respond when intermediate container changes type (inline-size -> size)`);
test(function() {
assert_cqi_equals(child, '30px');
assert_cqi_equals(deeper, '30px');
try {
inline.style.width = '50px';
assert_cqi_equals(child, '5px');
assert_cqi_equals(deeper, '5px');
} finally {
inline.style = '';
}
assert_cqi_equals(child, '30px');
assert_cqi_equals(deeper, '30px');
}, 'cqi respond when selected container changes inline-size');
test(function() {
assert_cqb_equals(child, '40px');
assert_cqb_equals(deeper, '40px');
try {
size.style.height = '50px';
assert_cqb_equals(child, '5px');
assert_cqb_equals(deeper, '5px');
} finally {
size.style = '';
}
assert_cqb_equals(child, '40px');
assert_cqb_equals(deeper, '40px');
}, 'cqb respond when selected container changes block-size');
</script>
|