diff options
Diffstat (limited to 'dom/prototype/tests/chrome')
-rw-r--r-- | dom/prototype/tests/chrome/chrome.ini | 7 | ||||
-rw-r--r-- | dom/prototype/tests/chrome/form.xhtml | 8 | ||||
-rw-r--r-- | dom/prototype/tests/chrome/no_whitespace.xhtml | 3 | ||||
-rw-r--r-- | dom/prototype/tests/chrome/test_prototype_document.xhtml | 73 | ||||
-rw-r--r-- | dom/prototype/tests/chrome/whitespace.xhtml | 8 |
5 files changed, 99 insertions, 0 deletions
diff --git a/dom/prototype/tests/chrome/chrome.ini b/dom/prototype/tests/chrome/chrome.ini new file mode 100644 index 0000000000..8de4e4bfb5 --- /dev/null +++ b/dom/prototype/tests/chrome/chrome.ini @@ -0,0 +1,7 @@ +[DEFAULT] +support-files = + whitespace.xhtml + no_whitespace.xhtml + form.xhtml + +[test_prototype_document.xhtml] diff --git a/dom/prototype/tests/chrome/form.xhtml b/dom/prototype/tests/chrome/form.xhtml new file mode 100644 index 0000000000..0659215e6e --- /dev/null +++ b/dom/prototype/tests/chrome/form.xhtml @@ -0,0 +1,8 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml"> + <body> + <input type="text" id="input" value=""/> + </body> +</html> diff --git a/dom/prototype/tests/chrome/no_whitespace.xhtml b/dom/prototype/tests/chrome/no_whitespace.xhtml new file mode 100644 index 0000000000..78a8c34cff --- /dev/null +++ b/dom/prototype/tests/chrome/no_whitespace.xhtml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/strict.dtd"> +<html xmlns="http://www.w3.org/TR/xhtml1/strict"><body>Hello<p>there!</p></body></html> diff --git a/dom/prototype/tests/chrome/test_prototype_document.xhtml b/dom/prototype/tests/chrome/test_prototype_document.xhtml new file mode 100644 index 0000000000..47dff2d565 --- /dev/null +++ b/dom/prototype/tests/chrome/test_prototype_document.xhtml @@ -0,0 +1,73 @@ +<?xml version="1.0"?> +<?xml-stylesheet type="text/css" href="chrome://global/skin"?> +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> +<window title="Test prototype document" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + <script type="application/javascript" + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <script><![CDATA[ + SimpleTest.waitForExplicitFinish(); + ]]></script> + <browser type="chrome" id="browser" flex="1"/> + <body xmlns="http://www.w3.org/1999/xhtml"> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +</pre> + + +<script><![CDATA[ + +async function load(frame, url) { + return new Promise((resolve) => { + frame.addEventListener("load", () => { + resolve(); + }, {once: true}); + + if (frame.src === url) { + frame.reload(); + } else { + frame.src = url; + } + }); +} + +// Load a file with and without the prototype document cache enabled. +async function compare(filename) { + let browser = document.getElementById("browser"); + // Load the page with no prototype document cache (the regular loading flow of + // an XHTML page). + await SpecialPowers.pushPrefEnv({ set: [["dom.prototype_document_cache.enabled", false]] }); + await load(browser, filename); + ok(!browser.contentDocument.loadedFromPrototype, `${filename} should not use prototype.`); + const contentWithoutPrototype = browser.contentDocument.documentElement.outerHTML; + + // Load the page with the prototype document cache enabled. The prototype should + // be built from the source file. + await SpecialPowers.pushPrefEnv({ set: [["dom.prototype_document_cache.enabled", true]] }); + await load(browser, filename); + ok(browser.contentDocument.loadedFromPrototype, `${filename} should load from prototype.`); + const contentWithPrototype = browser.contentDocument.documentElement.outerHTML; + is(contentWithPrototype, contentWithoutPrototype, `${filename} document contents should be the same.`); +} + +add_task(async function test_prototype_document() { + await compare("no_whitespace.xhtml"); + await compare("whitespace.xhtml"); + // TODO: Test whitespace within XUL elements, since it is handled differently + // with and without the prototype sink (bug 1544567). +}); + +add_task(async function test_prototype_document_form() { + let browser = document.getElementById("browser"); + await load(browser, "form.xhtml"); + ok(browser.contentDocument.loadedFromPrototype, `form.xhtml should load from prototype.`); + browser.contentDocument.getElementById("input").value = "test"; + await load(browser, "form.xhtml"); + is(browser.contentDocument.getElementById("input").value, "test", "input value should persist after reload"); +}); +]]></script> +</body> +</window> diff --git a/dom/prototype/tests/chrome/whitespace.xhtml b/dom/prototype/tests/chrome/whitespace.xhtml new file mode 100644 index 0000000000..0f121973c7 --- /dev/null +++ b/dom/prototype/tests/chrome/whitespace.xhtml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/strict.dtd"> +<html xmlns="http://www.w3.org/TR/xhtml1/strict"> + <body> + Hello + <p>there!</p> + </body> +</html> |