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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
<!DOCTYPE html>
<meta charset="utf-8" />
<title>'inert' is an HTML attribute and has no effect when used on other elements</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<style>
#tests {
line-height: 1.5em;
}
#tests svg {
height: 1.5em;
vertical-align: middle;
}
#tests svg > text {
transform: translateY(50%);
dominant-baseline: central;
}
#tests foreignObject {
height: 100%;
width: 100%;
}
</style>
<div id="log"></div>
<ul id="tests">
<!-- The 'inert' attribute only works on HTML elements -->
<li>
<span>non-inert</span>
</li>
<li>
<span inert>inert</span>
</li>
<li>
<foo>non-inert</foo>
</li>
<li>
<foo inert>inert</foo>
</li>
<li>
<foo-bar>non-inert</foo-bar>
</li>
<li>
<foo-bar inert>inert</foo-bar>
</li>
<li>
<math><mi>non-inert</mi></math>
</li>
<li>
<math inert><mi>non-inert</mi></math>
</li>
<li>
<math><mi inert>non-inert</mi></math>
</li>
<li>
<svg><text>non-inert</text></svg>
</li>
<li>
<svg inert><text>non-inert</text></svg>
</li>
<li>
<svg><text inert>non-inert</text></svg>
</li>
<!-- But non-HTML are inert if an HTML ancestor has the attribute -->
<li>
<span inert><span>inert</span></span>
</li>
<li>
<span inert><foo>inert</foo></span>
</li>
<li>
<span inert><foo-bar>inert</foo-bar></span>
</li>
<li>
<span inert><math><mi>inert</mi></math></span>
</li>
<li>
<span inert><svg><text>inert</text></svg></span>
</li>
<!-- HTML elements are not inert if an non-HTML ancestor has the attribute -->
<li>
<span data-move>non-inert</span>
<math inert><mi data-destination></mi></math>
</li>
<li>
<span data-move>non-inert</span>
<math><mi inert data-destination></mi></math>
</li>
<li>
<svg inert><foreignObject><span>non-inert</span></foreignObject></svg>
</li>
<li>
<svg><foreignObject inert><span>non-inert</span></foreignObject></svg>
</li>
<!-- HTML elements with non-HTML ancestors are inert if they have the attribute themselves -->
<li>
<span inert data-move>inert</span>
<math><mi data-destination></mi></math>
</li>
<li>
<foo inert data-move>inert</foo>
<math><mi data-destination></mi></math>
</li>
<li>
<foo-bar inert data-move>inert</foo-bar>
<math><mi data-destination></mi></math>
</li>
<li>
<svg><foreignObject><span inert>inert</span></foreignObject></svg>
</li>
<li>
<svg><foreignObject><foo inert>inert</foo></foreignObject></svg>
</li>
<li>
<svg><foreignObject><foo-bar inert>inert</foo-bar></foreignObject></svg>
</li>
</ul>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
for (let li of document.querySelectorAll("#tests > li")) {
// The HTML parser would mess certain trees, fixup here.
const move = li.querySelector("[data-move]");
if (move) {
const destination = li.querySelector("[data-destination]");
destination.append(move);
move.removeAttribute("data-move");
destination.removeAttribute("data-destination");
}
test(() => {
assert_equals(li.childElementCount, 1);
const element = li.firstElementChild;
const selection = getSelection();
selection.selectAllChildren(element);
const selectionText = selection.toString().trim();
const textContent = element.textContent.trim();
if (textContent === "inert") {
assert_equals(selectionText, "");
} else {
assert_equals(selectionText, "non-inert");
}
}, li.innerHTML.trim());
}
</script>
|