summaryrefslogtreecommitdiffstats
path: root/testing/mochitest/chrome
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testing/mochitest/chrome-harness.js262
-rw-r--r--testing/mochitest/chrome/chrome.ini16
-rw-r--r--testing/mochitest/chrome/test-dir/test-file1
-rw-r--r--testing/mochitest/chrome/test_chromeGetTestFile.xhtml47
-rw-r--r--testing/mochitest/chrome/test_sample.xhtml35
-rw-r--r--testing/mochitest/chrome/test_sanityEventUtils.xhtml171
-rw-r--r--testing/mochitest/chrome/test_sanityException.xhtml24
-rw-r--r--testing/mochitest/chrome/test_sanityException2.xhtml30
-rw-r--r--testing/mochitest/chrome/test_sanityManifest.xhtml19
-rw-r--r--testing/mochitest/chrome/test_sanityManifest_pf.xhtml20
-rw-r--r--testing/mochitest/chrome/test_tasks_skip.xhtml36
-rw-r--r--testing/mochitest/chrome/test_tasks_skipall.xhtml37
12 files changed, 698 insertions, 0 deletions
diff --git a/testing/mochitest/chrome-harness.js b/testing/mochitest/chrome-harness.js
new file mode 100644
index 0000000000..d9827fa503
--- /dev/null
+++ b/testing/mochitest/chrome-harness.js
@@ -0,0 +1,262 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et: */
+/* 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 { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
+
+/* import-globals-from manifestLibrary.js */
+
+// Defined in browser-test.js
+/* global gTestPath */
+
+/*
+ * getChromeURI converts a URL to a URI
+ *
+ * url: string of a URL (http://mochi.test/test.html)
+ * returns: a nsiURI object representing the given URL
+ *
+ */
+function getChromeURI(url) {
+ return Services.io.newURI(url);
+}
+
+/*
+ * Convert a URL (string) into a nsIURI or NSIJARURI
+ * This is intended for URL's that are on a file system
+ * or in packaged up in an extension .jar file
+ *
+ * url: a string of a url on the local system(http://localhost/blah.html)
+ */
+function getResolvedURI(url) {
+ var chromeURI = getChromeURI(url);
+ var resolvedURI = Cc["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Ci.nsIChromeRegistry)
+ .convertChromeURL(chromeURI);
+
+ try {
+ resolvedURI = resolvedURI.QueryInterface(Ci.nsIJARURI);
+ } catch (ex) {} // not a jar file
+
+ return resolvedURI;
+}
+
+/**
+ * getChromeDir is intended to be called after getResolvedURI and convert
+ * the input URI into a nsIFile (actually the directory containing the
+ * file). This can be used for copying or referencing the file or extra files
+ * required by the test. Usually we need to load a secondary html file or library
+ * and this will give us file system access to that.
+ *
+ * resolvedURI: nsIURI (from getResolvedURI) that points to a file:/// url
+ */
+function getChromeDir(resolvedURI) {
+ var fileHandler = Cc["@mozilla.org/network/protocol;1?name=file"].getService(
+ Ci.nsIFileProtocolHandler
+ );
+ var chromeDir = fileHandler.getFileFromURLSpec(resolvedURI.spec);
+ return chromeDir.parent.QueryInterface(Ci.nsIFile);
+}
+
+// used by tests to determine their directory based off window.location.path
+function getRootDirectory(path, chromeURI) {
+ if (chromeURI === undefined) {
+ chromeURI = getChromeURI(path);
+ }
+ var myURL = chromeURI.QueryInterface(Ci.nsIURL);
+ var mydir = myURL.directory;
+
+ if (mydir.match("/$") != "/") {
+ mydir += "/";
+ }
+
+ return chromeURI.prePath + mydir;
+}
+
+// used by tests to determine their directory based off window.location.path
+function getChromePrePath(path, chromeURI) {
+ if (chromeURI === undefined) {
+ chromeURI = getChromeURI(path);
+ }
+
+ return chromeURI.prePath;
+}
+
+/*
+ * Given a URI, return nsIJARURI or null
+ */
+function getJar(uri) {
+ var resolvedURI = getResolvedURI(uri);
+ var jar = null;
+ try {
+ if (resolvedURI.JARFile) {
+ jar = resolvedURI;
+ }
+ } catch (ex) {}
+ return jar;
+}
+
+/*
+ * input:
+ * jar: a nsIJARURI object with the jarfile and jarentry (path in jar file)
+ *
+ * output;
+ * all files and subdirectories inside jarentry will be extracted to TmpD/mochikit.tmp
+ * we will return the location of /TmpD/mochikit.tmp* so you can reference the files locally
+ */
+function extractJarToTmp(jar) {
+ var tmpdir = Services.dirsvc.get("ProfD", Ci.nsIFile);
+ tmpdir.append("mochikit.tmp");
+ // parseInt is used because octal escape sequences cause deprecation warnings
+ // in strict mode (which is turned on in debug builds)
+ tmpdir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0777", 8));
+
+ var zReader = Cc["@mozilla.org/libjar/zip-reader;1"].createInstance(
+ Ci.nsIZipReader
+ );
+
+ var fileHandler = Cc["@mozilla.org/network/protocol;1?name=file"].getService(
+ Ci.nsIFileProtocolHandler
+ );
+
+ var fileName = fileHandler.getFileFromURLSpec(jar.JARFile.spec);
+ zReader.open(fileName);
+
+ // filepath represents the path in the jar file without the filename
+ var filepath = "";
+ var parts = jar.JAREntry.split("/");
+ for (var i = 0; i < parts.length - 1; i++) {
+ if (parts[i] != "") {
+ filepath += parts[i] + "/";
+ }
+ }
+
+ /* Create dir structure first, no guarantee about ordering of directories and
+ * files returned from findEntries.
+ */
+ for (let dir of zReader.findEntries(filepath + "*/")) {
+ var targetDir = buildRelativePath(dir, tmpdir, filepath);
+ // parseInt is used because octal escape sequences cause deprecation warnings
+ // in strict mode (which is turned on in debug builds)
+ if (!targetDir.exists()) {
+ targetDir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0777", 8));
+ }
+ }
+
+ // now do the files
+ for (var fname of zReader.findEntries(filepath + "*")) {
+ if (fname.substr(-1) != "/") {
+ var targetFile = buildRelativePath(fname, tmpdir, filepath);
+ zReader.extract(fname, targetFile);
+ }
+ }
+ return tmpdir;
+}
+
+/*
+ * Take a relative path from the current mochitest file
+ * and returns the absolute path for the given test data file.
+ */
+function getTestFilePath(path) {
+ if (path[0] == "/") {
+ throw new Error("getTestFilePath only accepts relative path");
+ }
+ // Get the chrome/jar uri for the current mochitest file
+ // gTestPath being defined by the test harness in browser-chrome tests
+ // or window is being used for mochitest-browser
+ var baseURI = typeof gTestPath == "string" ? gTestPath : window.location.href;
+ var parentURI = getResolvedURI(getRootDirectory(baseURI));
+ var file;
+ if (parentURI.JARFile) {
+ // If it's a jar/zip, we have to extract it first
+ file = extractJarToTmp(parentURI);
+ } else {
+ // Otherwise, we can directly cast it to a file URI
+ var fileHandler = Cc[
+ "@mozilla.org/network/protocol;1?name=file"
+ ].getService(Ci.nsIFileProtocolHandler);
+ file = fileHandler.getFileFromURLSpec(parentURI.spec);
+ }
+ // Then walk by the given relative path
+ path.split("/").forEach(function(p) {
+ if (p == "..") {
+ file = file.parent;
+ } else if (p != ".") {
+ file.append(p);
+ }
+ });
+ return file.path;
+}
+
+/*
+ * Simple utility function to take the directory structure in jarentryname and
+ * translate that to a path of a nsIFile.
+ */
+function buildRelativePath(jarentryname, destdir, basepath) {
+ var baseParts = basepath.split("/");
+ if (baseParts[baseParts.length - 1] == "") {
+ baseParts.pop();
+ }
+
+ var parts = jarentryname.split("/");
+
+ var targetFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
+ targetFile.initWithFile(destdir);
+
+ for (var i = baseParts.length; i < parts.length; i++) {
+ targetFile.append(parts[i]);
+ }
+
+ return targetFile;
+}
+
+function readConfig(filename) {
+ filename = filename || "testConfig.js";
+
+ var configFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
+ configFile.append(filename);
+
+ if (!configFile.exists()) {
+ return {};
+ }
+
+ var fileInStream = Cc[
+ "@mozilla.org/network/file-input-stream;1"
+ ].createInstance(Ci.nsIFileInputStream);
+ fileInStream.init(configFile, -1, 0, 0);
+
+ var str = NetUtil.readInputStreamToString(
+ fileInStream,
+ fileInStream.available()
+ );
+ fileInStream.close();
+ return JSON.parse(str);
+}
+
+function getTestList(params, callback) {
+ var baseurl = "chrome://mochitests/content";
+ if (window.parseQueryString) {
+ params = window.parseQueryString(location.search.substring(1), true);
+ }
+ if (!params.baseurl) {
+ params.baseurl = baseurl;
+ }
+
+ var config = readConfig();
+ for (var p in params) {
+ if (params[p] == 1) {
+ config[p] = true;
+ } else if (params[p] == 0) {
+ config[p] = false;
+ } else {
+ config[p] = params[p];
+ }
+ }
+ params = config;
+ getTestManifest(
+ "http://mochi.test:8888/" + params.manifestFile,
+ params,
+ callback
+ );
+}
diff --git a/testing/mochitest/chrome/chrome.ini b/testing/mochitest/chrome/chrome.ini
new file mode 100644
index 0000000000..54fe522226
--- /dev/null
+++ b/testing/mochitest/chrome/chrome.ini
@@ -0,0 +1,16 @@
+[DEFAULT]
+skip-if = os == 'android'
+support-files = test-dir/test-file
+
+[test_sample.xhtml]
+[test_sanityEventUtils.xhtml]
+fail-if = headless # Bug 1678303
+[test_sanityException.xhtml]
+[test_sanityException2.xhtml]
+[test_sanityManifest.xhtml]
+fail-if = true
+[test_sanityManifest_pf.xhtml]
+fail-if = true
+[test_chromeGetTestFile.xhtml]
+[test_tasks_skip.xhtml]
+[test_tasks_skipall.xhtml]
diff --git a/testing/mochitest/chrome/test-dir/test-file b/testing/mochitest/chrome/test-dir/test-file
new file mode 100644
index 0000000000..257cc5642c
--- /dev/null
+++ b/testing/mochitest/chrome/test-dir/test-file
@@ -0,0 +1 @@
+foo
diff --git a/testing/mochitest/chrome/test_chromeGetTestFile.xhtml b/testing/mochitest/chrome/test_chromeGetTestFile.xhtml
new file mode 100644
index 0000000000..9bc0a74f3b
--- /dev/null
+++ b/testing/mochitest/chrome/test_chromeGetTestFile.xhtml
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!-- 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://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<window title="Test chrome harness functions"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script src="chrome://mochikit/content/chrome-harness.js"></script>
+ <script type="application/javascript">
+ <![CDATA[
+ add_task(async function test() {
+ SimpleTest.doesThrow(function () {
+ getTestFilePath("/test_chromeGetTestFile.xhtml")
+ }, "getTestFilePath rejects absolute paths");
+
+ await Promise.all([
+ IOUtils.exists(getTestFilePath("test_chromeGetTestFile.xhtml"))
+ .then(function (exists) {
+ ok(exists, "getTestFilePath consider the path as being relative");
+ }),
+
+ IOUtils.exists(getTestFilePath("./test_chromeGetTestFile.xhtml"))
+ .then(function (exists) {
+ ok(exists, "getTestFilePath also accepts explicit relative path");
+ }),
+
+ IOUtils.exists(getTestFilePath("./test_chromeGetTestFileTypo.xhtml"))
+ .then(function (exists) {
+ ok(!exists, "getTestFilePath do not throw if the file doesn't exists");
+ }),
+
+ IOUtils.readUTF8(getTestFilePath("test-dir/test-file"))
+ .then(function (content) {
+ is(content, "foo\n", "getTestFilePath can reach sub-folder files 1/2");
+ }),
+
+ IOUtils.readUTF8(getTestFilePath("./test-dir/test-file"))
+ .then(function (content) {
+ is(content, "foo\n", "getTestFilePath can reach sub-folder files 2/2");
+ })
+ ]);
+ });
+ ]]>
+ </script>
+</window>
diff --git a/testing/mochitest/chrome/test_sample.xhtml b/testing/mochitest/chrome/test_sample.xhtml
new file mode 100644
index 0000000000..041a910aa9
--- /dev/null
+++ b/testing/mochitest/chrome/test_sample.xhtml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=8675309
+-->
+<window title="Mozilla Bug 8675309"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=8675309">Mozilla Bug 8675309</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+
+<script class="testbody" type="application/javascript">
+<![CDATA[
+
+/** Test for Bug 8675309 **/
+
+ok(true, "sanity check");
+
+
+
+]]>
+</script>
+
+</window>
diff --git a/testing/mochitest/chrome/test_sanityEventUtils.xhtml b/testing/mochitest/chrome/test_sanityEventUtils.xhtml
new file mode 100644
index 0000000000..5eb2572d19
--- /dev/null
+++ b/testing/mochitest/chrome/test_sanityEventUtils.xhtml
@@ -0,0 +1,171 @@
+<?xml version="1.0"?>
+<!-- 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://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<window title="Test EventUtils functions"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script type="text/javascript">
+ var start = new Date();
+ </script>
+ <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+ <script type="text/javascript">
+ var loadTime = new Date();
+ </script>
+ <script type="application/javascript">
+ <![CDATA[
+ info("\nProfile::EventUtilsLoadTime: " + (loadTime - start) + "\n");
+ var testFile = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
+ var regularDtForDrag1 = null;
+ var gSetDropEffect = true;
+ var gData;
+ var gEnter = false;
+ var gOver = false;
+ var dragDrop = [[
+ { type : "text/plain",
+ data : "This is a test" }
+ ]];
+ // this is the expected data arrays
+ // for testing drag of 2 items create 2 inner arrays
+ var drag1 = [[
+ { type : "text/uri-list",
+ data : "http://www.mozilla.org/" }
+ ]];
+ var drag2items = [[
+ { type : "text/uri-list",
+ data : "http://www.mozilla.org/" }
+ ],[
+ { type : "text/uri-list",
+ data : "http://www.mozilla.org/" }
+ ]];
+ var drag1WrongFlavor = [[
+ { type : "text/plain",
+ data : "this is text/plain" }
+ ]];
+ var drag2 = [[
+ { type : "text/plain",
+ data : "this is text/plain" },
+ { type : "text/uri-list",
+ data : "http://www.mozilla.org/" }
+ ]];
+ var drag2WrongOrder = [[
+ { type : "text/uri-list",
+ data : "http://www.mozilla.org/" },
+ { type : "text/plain",
+ data : "this is text/plain" }
+ ]];
+ var dragfile = [[
+ { type : "application/x-moz-file",
+ data : testFile,
+ eqTest(actualData, expectedData) {return expectedData.equals(actualData);} },
+ { type : "Files",
+ data : null }
+ ]];
+
+ function doOnDrop(aEvent) {
+ gData = aEvent.dataTransfer.getData(dragDrop[0][0].type);
+ aEvent.preventDefault(); // cancels event and keeps dropEffect
+ // as was before event.
+ }
+
+ function doOnDragStart(aEvent) {
+ var dt = aEvent.dataTransfer;
+ switch (aEvent.currentTarget.id) {
+ case "drag2" :
+ dt.setData("text/plain", "this is text/plain");
+ // fallthrough
+ case "drag1" :
+ regularDtForDrag1 = dt;
+ dt.setData("text/uri-list", "http://www.mozilla.org/");
+ break;
+ case "dragfile" :
+ dt.mozSetDataAt("application/x-moz-file", testFile, 0);
+ break;
+ }
+ dt.effectAllowed = "all";
+ }
+
+ function doOnDragEnter(aEvent) {
+ gEnter = true;
+ aEvent.dataTransfer.effectAllowed = "all";
+ aEvent.preventDefault(); // sets target this element
+ }
+
+ function doOnDragOver(aEvent) {
+ gOver = true;
+ if (gSetDropEffect)
+ aEvent.dataTransfer.dropEffect = "copy";
+ aEvent.preventDefault();
+ }
+
+ SimpleTest.waitForExplicitFinish();
+ function test() {
+ var startTime = new Date();
+ var result;
+
+ /* test synthesizeDrop */
+ result = synthesizeDrop($("dragDrop"), $("dragDrop"), dragDrop, null, window);
+ ok(gEnter, "Fired dragenter");
+ ok(gOver, "Fired dragover");
+ is(result, "copy", "copy is dropEffect");
+ is(gData, dragDrop[0][0].data, "Received valid drop data");
+
+ gSetDropEffect = false;
+ result = synthesizeDrop($("dragDrop"), $("dragDrop"), dragDrop, "link", window);
+ is(result, "link", "link is dropEffect");
+ gSetDropEffect = true;
+
+ $("textB").focus();
+ var content = synthesizeQueryTextContent(0, 100);
+ ok(content, "synthesizeQueryTextContent should not be null");
+ ok(content.succeeded, "synthesizeQueryTextContent should succeed");
+ is(content.text, "I haz a content", "synthesizeQueryTextContent should be 'I haz a content': " + content.text);
+
+ content = synthesizeQueryCaretRect(0);
+ ok(content, "synthesizeQueryCaretRect should not be null");
+ ok(content.succeeded, "synthesizeQueryCaretRect should succeed");
+
+ content = synthesizeQueryTextRect(0, 100);
+ ok(content, "synthesizeQueryTextRect should not be null");
+ ok(content.succeeded, "synthesizeQueryTextRect should succeed");
+
+ content = synthesizeQueryEditorRect();
+ ok(content, "synthesizeQueryEditorRect should not be null");
+ ok(content.succeeded, "synthesizeQueryEditorRect should succeed");
+
+ content = synthesizeCharAtPoint(0, 0);
+ ok(content, "synthesizeCharAtPoint should not be null");
+ ok(content.succeeded, "synthesizeCharAtPoint should succeed");
+
+ content = synthesizeSelectionSet(0, 100);
+ ok(content, "synthesizeSelectionSet should not be null");
+ is(content, true, "synthesizeSelectionSet should succeed");
+
+ var endTime = new Date();
+ info("\nProfile::EventUtilsRunTime: " + (endTime-startTime) + "\n");
+ SimpleTest.finish();
+ };
+ ]]>
+ </script>
+
+ <body xmlns="http://www.w3.org/1999/xhtml" onload="setTimeout(test, 0)">
+ <input id="textB" value="I haz a content"/>
+ <p id="display"></p>
+ <div id="content" style="display:none;"></div>
+ <pre id="test"></pre>
+ <div id="drag1" ondragstart="doOnDragStart(event);">Need some space here</div>
+ <p id="display"></p>
+ <div id="content" style="display:none;"></div>
+ <pre id="test"></pre>
+ <div id="dragDrop" ondragover ="doOnDragOver(event);"
+ ondragenter ="doOnDragEnter(event);"
+ ondragleave ="doOnDragLeave(event);"
+ ondrop ="doOnDrop(event);">
+ Need some depth and height to drag here
+ </div>
+ <div id="drag2" ondragstart="doOnDragStart(event);">Need more space</div>
+ <div id="dragfile" ondragstart="doOnDragStart(event);">Sure why not here too</div>
+ </body>
+</window>
diff --git a/testing/mochitest/chrome/test_sanityException.xhtml b/testing/mochitest/chrome/test_sanityException.xhtml
new file mode 100644
index 0000000000..198e21a60c
--- /dev/null
+++ b/testing/mochitest/chrome/test_sanityException.xhtml
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=670817
+-->
+<window title="Mozilla Bug 670817"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=670817">Mozilla Bug 670817</a>
+<script type="application/javascript"><![CDATA[
+
+SimpleTest.expectUncaughtException();
+ok(true, "a call to ok");
+// eslint-disable-next-line no-throw-literal
+throw "this is a deliberately thrown exception";
+
+]]></script>
+</body>
+
+</window>
diff --git a/testing/mochitest/chrome/test_sanityException2.xhtml b/testing/mochitest/chrome/test_sanityException2.xhtml
new file mode 100644
index 0000000000..78d97032aa
--- /dev/null
+++ b/testing/mochitest/chrome/test_sanityException2.xhtml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=670817
+-->
+<window title="Mozilla Bug 670817"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=670817">Mozilla Bug 670817</a>
+<script type="application/javascript"><![CDATA[
+
+SimpleTest.waitForExplicitFinish();
+ok(true, "a call to ok");
+SimpleTest.executeSoon(function() {
+ SimpleTest.expectUncaughtException();
+ // eslint-disable-next-line no-throw-literal
+ throw "this is a deliberately thrown exception";
+});
+SimpleTest.executeSoon(function() {
+ SimpleTest.finish();
+});
+
+]]></script>
+</body>
+
+</window>
diff --git a/testing/mochitest/chrome/test_sanityManifest.xhtml b/testing/mochitest/chrome/test_sanityManifest.xhtml
new file mode 100644
index 0000000000..14a1ef543e
--- /dev/null
+++ b/testing/mochitest/chrome/test_sanityManifest.xhtml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=670817
+-->
+<window title="Mozilla Bug 987849"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=987849">Mozilla Bug 987849</a>
+<script type="application/javascript"><![CDATA[
+ok(false, "a call to ok");
+]]></script>
+</body>
+
+</window>
diff --git a/testing/mochitest/chrome/test_sanityManifest_pf.xhtml b/testing/mochitest/chrome/test_sanityManifest_pf.xhtml
new file mode 100644
index 0000000000..0f8c5e0a48
--- /dev/null
+++ b/testing/mochitest/chrome/test_sanityManifest_pf.xhtml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=670817
+-->
+<window title="Mozilla Bug 987849"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+<body xmlns="http://www.w3.org/1999/xhtml">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=987849">Mozilla Bug 987849</a>
+<script type="application/javascript"><![CDATA[
+ok(true, "a true call to ok");
+ok(false, "a false call to ok");
+]]></script>
+</body>
+
+</window>
diff --git a/testing/mochitest/chrome/test_tasks_skip.xhtml b/testing/mochitest/chrome/test_tasks_skip.xhtml
new file mode 100644
index 0000000000..2d321356af
--- /dev/null
+++ b/testing/mochitest/chrome/test_tasks_skip.xhtml
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<window title="Test add_task.skip() function"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript">
+ <![CDATA[
+
+ // Check that we can skip arbitrary tasks by calling `skip()`.
+
+ add_task(async function skipMeNot1() {
+ ok(true, "Well well well.");
+ });
+
+ add_task(async function skipMe1() {
+ ok(false, "Not skipped after all.");
+ }).skip();
+
+ add_task(async function skipMeNot2() {
+ ok(true, "Well well well.");
+ });
+
+ add_task(async function skipMeNot3() {
+ ok(true, "Well well well.");
+ });
+
+ add_task(async function skipMe2() {
+ ok(false, "Not skipped after all.");
+ }).skip();
+
+ ]]>
+ </script>
+ <body xmlns="http://www.w3.org/1999/xhtml" >
+ </body>
+</window>
diff --git a/testing/mochitest/chrome/test_tasks_skipall.xhtml b/testing/mochitest/chrome/test_tasks_skipall.xhtml
new file mode 100644
index 0000000000..40a2fe1a58
--- /dev/null
+++ b/testing/mochitest/chrome/test_tasks_skipall.xhtml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+<window title="Test add_task.only() function"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+ <script type="application/javascript">
+ <![CDATA[
+
+ /* eslint-disable mozilla/reject-addtask-only */
+ // Check that we can skip all but one task by calling `only()`.
+
+ add_task(async function skipMe1() {
+ ok(false, "Not skipped after all.");
+ });
+
+ add_task(async function skipMe2() {
+ ok(false, "Not skipped after all.");
+ }).skip();
+
+ add_task(async function skipMe3() {
+ ok(false, "Not skipped after all.");
+ }).only();
+
+ add_task(async function skipMeNot() {
+ ok(true, "Well well well.");
+ }).only();
+
+ add_task(async function skipMe4() {
+ ok(false, "Not skipped after all.");
+ });
+
+ ]]>
+ </script>
+ <body xmlns="http://www.w3.org/1999/xhtml" >
+ </body>
+</window>