Bug 1398908 - Add automated test that uses nonexistent script from extension JAR file. r=mixedpuppy draft
authorHaik Aftandilian <haftandilian@mozilla.com>
Tue, 03 Oct 2017 16:09:03 -0700
changeset 682127 dcc2aba616106685b167f954097cfd192515742d
parent 681976 5f569491165bd827dfe5fcc4e057e6b1ef79b8c6
child 736309 47a63bc1cd5577ad4b03ec3580261a203b5b7a24
push id85011
push userhaftandilian@mozilla.com
push dateWed, 18 Oct 2017 05:09:47 +0000
reviewersmixedpuppy
bugs1398908
milestone58.0a1
Bug 1398908 - Add automated test that uses nonexistent script from extension JAR file. r=mixedpuppy MozReview-Commit-ID: DbZ3JuFm770
toolkit/components/extensions/test/xpcshell/test_ext_brokenlinks.js
toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_brokenlinks.js
@@ -0,0 +1,55 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+/*
+ * This test extension has a background script 'missing.js' that is missing
+ * from the XPI. Such an extension should install/uninstall cleanly without
+ * causing timeouts.
+ */
+add_task(async function testXPIMissingBackGroundScript() {
+  let extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      "background": {
+        "scripts": ["missing.js"],
+        "persistent": false,
+      },
+    },
+  });
+
+  await extension.startup();
+  await extension.unload();
+  ok(true, "load/unload completed without timing out");
+});
+
+/*
+ * This test extension includes a page with a missing script. The
+ * extension should install/uninstall cleanly without causing hangs.
+ */
+add_task(async function testXPIMissingPageScript() {
+  async function pageScript() {
+    browser.test.sendMessage("pageReady");
+  }
+
+  let extension = ExtensionTestUtils.loadExtension({
+    background() {
+      browser.test.sendMessage("ready", browser.runtime.getURL("page.html"));
+    },
+    files: {
+      "page.html": `<html><head>
+                    <script src="missing.js"></script>
+                    <script src="page.js"></script>
+                    </head></html>`,
+      "page.js": pageScript,
+    },
+  });
+
+  await extension.startup();
+  let url = await extension.awaitMessage("ready");
+  let contentPage = await ExtensionTestUtils.loadContentPage(url);
+  await extension.awaitMessage("pageReady");
+  await extension.unload();
+  await contentPage.close();
+
+  ok(true, "load/unload completed without timing out");
+});
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
@@ -77,8 +77,9 @@ skip-if = os == "android"
 [test_native_manifests.js]
 subprocess = true
 skip-if = os == "android"
 [test_ext_permissions.js]
 skip-if = os == "android" # Bug 1350559
 [test_proxy_scripts.js]
 skip-if = os == "linux" # bug 1393940
 [test_proxy_scripts_results.js]
+[test_ext_brokenlinks.js]