summaryrefslogtreecommitdiffstats
path: root/dom/prototype/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/prototype/tests
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/prototype/tests')
-rw-r--r--dom/prototype/tests/chrome/chrome.ini7
-rw-r--r--dom/prototype/tests/chrome/form.xhtml8
-rw-r--r--dom/prototype/tests/chrome/no_whitespace.xhtml3
-rw-r--r--dom/prototype/tests/chrome/test_prototype_document.xhtml73
-rw-r--r--dom/prototype/tests/chrome/whitespace.xhtml8
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>