summaryrefslogtreecommitdiffstats
path: root/dom/xslt/tests
diff options
context:
space:
mode:
Diffstat (limited to 'dom/xslt/tests')
-rw-r--r--dom/xslt/tests/XSLTMark/XSLTMark-static.js46
-rw-r--r--dom/xslt/tests/XSLTMark/XSLTMark-test.js41
-rw-r--r--dom/xslt/tests/XSLTMark/XSLTMark-view.js171
-rw-r--r--dom/xslt/tests/XSLTMark/XSLTMark.css8
-rw-r--r--dom/xslt/tests/XSLTMark/XSLTMark.xhtml53
-rw-r--r--dom/xslt/tests/mochitest/file_bug1135764.xml3
-rw-r--r--dom/xslt/tests/mochitest/file_bug1135764.xsl19
-rw-r--r--dom/xslt/tests/mochitest/mochitest.ini22
-rw-r--r--dom/xslt/tests/mochitest/test_bug1072116.html37
-rw-r--r--dom/xslt/tests/mochitest/test_bug1135764.html58
-rw-r--r--dom/xslt/tests/mochitest/test_bug1436040.html54
-rw-r--r--dom/xslt/tests/mochitest/test_bug1527308.html38
-rw-r--r--dom/xslt/tests/mochitest/test_bug319374.html101
-rw-r--r--dom/xslt/tests/mochitest/test_bug427060.html49
-rw-r--r--dom/xslt/tests/mochitest/test_bug440974.html46
-rw-r--r--dom/xslt/tests/mochitest/test_bug453441.html57
-rw-r--r--dom/xslt/tests/mochitest/test_bug468208.html35
-rw-r--r--dom/xslt/tests/mochitest/test_bug511487.html59
-rw-r--r--dom/xslt/tests/mochitest/test_bug551412.html48
-rw-r--r--dom/xslt/tests/mochitest/test_bug551654.html49
-rw-r--r--dom/xslt/tests/mochitest/test_bug566629.html70
-rw-r--r--dom/xslt/tests/mochitest/test_bug566629.xhtml73
-rw-r--r--dom/xslt/tests/mochitest/test_bug603159.html54
-rw-r--r--dom/xslt/tests/mochitest/test_bug616774.html28
-rw-r--r--dom/xslt/tests/mochitest/test_bug667315.html46
-rw-r--r--dom/xslt/tests/mochitest/test_exslt.html249
-rw-r--r--dom/xslt/tests/mochitest/test_parameter.html31
27 files changed, 1545 insertions, 0 deletions
diff --git a/dom/xslt/tests/XSLTMark/XSLTMark-static.js b/dom/xslt/tests/XSLTMark/XSLTMark-static.js
new file mode 100644
index 0000000000..fcca33e72b
--- /dev/null
+++ b/dom/xslt/tests/XSLTMark/XSLTMark-static.js
@@ -0,0 +1,46 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+const enablePrivilege = netscape.security.PrivilegeManager.enablePrivilege;
+const IOSERVICE_CTRID = "@mozilla.org/network/io-service;1";
+const nsIIOService = Ci.nsIIOService;
+const SIS_CTRID = "@mozilla.org/scriptableinputstream;1";
+const nsISIS = Ci.nsIScriptableInputStream;
+const nsIFilePicker = Ci.nsIFilePicker;
+const STDURLMUT_CTRID = "@mozilla.org/network/standard-url-mutator;1";
+const nsIURIMutator = Ci.nsIURIMutator;
+
+const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
+
+var gStop = false;
+
+function loadFile(aUriSpec) {
+ enablePrivilege("UniversalXPConnect");
+ var serv = Cc[IOSERVICE_CTRID].getService(nsIIOService);
+ if (!serv) {
+ throw Components.Exception("", Cr.ERR_FAILURE);
+ }
+ var chan = NetUtil.newChannel({
+ uri: aUriSpec,
+ loadUsingSystemPrincipal: true,
+ });
+ var instream = Cc[SIS_CTRID].createInstance(nsISIS);
+ instream.init(chan.open());
+
+ return instream.read(instream.available());
+}
+
+function dump20(aVal) {
+ const pads = " ";
+ if (typeof aVal == "string") {
+ out = aVal;
+ } else if (typeof aVal == "number") {
+ out = Number(aVal).toFixed(2);
+ } else {
+ out = new String(aVal);
+ }
+ dump(pads.substring(0, 20 - out.length));
+ dump(out);
+}
diff --git a/dom/xslt/tests/XSLTMark/XSLTMark-test.js b/dom/xslt/tests/XSLTMark/XSLTMark-test.js
new file mode 100644
index 0000000000..d88a44649a
--- /dev/null
+++ b/dom/xslt/tests/XSLTMark/XSLTMark-test.js
@@ -0,0 +1,41 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var gParser = new DOMParser();
+var gTimeout;
+
+function Test(aTitle, aSourceURL, aStyleURL, aNumber, aObserver) {
+ this.mTitle = aTitle;
+ this.mObserver = aObserver;
+ this.mTotal = aNumber;
+ this.mDone = 0;
+ var xmlcontent = loadFile(aSourceURL);
+ var xslcontent = loadFile(aStyleURL);
+ this.mSource = gParser.parseFromString(xmlcontent, "application/xml");
+ this.mStyle = gParser.parseFromString(xslcontent, "application/xml");
+}
+
+function runTest(aTitle, aSourceURL, aStyleURL, aNumber, aObserver) {
+ test = new Test(aTitle, aSourceURL, aStyleURL, aNumber, aObserver);
+ gTimeout = setTimeout(onNextTransform, 100, test, 0);
+}
+
+function onNextTransform(aTest, aNumber) {
+ var proc = new XSLTProcessor();
+ var startTime = Date.now();
+ proc.importStylesheet(aTest.mStyle);
+ var res = proc.transformToDocument(aTest.mSource);
+ var endTime = Date.now();
+ aNumber++;
+ var progress = (aNumber / aTest.mTotal) * 100;
+ if (aTest.mObserver) {
+ aTest.mObserver.progress(aTest.mTitle, endTime - startTime, progress);
+ }
+ if (aNumber < aTest.mTotal) {
+ gTimeout = setTimeout(onNextTransform, 100, aTest, aNumber);
+ } else if (aTest.mObserver) {
+ aTest.mObserver.done(aTest.mTitle);
+ }
+}
diff --git a/dom/xslt/tests/XSLTMark/XSLTMark-view.js b/dom/xslt/tests/XSLTMark/XSLTMark-view.js
new file mode 100644
index 0000000000..9436b602a7
--- /dev/null
+++ b/dom/xslt/tests/XSLTMark/XSLTMark-view.js
@@ -0,0 +1,171 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var view = {
+ configUrl: null,
+ testArray: null,
+ mCurrent: null,
+
+ browseForConfig() {
+ enablePrivilege("UniversalXPConnect");
+ var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
+ fp.init(window, "XSLTMark Description File", nsIFilePicker.modeOpen);
+ fp.appendFilter("*.conf", "*.conf");
+ fp.appendFilters(nsIFilePicker.filterAll);
+ var res = fp.show();
+
+ if (res == nsIFilePicker.returnOK) {
+ this.configUrl = Cc[STDURLMUT_CTRID].createInstance(nsIURIMutator)
+ .setSpec(fp.fileURL.spec)
+ .finalize();
+ document
+ .getElementById("config")
+ .setAttribute("value", this.configUrl.spec);
+ }
+ this.parseConfig();
+ return true;
+ },
+
+ parseConfig() {
+ this.testArray = new Array();
+ var test;
+ if (!this.configUrl) {
+ return;
+ }
+
+ var content = loadFile(this.configUrl.spec);
+
+ var lines = content.split("\n");
+ var line, res;
+ var head = /^\[(.+)\]$/;
+ var instruct = /^(.+)=(.+)$/;
+ while (lines.length) {
+ line = lines.shift();
+ if (head.test(line)) {
+ test = new Object();
+ res = head.exec(line);
+ test.title = res[1];
+ this.testArray.push(test);
+ } else if (line == "") {
+ test = undefined;
+ } else {
+ res = instruct.exec(line);
+ test[res[1]] = res[2];
+ }
+ }
+ },
+
+ onLoad() {
+ this.mCurrentStatus = document.getElementById("currentStatus");
+ this.mCurrentProgress = document.getElementById("currentProgress");
+ this.mTotalProgress = document.getElementById("totalProgress");
+ this.mOutput = document.getElementById("transformOutput");
+ this.mDetailOutput = document.getElementById("transformDetailedOutput");
+ this.mDetail = true;
+ },
+
+ progress(aTitle, aTime, aProgress) {
+ // dump20(aTitle);
+ // dump20(aTime);
+ // dump20(aProgress);
+ this.mCurrentProgress.value = aProgress;
+ this.displayDetailTime(aTime);
+ this.mTimes.push(aTime);
+ // dump("\n");
+ },
+
+ done(aTitle) {
+ // dump(aTitle + " is finished.\n");
+ this.mCurrent++;
+ this.mCurrentProgress.value = 0;
+ this.displayTotalTime();
+ if (this.mCurrent >= this.testArray.length) {
+ this.mTotalProgress.value = 0;
+ this.mCurrentStatus.value = "done";
+ return;
+ }
+ this.mTotalProgress.value = (this.mCurrent * 100) / this.testArray.length;
+ var test = this.testArray[this.mCurrent];
+ enablePrivilege("UniversalXPConnect");
+ this.displayTest(test.title);
+ runTest(
+ test.title,
+ this.configUrl.resolve(test.input),
+ this.configUrl.resolve(test.stylesheet),
+ test.iterations,
+ this
+ );
+ },
+
+ onStop() {
+ clearTimeout(gTimeout);
+ this.mCurrentProgress.value = 0;
+ this.mTotalProgress.value = 0;
+ this.mCurrentStatus.value = "stopped";
+ },
+
+ displayTest(aTitle) {
+ this.mTimes = new Array();
+ aTitle += "\t";
+ this.mCurrentStatus.value = aTitle;
+ this.mOutput.value += aTitle;
+ if (this.mDetail) {
+ this.mDetailOutput.value += aTitle;
+ }
+ },
+
+ displayDetailTime(aTime) {
+ if (this.mDetail) {
+ this.mDetailOutput.value += aTime + " ms\t";
+ }
+ },
+
+ displayTotalTime() {
+ var sum = 0;
+ for (k = 0; k < this.mTimes.length; k++) {
+ sum += this.mTimes[k];
+ }
+ var mean = sum / this.mTimes.length;
+ this.mOutput.value += Number(mean).toFixed(2) + " ms\t" + sum + " ms\t";
+ var variance = 0;
+ for (k = 0; k < this.mTimes.length; k++) {
+ var n = this.mTimes[k] - mean;
+ variance += n * n;
+ }
+ variance = Math.sqrt(variance / this.mTimes.length);
+ this.mOutput.value += Number(variance).toFixed(2) + "\n";
+ if (this.mDetail) {
+ this.mDetailOutput.value += "\n";
+ }
+ },
+
+ runBenchmark() {
+ enablePrivilege("UniversalXPConnect");
+ if (!this.testArray) {
+ if (!this.configUrl) {
+ this.configUrl = Cc[STDURLMUT_CTRID].createInstance(nsIURIMutator)
+ .setSpec(document.getElementById("config").value)
+ .finalize();
+ }
+ this.parseConfig();
+ }
+
+ this.mCurrent = 0;
+ var test = this.testArray[this.mCurrent];
+ this.mOutput.value = "";
+ if (this.mDetail) {
+ this.mDetailOutput.value = "";
+ }
+ this.displayTest(test.title);
+ runTest(
+ test.title,
+ this.configUrl.resolve(test.input),
+ this.configUrl.resolve(test.stylesheet),
+ test.iterations,
+ this
+ );
+ return true;
+ },
+};
diff --git a/dom/xslt/tests/XSLTMark/XSLTMark.css b/dom/xslt/tests/XSLTMark/XSLTMark.css
new file mode 100644
index 0000000000..80386ae2da
--- /dev/null
+++ b/dom/xslt/tests/XSLTMark/XSLTMark.css
@@ -0,0 +1,8 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+textbox.out {
+ white-space: pre;
+}
diff --git a/dom/xslt/tests/XSLTMark/XSLTMark.xhtml b/dom/xslt/tests/XSLTMark/XSLTMark.xhtml
new file mode 100644
index 0000000000..1527044606
--- /dev/null
+++ b/dom/xslt/tests/XSLTMark/XSLTMark.xhtml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?><!-- -*- Mode: xml; tab-width: 2; indent-tabs-mode: nil -*- -->
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="XSLTMark.css" type="text/css"?>
+<window id="XSLTMarkHarness"
+ title="XSLTMark"
+ onload="view.onLoad()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ orient="vertical">
+<script type="application/x-javascript" src="XSLTMark-static.js" />
+<script type="application/x-javascript" src="XSLTMark-test.js" />
+<script type="application/x-javascript" src="XSLTMark-view.js" />
+
+<hbox>
+ <groupbox orient="horizontal">
+ <caption label="test description file" />
+ <label value=""/><!-- needed, otherwise groupbox is broken :-( -->
+ <input xmlns="http://www.w3.org/1999/xhtml" id="config" persist="value" readonly="true"/>
+ <button label="browse..." oncommand="view.browseForConfig();" />
+ </groupbox>
+ <groupbox orient="horizontal">
+ <caption label="test control" />
+ <button label="run..."
+ oncommand="setTimeout('view.runBenchmark();', 0);" />
+ <button label="stop" oncommand="view.onStop();" />
+ </groupbox>
+ <groupbox orient="horizontal">
+ <caption label="options" />
+ <label value="responsiveness: "/>
+ <menulist label="sloppy">
+ <menupopup>
+ <menuitem label="sloppy" selected="true"/>
+ <menuitem label="bad"/>
+ </menupopup>
+ </menulist>
+ </groupbox>
+</hbox>
+<hbox>
+ <input xmlns="http://www.w3.org/1999/xhtml" id="currentStatus" readonly="true" flex="1"/>
+ <progressmeter id="currentProgress" mode="normal" value="0" flex="2"/>
+ <progressmeter id="totalProgress" mode="normal" value="0" flex="2"/>
+</hbox>
+<hbox flex="1">
+ <html:textarea id="transformOutput" class="out" readonly="readonly" flex="1"/>
+</hbox>
+<hbox flex="1">
+ <html:textarea id="transformDetailedOutput" class="out" readonly="readonly" flex="1"/>
+</hbox>
+</window>
diff --git a/dom/xslt/tests/mochitest/file_bug1135764.xml b/dom/xslt/tests/mochitest/file_bug1135764.xml
new file mode 100644
index 0000000000..b9da87e5e5
--- /dev/null
+++ b/dom/xslt/tests/mochitest/file_bug1135764.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="file_bug1135764.xsl"?>
+<root/>
diff --git a/dom/xslt/tests/mochitest/file_bug1135764.xsl b/dom/xslt/tests/mochitest/file_bug1135764.xsl
new file mode 100644
index 0000000000..e739086cbe
--- /dev/null
+++ b/dom/xslt/tests/mochitest/file_bug1135764.xsl
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="html"
+ indent="yes"
+ version="5.0"
+ doctype-system="about:legacy-compat"/>
+
+<xsl:template match="/">
+<html>
+<head>
+</head>
+ <body>
+ Some text
+ </body>
+</html>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/dom/xslt/tests/mochitest/mochitest.ini b/dom/xslt/tests/mochitest/mochitest.ini
new file mode 100644
index 0000000000..38e321db05
--- /dev/null
+++ b/dom/xslt/tests/mochitest/mochitest.ini
@@ -0,0 +1,22 @@
+[DEFAULT]
+
+[test_bug1072116.html]
+[test_bug319374.html]
+[test_bug427060.html]
+[test_bug440974.html]
+[test_bug453441.html]
+[test_bug468208.html]
+[test_bug511487.html]
+[test_bug551412.html]
+[test_bug551654.html]
+[test_bug566629.html]
+[test_bug566629.xhtml]
+[test_bug603159.html]
+[test_bug616774.html]
+[test_bug667315.html]
+[test_bug1135764.html]
+support-files = file_bug1135764.xml file_bug1135764.xsl
+[test_bug1436040.html]
+[test_bug1527308.html]
+[test_exslt.html]
+[test_parameter.html]
diff --git a/dom/xslt/tests/mochitest/test_bug1072116.html b/dom/xslt/tests/mochitest/test_bug1072116.html
new file mode 100644
index 0000000000..ec05d23da2
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug1072116.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1072116
+-->
+<head>
+ <title>Test for Bug 1072116</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1072116">Mozilla Bug 1072116</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 1072116 **/
+var attr = document.createAttribute("c");
+
+var xpathExpr = document.createExpression('a', null);
+
+var status = false;
+try {
+ xpathExpr.evaluate(attr, null, null, null, null);
+} catch(e) {
+ status = true;
+}
+
+ok(status, "Still alive \\o/");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug1135764.html b/dom/xslt/tests/mochitest/test_bug1135764.html
new file mode 100644
index 0000000000..a368b9b4ab
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug1135764.html
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1135764
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1135764</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 1135764 **/
+ SimpleTest.waitForExplicitFinish();
+ var counter = 0;
+ var startTimelineValue;
+
+ function waitATick() {
+ ++counter;
+ if (counter == 1) {
+ frames[0].requestAnimationFrame(waitATick);
+ return;
+ }
+ ok(frames[0].document.timeline.currentTime !== startTimelineValue,
+ "The timeline in an XSLT-transformed document should still advance");
+ SimpleTest.finish();
+ }
+ addLoadEvent(function() {
+ SpecialPowers.pushPrefEnv(
+ {
+ set: [
+ ["dom.animations-api.timelines.enabled", true],
+ ],
+ },
+ function() {
+ var ifr = document.querySelector("iframe");
+ ifr.onload = function() {
+ startTimelineValue = frames[0].document.timeline.currentTime;
+ frames[0].requestAnimationFrame(waitATick);
+ };
+ ifr.src = "file_bug1135764.xml";
+ }
+ );
+ });
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1135764">Mozilla Bug 1135764</a>
+<p id="display">
+ <iframe></iframe>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug1436040.html b/dom/xslt/tests/mochitest/test_bug1436040.html
new file mode 100644
index 0000000000..df17e75779
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug1436040.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for xslt-param PIs</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ let iframe = document.createElement('iframe');
+ let src = `<?xml version="1.0"?>
+ <?xslt-param name="param" value="true"?>
+ <?xml-stylesheet type="text/xml" href="#bug"?>
+ <doc>
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" id="bug">
+ <xsl:output method="html"/>
+ <xsl:param name="param">false</xsl:param>
+ <xsl:template match="/">
+ <xsl:element name="script">parent.postMessage({test: 1, result: <xsl:value-of select="$param"/>}, "*");</xsl:element>
+ </xsl:template>
+ </xsl:stylesheet>
+ </doc>`;
+ iframe.src = "data:text/xml," + encodeURIComponent(src);
+ self.addEventListener("message", t.step_func_done(({data: {test, result}}) => {
+ if (test == 1) {
+ assert_true(result, "The stylesheet param's value should be set by the xslt-param PI.");
+ }
+ }));
+ document.body.appendChild(iframe);
+}, "Test for xslt-param PIs");
+async_test(t => {
+ let iframe = document.createElement('iframe');
+ let src = `<?xml version="1.0"?>
+ <?xslt-param-namespace prefix="foo" namespace="foonamespace"?>
+ <?xslt-param name="param" select="//foo:default"?>
+ <?xml-stylesheet type="text/xml" href="#bug"?>
+ <doc>
+ <default xmlns="foonamespace">true</default>
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" id="bug">
+ <xsl:output method="html"/>
+ <xsl:param name="param">false</xsl:param>
+ <xsl:template match="/">
+ <xsl:element name="script">parent.postMessage({test: 2, result: <xsl:value-of select="$param"/>}, "*");</xsl:element>
+ </xsl:template>
+ </xsl:stylesheet>
+ </doc>`;
+ iframe.src = "data:text/xml," + encodeURIComponent(src);
+ self.addEventListener("message", t.step_func_done(({data: {test, result}}) => {
+ if (test == 2) {
+ assert_true(result, "xslt-param-namespace should have set the right namespace");
+ }
+ }));
+ document.body.appendChild(iframe);
+}, "Test for xslt-param PIs");
+</script>
diff --git a/dom/xslt/tests/mochitest/test_bug1527308.html b/dom/xslt/tests/mochitest/test_bug1527308.html
new file mode 100644
index 0000000000..c37a0c1f00
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug1527308.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for serialized state in XSLT result document</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ let iframe = document.createElement('iframe');
+ let src = `<?xml version="1.0"?>
+ <?xml-stylesheet type="text/xml" href="#stylesheet"?>
+ <doc>
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" id="stylesheet">
+ <xsl:output method="html"/>
+ <xsl:template match="/">
+ <html>
+ <xsl:element name="script">self.addEventListener("message", () => { history.go(0); });</xsl:element>
+ <body onload="parent.postMessage(history.state, '*'); history.replaceState('data', 'title');"></body>
+ </html>
+ </xsl:template>
+ </xsl:stylesheet>
+ </doc>`;
+ iframe.src = "data:text/xml," + encodeURIComponent(src);
+ let reloaded = false;
+ self.addEventListener("message", t.step_func(({data: state}) => {
+ if (!reloaded) {
+ assert_equals(state, null, "At this point history.state should be set.");
+ iframe.contentWindow.postMessage("", "*");
+ reloaded = true;
+ return;
+ }
+
+ assert_equals(state, 'data', "Data set through history.replaceState in an XSLT result document should persist.");
+ t.done();
+ }));
+ document.body.appendChild(iframe);
+}, "Test for serialized state in XSLT result document");
+</script>
diff --git a/dom/xslt/tests/mochitest/test_bug319374.html b/dom/xslt/tests/mochitest/test_bug319374.html
new file mode 100644
index 0000000000..92d48e037a
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug319374.html
@@ -0,0 +1,101 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=319374
+-->
+<head>
+ <title>Test for Bug 319374</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=319374">Mozilla Bug 319374</a>
+<p id="display"></p>
+<div id="content"><custom-el></custom-el><custom-el></custom-el><custom-el></custom-el></div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+customElements.define("custom-el", class extends HTMLElement {
+ constructor() {
+ super();
+ this.attachShadow({ mode: "open" });
+ this.shadowRoot.innerHTML =
+ `<span attr="attribute"><span></span></span><span> anon text </span><br>`;
+ }
+});
+
+ function testChangesInShadowDOM() {
+ // Test 1: Make sure that modifying anonymous content doesn't
+ // cause non-anonymous XPath result to throw exceptions..
+ var counter = 0;
+ var error = null;
+ try {
+ var xp = new XPathEvaluator();
+ var result = xp.evaluate("*",
+ document.getElementById('content'),
+ null,
+ XPathResult.UNORDERED_NODE_ITERATOR_TYPE,
+ null);
+ var res = null;
+ while (res = result.iterateNext()) {
+ ++counter;
+ let anon = res.shadowRoot.childNodes;
+ anon[0].firstChild.remove(); // Removing a child node
+ anon[0].removeAttribute("attr1"); // Removing an attribute
+ anon[1].firstChild.data = "anon text changed" // Modifying text data
+ }
+ } catch (e) {
+ error = e;
+ }
+ ok(!error, error);
+ ok(counter == 3, "XPathEvaluator should have found 3 elements.")
+
+ // Test 2: If the context node is in anonymous content, changing some
+ // other anonymous tree shouldn't cause XPath result to throw.
+ let shadowAttr1 = document.getElementById("content").firstChild.
+ shadowRoot.firstChild.getAttributeNode("attr");
+ let shadowAttr2 = document.getElementById("content").lastChild.
+ shadowRoot.firstChild.getAttributeNode("attr");
+ var resultAttr = null;
+ try {
+ var xp2 = xp.evaluate(".",
+ shadowAttr1,
+ null,
+ XPathResult.UNORDERED_NODE_ITERATOR_TYPE,
+ null);
+ // Attribute changing in a different anonymous tree.
+ shadowAttr2.value = "foo";
+ resultAttr = xp2.iterateNext();
+ is(resultAttr, shadowAttr1, "XPathEvaluator returned wrong attribute!");
+ } catch (e) {
+ ok(false, e);
+ }
+
+ // Test 3: If the anonymous tree in which context node is in is modified,
+ // XPath result should throw when iterateNext() is called.
+ resultAttr = null;
+ try {
+ var xp3 = xp.evaluate(".",
+ shadowAttr1,
+ null,
+ XPathResult.UNORDERED_NODE_ITERATOR_TYPE,
+ null);
+ // Attribute changing in the same anonymous tree.
+ shadowAttr1.ownerElement.setAttribute("foo", "bar");
+ resultAttr = xp3.iterateNext();
+ ok(resultAttr == shadowAttr1,
+ "XPathEvaluator should have thrown an exception!")
+ } catch (e) {
+ ok(true, e);
+ }
+
+ SimpleTest.finish();
+ }
+
+ SimpleTest.waitForExplicitFinish();
+ addLoadEvent(testChangesInShadowDOM);
+</script>
+</pre>
+</body>
+</html>
+
diff --git a/dom/xslt/tests/mochitest/test_bug427060.html b/dom/xslt/tests/mochitest/test_bug427060.html
new file mode 100644
index 0000000000..0dac88b74b
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug427060.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=427060
+-->
+<head>
+ <title>Test for Bug 427060</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=427060">Mozilla Bug 427060</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 427060 **/
+
+var xmldoc, xsltdoc;
+
+xmldoc = new DOMParser().parseFromString('<opml version="1.0"><body></body></opml>', "text/xml");
+xsltdoc = new DOMParser().parseFromString('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n\
+ <xsl:template match="/opml">\n\
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n\
+ <head>\n\
+ <base target="_blank"></base>\n\
+ </head>\n\
+ <body></body>\n\
+ </html>\n\
+ </xsl:template>\n\
+ </xsl:stylesheet>', "text/xml");
+
+var processor = new XSLTProcessor;
+processor.importStylesheet(xsltdoc);
+try
+{
+ var result = processor.transformToDocument(xmldoc);
+}
+catch (e)
+{
+}
+ok(result && result instanceof Document, "XSLT transform should have created a document");
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug440974.html b/dom/xslt/tests/mochitest/test_bug440974.html
new file mode 100644
index 0000000000..40745ae210
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug440974.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=440974
+-->
+<head>
+ <title>Test for Bug 440974</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=440974">Mozilla Bug 440974</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 440974 **/
+
+function isTxResult(node)
+{
+ return node.namespaceURI == "http://www.mozilla.org/TransforMiix" &&
+ node.localName == "result";
+}
+
+var xmldoc, xsltdoc;
+
+xmldoc = new DOMParser().parseFromString('<items><item><id>1</id></item><item><id>2</id></item><item><id>3</id></item></items>', "text/xml");
+xsltdoc = new DOMParser().parseFromString('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n\
+ <xsl:output method="xml" />\n\
+ <xsl:template match="item"><foo id="{id}"/></xsl:template>\n\
+ </xsl:stylesheet>', "text/xml");
+
+var processor = new XSLTProcessor;
+processor.importStylesheet(xsltdoc);
+var result = processor.transformToDocument(xmldoc);
+var resultElements = Array.prototype.filter.call(result.getElementsByTagName('*'), isTxResult);
+is(resultElements.length, 1, "there should be only one 'transformiix:result' element");
+is(resultElements[0], result.documentElement, "the 'transformiix:result' element should be the document element");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug453441.html b/dom/xslt/tests/mochitest/test_bug453441.html
new file mode 100644
index 0000000000..1d8b554c00
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug453441.html
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=453441
+-->
+<head>
+ <title>Test for Bug 453441</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=453441">Mozilla Bug 453441</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 453441 **/
+
+function tryImportStylesheet(xml, valid)
+{
+ var processor = new XSLTProcessor;
+
+ var xsltdoc = new DOMParser().parseFromString(xml, "text/xml");
+ try
+ {
+ processor.importStylesheet(xsltdoc);
+ ok(valid, "should be able to parse this XSLT stylesheet");
+ }
+ catch (e)
+ {
+ ok(!valid, "should not be able to parse this XSLT stylesheet");
+ }
+}
+
+tryImportStylesheet(
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n\
+ <xsl:template match="/">\n\
+ <html xmlns="http://www.w3.org/1999/xhtml" xsl:version="1.0" />\n\
+ </xsl:template>\n\
+ </xsl:stylesheet>'
+, true);
+
+tryImportStylesheet(
+ '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" />'
+, false);
+
+tryImportStylesheet(
+ '<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" />'
+, false);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug468208.html b/dom/xslt/tests/mochitest/test_bug468208.html
new file mode 100644
index 0000000000..d3c05c7374
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug468208.html
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=468208
+-->
+<head>
+ <title>Test for Bug 468208</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=468208">Mozilla Bug 468208</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 468208 **/
+var xslt =
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\n\
+ <xsl:strip-space elements="color"/>\n\
+ </xsl:stylesheet>'
+;
+var xsltdoc = new DOMParser().parseFromString(xslt, "text/xml");
+
+var processor = new XSLTProcessor;
+processor.importStylesheet(xsltdoc);
+ok(true, "XSLT shouldn't leak");
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug511487.html b/dom/xslt/tests/mochitest/test_bug511487.html
new file mode 100644
index 0000000000..324ba04679
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug511487.html
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=511487
+-->
+<head>
+ <title>Test for Bug 511487</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511487">Mozilla Bug 511487</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 511487 **/
+
+ var didTransform = false;
+ var processor = new XSLTProcessor();
+ var style =
+ '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml">' +
+ '<xsl:output method="xml" version="1.0" encoding="UTF-8" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />' +
+ '<xsl:template match="wml">' +
+ '<html xmlns="http://www.w3.org/1999/xhtml">' +
+ '<head>' +
+ '<title>XSLT test</title>' +
+ '</head>' +
+ '<body onload="window.alert(this)">' +
+ '</body>' +
+ '</html>' +
+ '</xsl:template>' +
+ '</xsl:stylesheet>';
+ var styleDoc = new DOMParser().parseFromString (style, "text/xml");
+
+ var data =
+ '<?xml version="1.0"?>' +
+ '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">' +
+ '<wml><card><p>paragraph</p></card></wml>';
+ var originalDoc = new DOMParser().parseFromString(data, "text/xml");
+
+ processor.importStylesheet(styleDoc);
+ try {
+ var transformedDocument = processor.transformToDocument(originalDoc);
+ didTransform = true;
+ } catch (e) {
+ ok(false, e);
+ }
+
+ ok(didTransform, "transformToDocument didn't succeed!");
+
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug551412.html b/dom/xslt/tests/mochitest/test_bug551412.html
new file mode 100644
index 0000000000..399310a014
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug551412.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=551412
+-->
+<head>
+ <title>Test for Bug 551412</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=551412">Mozilla Bug 551412</a>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 551412 **/
+
+ var processor = new XSLTProcessor();
+ var style =
+ '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' +
+ 'xmlns:exsl="http://exslt.org/common" ' +
+ 'version="1.0">' +
+ '<xsl:output method="html"/>' +
+ '<xsl:variable name="rtf">1 <b>2</b> 3</xsl:variable>' +
+ '<xsl:template match="/">' +
+ '<xsl:copy-of select="exsl:node-set($rtf)"/>' +
+ '</xsl:template>' +
+ '</xsl:stylesheet>';
+ var styleDoc = new DOMParser().parseFromString (style, "text/xml");
+
+ var data =
+ '<root/>';
+ var originalDoc = new DOMParser().parseFromString(data, "text/xml");
+
+ processor.importStylesheet(styleDoc);
+
+ var fragment = processor.transformToFragment(originalDoc, document);
+ var content = document.getElementById("content");
+ content.appendChild(fragment);
+ is(content.innerHTML, "1 <b>2</b> 3",
+ "Result of transform should be '1 <b>2</b> 3'");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug551654.html b/dom/xslt/tests/mochitest/test_bug551654.html
new file mode 100644
index 0000000000..0bdd2dda60
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug551654.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=551654
+-->
+<head>
+ <title>Test for Bug 551654</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=551654">Mozilla Bug 551654</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 551654 **/
+
+ var didTransform = false;
+ var processor = new XSLTProcessor();
+ var style =
+ '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' +
+ 'xmlns:exsl="http://exslt.org/common" ' +
+ 'version="1.0">' +
+ '<xsl:output method="html"/>' +
+ '<xsl:template match="/">' +
+ '<xsl:copy-of select="exsl:node-set(42)"/>' +
+ '</xsl:template>' +
+ '</xsl:stylesheet>';
+ var styleDoc = new DOMParser().parseFromString (style, "text/xml");
+
+ var data =
+ '<root/>';
+ var originalDoc = new DOMParser().parseFromString(data, "text/xml");
+
+ processor.importStylesheet(styleDoc);
+ var fragment = processor.transformToFragment(originalDoc, document);
+ is(fragment.firstChild.nodeType, Node.TEXT_NODE,
+ "Result of transform should be a textnode");
+ is(fragment.firstChild.nodeValue, "42",
+ "Result of transform should be a textnode with value '42'");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug566629.html b/dom/xslt/tests/mochitest/test_bug566629.html
new file mode 100644
index 0000000000..5670207145
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug566629.html
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=566629
+-->
+<head>
+ <title>Test for Bug 566629</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=566629">Mozilla Bug 566629</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 566629 **/
+
+var xsltdoc = new DOMParser().parseFromString(
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\
+ xmlns:xhtml="http://www.w3.org/1999/xhtml">\
+ <xsl:template match="/">\
+ <xsl:value-of select="count(//body)"/>\
+ <xsl:text>,</xsl:text>\
+ <xsl:value-of select="count(//xhtml:body)"/>\
+ <xsl:text>,</xsl:text>\
+ <xsl:value-of select="count(//xsl:body)"/>\
+ <xsl:text>,</xsl:text>\
+ <xsl:value-of select="name(//body)"/>\
+ <xsl:text>,</xsl:text>\
+ <xsl:value-of select="local-name(//body)"/>\
+ </xsl:template>\
+ </xsl:stylesheet>',
+ "text/xml");
+
+var processor = new XSLTProcessor;
+processor.importStylesheet(xsltdoc);
+var result = processor.transformToFragment(document, document);
+ok(result instanceof DocumentFragment, "returned a docfragment");
+is(result.firstChild.nodeValue, "1,1,0,BODY,body",
+ "correct treatment of HTML elements in XSLT");
+
+is(document.evaluate("count(//body)", document, null, XPathResult.ANY_TYPE, null).numberValue,
+ 1, "namespace-less node-test");
+is(document.evaluate("count(//a:body)", document,
+ function() { return "http://www.w3.org/1999/xhtml" },
+ XPathResult.ANY_TYPE, null).numberValue,
+ 1, "with-namespace node-test");
+is(document.evaluate("count(//a:body)", document,
+ function() { return "foo" },
+ XPathResult.ANY_TYPE, null).numberValue,
+ 0, "wrong-namespace node-test");
+is(document.evaluate("//bODy", document, null, XPathResult.ANY_TYPE, null).iterateNext(),
+ document.body, "case insensitive matching");
+is(document.evaluate("count(//a:bODy)", document,
+ function() { return "http://www.w3.org/1999/xhtml" },
+ XPathResult.ANY_TYPE, null).numberValue,
+ 0, "with-namespace but wrong casing node-test");
+is(document.evaluate("name(//body)", document, null, XPathResult.ANY_TYPE, null).stringValue,
+ "BODY", "uppercase name() function");
+is(document.evaluate("local-name(//body)", document, null, XPathResult.ANY_TYPE, null).stringValue,
+ "body", "lowercase local-name() function");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug566629.xhtml b/dom/xslt/tests/mochitest/test_bug566629.xhtml
new file mode 100644
index 0000000000..0880a36002
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug566629.xhtml
@@ -0,0 +1,73 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=566629
+-->
+<head>
+ <title>Test for Bug 566629</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=566629">Mozilla Bug 566629</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+<![CDATA[
+/** Test for Bug 566629 **/
+
+var xsltdoc = new DOMParser().parseFromString(
+ '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\
+ xmlns:xhtml="http://www.w3.org/1999/xhtml">\
+ <xsl:template match="/">\
+ <xsl:value-of select="count(//body)"/>\
+ <xsl:text>,</xsl:text>\
+ <xsl:value-of select="count(//xhtml:body)"/>\
+ <xsl:text>,</xsl:text>\
+ <xsl:value-of select="count(//xsl:body)"/>\
+ <xsl:text>,</xsl:text>\
+ <xsl:value-of select="name(//xhtml:body)"/>\
+ <xsl:text>,</xsl:text>\
+ <xsl:value-of select="local-name(//xhtml:body)"/>\
+ </xsl:template>\
+ </xsl:stylesheet>',
+ "text/xml");
+
+var processor = new XSLTProcessor;
+processor.importStylesheet(xsltdoc);
+var result = processor.transformToFragment(document, document);
+ok(result instanceof DocumentFragment, "returned a docfragment");
+is(result.firstChild.nodeValue, "0,1,0,body,body",
+ "correct treatment of HTML elements in XSLT");
+
+is(document.evaluate("count(//body)", document, null, XPathResult.ANY_TYPE, null).numberValue,
+ 0, "namespace-less node-test");
+is(document.evaluate("count(//a:body)", document,
+ function() { return "http://www.w3.org/1999/xhtml" },
+ XPathResult.ANY_TYPE, null).numberValue,
+ 1, "with-namespace node-test");
+is(document.evaluate("count(//a:body)", document,
+ function() { return "foo" },
+ XPathResult.ANY_TYPE, null).numberValue,
+ 0, "wrong-namespace node-test");
+is(document.evaluate("count(//a:bODy)", document,
+ function() { return "http://www.w3.org/1999/xhtml" },
+ XPathResult.ANY_TYPE, null).numberValue,
+ 0, "with-namespace wrong-casing node-test");
+is(document.evaluate("count(//bODy)", document, null, XPathResult.ANY_TYPE, null).numberValue,
+ 0, "without-namespace wrong-casing node-test");
+is(document.evaluate("name(//a:body)", document,
+ function() { return "http://www.w3.org/1999/xhtml" },
+ XPathResult.ANY_TYPE, null).stringValue,
+ "body", "name()");
+is(document.evaluate("local-name(//a:body)", document,
+ function() { return "http://www.w3.org/1999/xhtml" },
+ XPathResult.ANY_TYPE, null).stringValue,
+ "body", "local-name()");
+]]>
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug603159.html b/dom/xslt/tests/mochitest/test_bug603159.html
new file mode 100644
index 0000000000..95c4efa9c5
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug603159.html
@@ -0,0 +1,54 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=603159
+-->
+<head>
+ <title>Test for Bug 603159</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=603159">Mozilla Bug 603159</a>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 603159 **/
+
+ var style =
+ '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' +
+ 'xmlns:date="http://exslt.org/dates-and-times" '+
+ 'version="1.0">' +
+ '<xsl:output method="html"/>' +
+ '<xsl:template match="/">' +
+ '<xsl:value-of select="date:date-time()" /> ' +
+ '</xsl:template>' +
+ '</xsl:stylesheet>';
+ var styleDoc = new DOMParser().parseFromString (style, "text/xml");
+
+ var data = '<root/>';
+ var originalDoc = new DOMParser().parseFromString(data, "text/xml");
+
+ var processor = new XSLTProcessor();
+ processor.importStylesheet(styleDoc);
+
+ var fragment = processor.transformToFragment(originalDoc, document);
+ var content = document.getElementById("content");
+ content.appendChild(fragment);
+
+ // use Gecko's Date.parse to parse, then compare the milliseconds since epoch
+ var xslt_ms = Date.parse(content.innerHTML);
+ var now_ms = new Date().getTime();
+ var accepted_diff = 30 * 60 * 1000; // 30 minutes
+ var diff = Math.abs(now_ms - xslt_ms);
+
+ ok(diff < accepted_diff, "generated timestamp should be not more than "
+ + accepted_diff + " ms before 'now', but the difference was: " + diff);
+
+ content.innerHTML = '';
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug616774.html b/dom/xslt/tests/mochitest/test_bug616774.html
new file mode 100644
index 0000000000..e970b778e9
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug616774.html
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=616774-->
+<head>
+ <title>Test for Bug 616774</title>
+ <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=616774">Mozilla Bug 616774</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+ 42
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 616774 **/
+is(document.evaluate('- "8"', document, null, XPathResult.ANY_TYPE, null).numberValue, -8, "Negated string literal should evaluate to itself negated");
+is(document.evaluate('- - "999"', document, null, XPathResult.ANY_TYPE, null).numberValue, 999, "String literal should evaluate to itself");
+is(document.evaluate('- - id("content")', document, null, XPathResult.ANY_TYPE, null).numberValue, 42, "DOM element should evaluate to itself coerced to a number");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_bug667315.html b/dom/xslt/tests/mochitest/test_bug667315.html
new file mode 100644
index 0000000000..a54fa05f42
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_bug667315.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=667315
+-->
+<head>
+ <title>Test for Bug 667315</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=667315">Mozilla Bug 667315</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 667315 **/
+
+var style =
+ '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ' +
+ 'version="1.0">' +
+ '<xsl:variable name="var">' +
+ '<html><p>a</p></html>' +
+ '</xsl:variable>' +
+ '<xsl:template match="/">' +
+ '<xsl:copy-of select="$var" />' +
+ '</xsl:template>' +
+ '</xsl:stylesheet>';
+var styleDoc = new DOMParser().parseFromString (style, "text/xml");
+
+var data = '<root/>';
+var originalDoc = new DOMParser().parseFromString(data, "text/xml");
+
+var processor = new XSLTProcessor();
+processor.importStylesheet(styleDoc);
+
+var doc = processor.transformToDocument(originalDoc);
+ok(doc instanceof HTMLDocument, "should have switched to html output method");
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_exslt.html b/dom/xslt/tests/mochitest/test_exslt.html
new file mode 100644
index 0000000000..739d1c1988
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_exslt.html
@@ -0,0 +1,249 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Test EXSLT extensions
+http://www.exslt.org/
+-->
+<head>
+ <title>Test for EXSLT extensions</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test">
+<script type="application/javascript">
+ let tests = [
+ {
+ descr: "Testing common:node-set",
+ expr: "common:node-set($tree)",
+ useCopyOf: true,
+ expResult: "<abc>def</abc>",
+ },
+ {
+ descr: "Testing common:object-type(string)",
+ expr: "common:object-type($string)",
+ expResult: "string",
+ },
+ {
+ descr: "Testing common:object-type(number)",
+ expr: "common:object-type($number)",
+ expResult: "number",
+ },
+ {
+ descr: "Testing common:object-type(boolean)",
+ expr: "common:object-type($boolean)",
+ expResult: "boolean",
+ },
+ {
+ descr: "Testing common:object-type(node-set)",
+ expr: "common:object-type($node-set)",
+ expResult: "node-set",
+ },
+ {
+ descr: "Testing common:object-type(tree)",
+ expr: "common:object-type($tree)",
+ expResult: "RTF",
+ },
+ {
+ descr: "Testing math:max",
+ expr: "math:max(root/numbers/number)",
+ expResult: "11",
+ },
+ {
+ descr: "Testing math:min",
+ expr: "math:min(root/numbers/number)",
+ expResult: "4",
+ },
+ {
+ descr: "Testing math:highest",
+ expr: "math:highest(root/numbers/number)/@id",
+ expResult: "eleven",
+ },
+ {
+ descr: "Testing math:lowest",
+ expr: "math:lowest(root/numbers/number)/@id",
+ expResult: "four",
+ },
+ {
+ descr: "Testing regexp:test",
+ expr: "regexp:test('XSLT is great', 'XSLT', '')",
+ expResult: "true",
+ },
+ {
+ descr: "Testing regexp:match",
+ expr: "regexp:match('XSLT is great', 'XSL.', '')[1]",
+ expResult: "XSLT",
+ },
+ {
+ descr: "Testing regexp:replace",
+ expr: "regexp:replace('Food is great', 'Fo.d', '', 'XSLT')",
+ expResult: "XSLT is great",
+ },
+ {
+ descr: "Testing sets:difference",
+ expr: "sets:difference($i, $e)",
+ useCopyOf: true,
+ expResult: "<city name=\"Paris\" country=\"France\"></city><city name=\"Madrid\" country=\"Spain\"></city><city name=\"Calais\" country=\"France\"></city>",
+ },
+ {
+ descr: "Testing sets:distinct",
+ expr: "strings:concat(sets:distinct(//@country))",
+ expResult: "FranceSpainAustriaGermany",
+ },
+ {
+ descr: "Testing sets:hasSameNode",
+ expr: "sets:has-same-node($i, $e)",
+ expResult: "true",
+ },
+ {
+ descr: "Testing sets:hasSameNode",
+ expr: "sets:has-same-node($i, $o)",
+ expResult: "false",
+ },
+ {
+ descr: "Testing sets:intersection",
+ expr: "sets:intersection($i, $e)",
+ useCopyOf: true,
+ expResult: "<city name=\"Vienna\" country=\"Austria\"></city><city name=\"Berlin\" country=\"Germany\"></city>",
+ },
+ {
+ descr: "Testing sets:leading",
+ expr: "sets:leading($i, $e)",
+ useCopyOf: true,
+ expResult: "<city name=\"Paris\" country=\"France\"></city><city name=\"Madrid\" country=\"Spain\"></city>",
+ },
+ {
+ descr: "Testing sets:leading",
+ expr: "sets:leading($i, $o)",
+ useCopyOf: true,
+ expResult: "",
+ },
+ {
+ descr: "Testing sets:leading",
+ expr: "sets:leading($i, $empty)",
+ useCopyOf: true,
+ expResult: "<city name=\"Paris\" country=\"France\"></city><city name=\"Madrid\" country=\"Spain\"></city><city name=\"Vienna\" country=\"Austria\"></city><city name=\"Calais\" country=\"France\"></city><city name=\"Berlin\" country=\"Germany\"></city>",
+ },
+ {
+ descr: "Testing sets:trailing",
+ expr: "sets:trailing($i, $e)",
+ useCopyOf: true,
+ expResult: "<city name=\"Calais\" country=\"France\"></city><city name=\"Berlin\" country=\"Germany\"></city>",
+ },
+ {
+ descr: "Testing sets:trailing",
+ expr: "sets:trailing($i, $o)",
+ useCopyOf: true,
+ expResult: "",
+ },
+ {
+ descr: "Testing sets:trailing",
+ expr: "sets:trailing($i, $empty)",
+ useCopyOf: true,
+ expResult: "<city name=\"Paris\" country=\"France\"></city><city name=\"Madrid\" country=\"Spain\"></city><city name=\"Vienna\" country=\"Austria\"></city><city name=\"Calais\" country=\"France\"></city><city name=\"Berlin\" country=\"Germany\"></city>",
+ },
+ {
+ descr: "Testing strings:concat",
+ expr: "strings:concat(root/numbers/number/@id)",
+ expResult: "seveneleveneightfour",
+ },
+ {
+ descr: "Testing strings:split",
+ expr: "strings:split('a, simple, list', ', ')",
+ useCopyOf: true,
+ expResult: "<token>a</token><token>simple</token><token>list</token>",
+ },
+ {
+ descr: "Testing strings:split",
+ expr: "strings:split('date math str')",
+ useCopyOf: true,
+ expResult: "<token>date</token><token>math</token><token>str</token>",
+ },
+ {
+ descr: "Testing strings:split",
+ expr: "strings:split('foo', '')",
+ useCopyOf: true,
+ expResult: "<token>f</token><token>o</token><token>o</token>",
+ },
+ {
+ descr: "Testing strings:tokenize",
+ expr: "strings:tokenize('2001-06-03T11:40:23', '-T:')",
+ useCopyOf: true,
+ expResult: "<token>2001</token><token>06</token><token>03</token><token>11</token><token>40</token><token>23</token>",
+ },
+ {
+ descr: "Testing strings:tokenize",
+ expr: "strings:tokenize('date math str')",
+ useCopyOf: true,
+ expResult: "<token>date</token><token>math</token><token>str</token>",
+ },
+ {
+ descr: "Testing strings:tokenize",
+ expr: "strings:tokenize('foo', '')",
+ useCopyOf: true,
+ expResult: "<token>f</token><token>o</token><token>o</token>",
+ },
+ ];
+
+ let style =
+ `<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:common="http://exslt.org/common"
+ xmlns:math="http://exslt.org/math"
+ xmlns:regexp="http://exslt.org/regular-expressions"
+ xmlns:sets="http://exslt.org/sets"
+ xmlns:strings="http://exslt.org/strings">
+ <xsl:output method="html"/>
+ <xsl:variable name="tree"><abc>def</abc></xsl:variable>
+ <xsl:variable name="string" select="'abc'"/>
+ <xsl:variable name="number" select="123"/>
+ <xsl:variable name="boolean" select="true()"/>
+ <xsl:variable name="node-set" select="//*"/>
+ <xsl:variable name="i" select="/root/sets/city[contains(@name, 'i')]" />
+ <xsl:variable name="e" select="/root/sets/city[contains(@name, 'e')]" />
+ <xsl:variable name="o" select="/root/sets/city[contains(@name, 'o')]" />
+ <xsl:variable name="empty" select="/root/sets/city[contains(@name, 'x')]" />
+ <xsl:template match="/">
+ ${tests.map(({expr, useCopyOf}, i) => `<div id="${i}"><xsl:${useCopyOf ? "copy-of" : "value-of"} select="${expr}"/></div>`).join("\n")}
+ </xsl:template>
+ </xsl:stylesheet>`;
+
+ let styleDoc = new DOMParser().parseFromString(style, "text/xml");
+
+ let data = `<root>
+ <numbers>
+ <number id="seven">7</number>
+ <number id="eleven">11</number>
+ <number id="eight">8</number>
+ <number id="four">4</number>
+ </numbers>
+ <sets>
+ <city name="Paris" country="France" />
+ <city name="Madrid" country="Spain" />
+ <city name="Vienna" country="Austria" />
+ <city name="Barcelona" country="Spain" />
+ <city name="Salzburg" country="Austria" />
+ <city name="Bonn" country="Germany" />
+ <city name="Lyon" country="France" />
+ <city name="Hannover" country="Germany" />
+ <city name="Calais" country="France" />
+ <city name="Berlin" country="Germany" />
+ </sets>
+ </root>`;
+ let originalDoc = new DOMParser().parseFromString(data, "text/xml");
+
+ let processor = new XSLTProcessor();
+ processor.importStylesheet(styleDoc);
+
+ let fragment = processor.transformToFragment(originalDoc, document);
+
+ tests.forEach(({descr, expResult}, i) => {
+ let result = fragment.getElementById(i);
+ is(result.innerHTML, expResult, descr);
+ });
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/xslt/tests/mochitest/test_parameter.html b/dom/xslt/tests/mochitest/test_parameter.html
new file mode 100644
index 0000000000..0239f33c5c
--- /dev/null
+++ b/dom/xslt/tests/mochitest/test_parameter.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for setParameter/getParameter</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test">
+<script>
+ var processor = new XSLTProcessor();
+
+ processor.setParameter(null, "test", "hello");
+ is(processor.getParameter(null, "test"), "hello", "null namespace works");
+
+ processor.setParameter("foo", "bar", "foobar");
+ is(processor.getParameter("foo", "bar"), "foobar", "non-null namespace works");
+
+ processor.setParameter(null, "test", 123);
+ is(processor.getParameter(null, "test"), 123, "number value works");
+
+ processor.removeParameter(null, "test");
+ is(processor.getParameter(null, "test"), null, "removeParameter works");
+
+ is(processor.getParameter(null, "not-here"), null, "nonexistant parameter");
+</script>
+</pre>
+</body>
+</html>