summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/domparsing/resources
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 /testing/web-platform/tests/domparsing/resources
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 'testing/web-platform/tests/domparsing/resources')
-rw-r--r--testing/web-platform/tests/domparsing/resources/domparser-iframe-base-pushstate.html10
-rw-r--r--testing/web-platform/tests/domparsing/resources/domparser-iframe-base.html6
-rw-r--r--testing/web-platform/tests/domparsing/resources/domparser-iframe-pushstate.html9
-rw-r--r--testing/web-platform/tests/domparsing/resources/domparser-iframe.html4
-rw-r--r--testing/web-platform/tests/domparsing/resources/domparser-iframe.js4
-rw-r--r--testing/web-platform/tests/domparsing/resources/domparser-url-tests.js72
6 files changed, 105 insertions, 0 deletions
diff --git a/testing/web-platform/tests/domparsing/resources/domparser-iframe-base-pushstate.html b/testing/web-platform/tests/domparsing/resources/domparser-iframe-base-pushstate.html
new file mode 100644
index 0000000000..9c4a1bd07a
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/resources/domparser-iframe-base-pushstate.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>An iframe that does DOMParser stuff with base and pushstates itself</title>
+<base href="/fake/base-from-iframe">
+
+<script>
+"use strict";
+history.pushState(null, "", "/fake/push-state-from-iframe");
+</script>
+<script src="/domparsing/resources/domparser-iframe.js"></script>
diff --git a/testing/web-platform/tests/domparsing/resources/domparser-iframe-base.html b/testing/web-platform/tests/domparsing/resources/domparser-iframe-base.html
new file mode 100644
index 0000000000..e8a084b7dc
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/resources/domparser-iframe-base.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>An iframe that does DOMParser stuff with base</title>
+<base href="/fake/base-from-iframe">
+
+<script src="/domparsing/resources/domparser-iframe.js"></script>
diff --git a/testing/web-platform/tests/domparsing/resources/domparser-iframe-pushstate.html b/testing/web-platform/tests/domparsing/resources/domparser-iframe-pushstate.html
new file mode 100644
index 0000000000..b2821c6994
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/resources/domparser-iframe-pushstate.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>An iframe that does DOMParser stuff and pushstates itself</title>
+
+<script>
+"use strict";
+history.pushState(null, "", "/fake/push-state-from-iframe");
+</script>
+<script src="/domparsing/resources/domparser-iframe.js"></script>
diff --git a/testing/web-platform/tests/domparsing/resources/domparser-iframe.html b/testing/web-platform/tests/domparsing/resources/domparser-iframe.html
new file mode 100644
index 0000000000..710f141bb9
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/resources/domparser-iframe.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>An iframe that does DOMParser stuff</title>
+<script src="/domparsing/resources/domparser-iframe.js"></script>
diff --git a/testing/web-platform/tests/domparsing/resources/domparser-iframe.js b/testing/web-platform/tests/domparsing/resources/domparser-iframe.js
new file mode 100644
index 0000000000..a62d2f293b
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/resources/domparser-iframe.js
@@ -0,0 +1,4 @@
+window.doParse = (html, mimeType) => {
+ const parser = new DOMParser();
+ return parser.parseFromString(html, mimeType);
+};
diff --git a/testing/web-platform/tests/domparsing/resources/domparser-url-tests.js b/testing/web-platform/tests/domparsing/resources/domparser-url-tests.js
new file mode 100644
index 0000000000..7b02fab1c3
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/resources/domparser-url-tests.js
@@ -0,0 +1,72 @@
+const loadPromise = new Promise(resolve => { window.resolveLoadPromise = resolve; });
+
+function assertURL(doc, expectedURL) {
+ assert_equals(doc.URL, expectedURL, "document.URL");
+ assert_equals(doc.documentURI, expectedURL, "document.documentURI");
+ assert_equals(doc.baseURI, expectedURL, "document.baseURI");
+}
+
+const supportedTypes = [
+ "text/html",
+ "text/xml",
+ "application/xml",
+ "application/xhtml+xml",
+ "image/svg+xml",
+];
+
+const invalidXML = `<span x:test="testing">1</span>`;
+const inputs = {
+ valid: "<html></html>",
+ "invalid XML": invalidXML
+};
+
+for (const mimeType of supportedTypes) {
+ for (const [inputName, input] of Object.entries(inputs)) {
+ if (mimeType === "text/html" && input === invalidXML) {
+ continue;
+ }
+
+ test(() => {
+ const parser = new DOMParser();
+ const doc = parser.parseFromString(input, mimeType);
+
+ assertURL(doc, document.URL);
+ }, `${mimeType} ${inputName}: created normally`);
+
+ promise_test(async () => {
+ await loadPromise;
+
+ const parser = new frames[0].DOMParser();
+ const doc = parser.parseFromString(input, mimeType);
+
+ assertURL(doc, frames[0].document.URL);
+ }, `${mimeType} ${inputName}: created using another iframe's DOMParser from this frame`);
+
+ promise_test(async () => {
+ await loadPromise;
+
+ const parser = new frames[0].DOMParser();
+ const doc = frames[0].doParse(input, mimeType);
+
+ assertURL(doc, frames[0].document.URL);
+ }, `${mimeType} ${inputName}: created using another iframe's DOMParser from that frame`);
+
+ promise_test(async () => {
+ await loadPromise;
+
+ const parser = new DOMParser();
+ const doc = frames[0].DOMParser.prototype.parseFromString.call(parser, input, mimeType);
+
+ assertURL(doc, document.URL);
+ }, `${mimeType} ${inputName}: created using a parser from this frame and the method from the iframe`);
+
+ promise_test(async () => {
+ await loadPromise;
+
+ const parser = new frames[0].DOMParser();
+ const doc = DOMParser.prototype.parseFromString.call(parser, input, mimeType);
+
+ assertURL(doc, frames[0].document.URL);
+ }, `${mimeType} ${inputName}: created using a parser from the iframe and the method from this frame`);
+ }
+}