summaryrefslogtreecommitdiffstats
path: root/dom/xslt/tests/browser
diff options
context:
space:
mode:
Diffstat (limited to 'dom/xslt/tests/browser')
-rw-r--r--dom/xslt/tests/browser/browser.ini10
-rw-r--r--dom/xslt/tests/browser/browser_bug1309630.js74
-rw-r--r--dom/xslt/tests/browser/bug1309630.sjs54
-rw-r--r--dom/xslt/tests/browser/file_bug1309630.html19
4 files changed, 157 insertions, 0 deletions
diff --git a/dom/xslt/tests/browser/browser.ini b/dom/xslt/tests/browser/browser.ini
new file mode 100644
index 0000000000..c9111df370
--- /dev/null
+++ b/dom/xslt/tests/browser/browser.ini
@@ -0,0 +1,10 @@
+[DEFAULT]
+
+[browser_bug1309630.js]
+skip-if =
+ !fission && os == "linux" && bits == 64 # Bug 1763179
+ os == "linux" && !debug # Bug 1776052
+ os == "win" && !debug # Bug 1776052
+support-files =
+ bug1309630.sjs
+ file_bug1309630.html
diff --git a/dom/xslt/tests/browser/browser_bug1309630.js b/dom/xslt/tests/browser/browser_bug1309630.js
new file mode 100644
index 0000000000..f475fc2585
--- /dev/null
+++ b/dom/xslt/tests/browser/browser_bug1309630.js
@@ -0,0 +1,74 @@
+"use strict";
+
+const BASE = "https://example.com/browser/dom/xslt/tests/browser";
+const SERVER_SCRIPT = `${BASE}/bug1309630.sjs`;
+
+function resetCounter() {
+ return fetch(`${SERVER_SCRIPT}?reset_counter`);
+}
+function recordCounter() {
+ return fetch(`${SERVER_SCRIPT}?record_counter`);
+}
+// Returns a promise that resolves to true if the counter in
+// bug1309630.sjs changed by more than 'value' since last calling
+// recordCounter(), or false if it doesn't and we time out.
+function waitForCounterChangeAbove(value) {
+ return TestUtils.waitForCondition(() =>
+ fetch(`${SERVER_SCRIPT}?get_counter_change`).then(response =>
+ response.ok
+ ? response.text().then(str => Number(str) > value)
+ : Promise.reject()
+ )
+ ).then(
+ () => true,
+ () => false
+ );
+}
+
+add_task(async function test_eternal_xslt() {
+ await resetCounter();
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url: SERVER_SCRIPT, waitForLoad: false },
+ async function(browser) {
+ info("Waiting for XSLT to keep loading");
+
+ ok(
+ await waitForCounterChangeAbove(1),
+ "We should receive at least a request from the document function call."
+ );
+
+ info("Navigating to about:blank");
+ BrowserTestUtils.loadURI(browser, "about:blank");
+ await BrowserTestUtils.browserLoaded(browser);
+
+ info("Check to see if XSLT stops loading");
+ await recordCounter();
+ ok(
+ !(await waitForCounterChangeAbove(0)),
+ "We shouldn't receive more requests to the XSLT file within the timeout period."
+ );
+ }
+ );
+
+ await resetCounter();
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url: `${BASE}/file_bug1309630.html` },
+ async function(browser) {
+ ok(
+ await waitForCounterChangeAbove(1),
+ "We should receive at least a request from the document function call."
+ );
+
+ info("Navigating to about:blank");
+ BrowserTestUtils.loadURI(browser, "about:blank");
+ await BrowserTestUtils.browserLoaded(browser);
+
+ info("Check to see if XSLT stops loading");
+ await recordCounter();
+ ok(
+ !(await waitForCounterChangeAbove(0)),
+ "We shouldn't receive more requests to the XSLT file within the timeout period."
+ );
+ }
+ );
+});
diff --git a/dom/xslt/tests/browser/bug1309630.sjs b/dom/xslt/tests/browser/bug1309630.sjs
new file mode 100644
index 0000000000..9a3f464139
--- /dev/null
+++ b/dom/xslt/tests/browser/bug1309630.sjs
@@ -0,0 +1,54 @@
+function handleRequest(request, response) {
+ const XSLT = `<?xml version="1.0"?>
+ <?xml-stylesheet type="text/xsl" href="#bug"?>
+ <xsl:stylesheet id="bug" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template name="f" match="/">
+ <xsl:param name="n" select="0" />
+ <xsl:apply-templates select="document(concat('${request.path}?', $n))/xsl:stylesheet/xsl:template[@name='f']">
+ <xsl:with-param name="n" select="$n + 1"/>
+ </xsl:apply-templates>
+ <xsl:call-template name="f">
+ <xsl:with-param name="n" select="$n + 1"/>
+ </xsl:call-template>
+ </xsl:template>
+ </xsl:stylesheet>`;
+
+ // reset_counter sets the counter to -1.
+ if (request.queryString === "reset_counter") {
+ setState("base", "-1");
+ response.write("");
+ return;
+ }
+
+ // record_counter makes us store the current value of the counter.
+ if (request.queryString === "record_counter") {
+ setState("base", getState("counter"));
+ response.write("");
+ return;
+ }
+
+ // get_counter_change returns the difference between the current
+ // value of the counter and the value it had when the script was
+ // loaded with the record_counter query string.
+ if (request.queryString === "get_counter_change") {
+ response.write(
+ String(Number(getState("counter")) - Number(getState("base")))
+ );
+ return;
+ }
+
+ // The XSLT code calls the document() function with a URL pointing to
+ // this script, with the query string set to a counter starting from 0
+ // and incremementing with every call of the document() function.
+ // The first load will happen either from the xml-stylesheet PI, or
+ // with fetch(), to parse a document to pass to
+ // XSLTProcessor.importStylesheet. In that case the query string will
+ // be empty, and we don't change the counter value, we only care about
+ // the loads through the document() function.
+ if (request.queryString) {
+ setState("counter", request.queryString);
+ }
+
+ response.setHeader("Content-Type", "text/xml; charset=utf-8", false);
+ response.write(XSLT);
+}
diff --git a/dom/xslt/tests/browser/file_bug1309630.html b/dom/xslt/tests/browser/file_bug1309630.html
new file mode 100644
index 0000000000..c22889358c
--- /dev/null
+++ b/dom/xslt/tests/browser/file_bug1309630.html
@@ -0,0 +1,19 @@
+<script>
+ let styleDoc = fetch("bug1309630.sjs")
+ .then(response => {
+ if (response.ok) {
+ return response.text();
+ }
+ return Promise.reject();
+ }).then(xslt => {
+ let styleDoc = new DOMParser().parseFromString(xslt, "text/xml");
+ let originalDoc = new DOMParser().parseFromString(
+ "<root/>",
+ "text/xml"
+ );
+
+ let processor = new XSLTProcessor();
+ processor.importStylesheet(styleDoc);
+ processor.transformToDocument(originalDoc);
+ });
+</script>>