Bug 1539759 - Improve DTD entity handling. Testcase. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D33778
This commit is contained in:
Peter Van der Beken 2022-02-14 17:14:32 +00:00
Родитель af133eccab
Коммит 4fc8956e2c
4 изменённых файлов: 48 добавлений и 0 удалений

Просмотреть файл

@ -10,3 +10,8 @@ support-files =
[browser_ysod_telemetry.js]
support-files =
broken_xml.xhtml
[browser_elementindtd.js]
support-files =
browser_elementindtd.xml
browser_elementindtd.dtd

Просмотреть файл

@ -0,0 +1,2 @@
<!ENTITY entitywithelement
'<p id="fromdtd">From dtd</p>'>

Просмотреть файл

@ -0,0 +1,31 @@
/* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/*
* Test for bug 1539759
* Loads a chrome XML document that has an exteernal DTD file with an entity
* that contains an element, and verifies that that element was not inserted
* into the document (but its content was).
*/
add_task(async function test() {
await BrowserTestUtils.withNewTab(
getRootDirectory(gTestPath) + "browser_elementindtd.xml",
async function(newBrowser) {
// NB: We load the chrome:// page in the parent process.
testNoElementFromEntity(newBrowser);
}
);
});
function testNoElementFromEntity(newBrowser) {
let doc = newBrowser.contentDocument;
is(doc.body.textContent, "From dtd", "Should load DTD.");
is(
doc.body.firstElementChild,
null,
"Shouldn't have an element inserted from the DTD"
);
}

Просмотреть файл

@ -0,0 +1,10 @@
<!DOCTYPE html
[
<!ENTITY % externaldtd SYSTEM "chrome://mochitests/content/browser/parser/htmlparser/tests/mochitest/browser_elementindtd.dtd" >
%externaldtd;
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
&entitywithelement;
</body>
</html>