Bug 1226293. Followup: add SVG tests. r=bz

This commit is contained in:
Robert O'Callahan 2015-11-23 18:09:39 +13:00
parent 8b764d54fa
commit b62f07f5e0
3 changed files with 18 additions and 3 deletions

View File

@ -3334,8 +3334,7 @@ nsGenericHTMLElement::GetInnerText(mozilla::dom::DOMString& aValue,
{
if (!GetPrimaryFrame(Flush_Layout)) {
nsIPresShell* presShell = nsComputedDOMStyle::GetPresShellForContent(this);
if (!presShell || !IsInComposedDoc() ||
IsOrHasAncestorWithDisplayNone(this, presShell)) {
if (!presShell || IsOrHasAncestorWithDisplayNone(this, presShell)) {
GetTextContentInternal(aValue, aError);
return;
}

View File

@ -73,6 +73,9 @@ testText("<div style='display:none'>abc def", "abc def", "No whitespace compre
testText("<div style='display:none'> abc def ", " abc def ", "No removal of leading/trailing whitespace in display:none container");
testText("<div>123<span style='display:none'>abc", "123", "display:none child not rendered");
testText("<div style='display:none'><span id='target'>abc", "abc", "display:none container with non-display-none target child");
testTextInSVG("<div id='target'>abc", "", "non-display-none child of svg");
testTextInSVG("<div style='display:none' id='target'>abc", "abc", "display:none child of svg");
testTextInSVG("<div style='display:none'><div id='target'>abc", "abc", "child of display:none child of svg");
/**** display:contents ****/

View File

@ -13,13 +13,25 @@
.first-letter-float::first-letter { float:left; }
</style>
<div id="container"></div>
<svg id="svgContainer"></svg>
<script>
function testText(html, expectedPlain, msg) {
textTextInContainer(container, html, expectedPlain, msg);
}
function testTextInSVG(html, expectedPlain, msg) {
textTextInContainer(svgContainer, html, expectedPlain, msg);
}
function textTextInContainer(cont, html, expectedPlain, msg) {
test(function() {
container.innerHTML = html;
if (cont != container) {
while (container.firstChild) {
cont.appendChild(container.firstChild);
}
}
var e = document.getElementById('target');
if (!e) {
e = container.firstChild;
e = cont.firstChild;
}
var pokes = document.getElementsByClassName('poke');
for (var i = 0; i < pokes.length; ++i) {
@ -40,6 +52,7 @@ function testText(html, expectedPlain, msg) {
e = e.nextSibling;
}
assert_equals(e.innerText, expectedPlain);
cont.textContent = '';
}, msg);
}
</script>