summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/mochitest
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/extensions/test/mochitest')
-rw-r--r--toolkit/mozapps/extensions/test/mochitest/chrome.toml3
-rw-r--r--toolkit/mozapps/extensions/test/mochitest/file_empty.html2
-rw-r--r--toolkit/mozapps/extensions/test/mochitest/mochitest.toml6
-rw-r--r--toolkit/mozapps/extensions/test/mochitest/test_blocklist_gfx_initialized.html31
-rw-r--r--toolkit/mozapps/extensions/test/mochitest/test_bug887098.html70
-rw-r--r--toolkit/mozapps/extensions/test/mochitest/test_default_theme.html37
6 files changed, 149 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/mochitest/chrome.toml b/toolkit/mozapps/extensions/test/mochitest/chrome.toml
new file mode 100644
index 0000000000..607667ee57
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/mochitest/chrome.toml
@@ -0,0 +1,3 @@
+[DEFAULT]
+
+["test_default_theme.html"]
diff --git a/toolkit/mozapps/extensions/test/mochitest/file_empty.html b/toolkit/mozapps/extensions/test/mochitest/file_empty.html
new file mode 100644
index 0000000000..b6c8a53b41
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/mochitest/file_empty.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<html><head></head><body><span id="text">Nothing to see here</span></body></html>
diff --git a/toolkit/mozapps/extensions/test/mochitest/mochitest.toml b/toolkit/mozapps/extensions/test/mochitest/mochitest.toml
new file mode 100644
index 0000000000..9567d51802
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/mochitest/mochitest.toml
@@ -0,0 +1,6 @@
+[DEFAULT]
+support-files = ["file_empty.html"]
+
+["test_blocklist_gfx_initialized.html"]
+
+["test_bug887098.html"]
diff --git a/toolkit/mozapps/extensions/test/mochitest/test_blocklist_gfx_initialized.html b/toolkit/mozapps/extensions/test/mochitest/test_blocklist_gfx_initialized.html
new file mode 100644
index 0000000000..3800df3f69
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/mochitest/test_blocklist_gfx_initialized.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test gfx blocklist is initialized</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+add_task(async function check_GfxBlocklistRS_initialized() {
+ // We have extensive xpcshell tests to ensure the blocklist works
+ // correctly. Here we just want to ensure the blocklist is indeed
+ // initialized in a regular browser setup.
+ // In fact, calling GfxBlocklistRS.checkForEntries() in order to test
+ // specific functionality would lazily initialize the blocklist, negating
+ // the value of this test.
+ let initialized = await SpecialPowers.spawnChrome([], async () => {
+ const { BlocklistPrivate } = ChromeUtils.importESModule(
+ "resource://gre/modules/Blocklist.sys.mjs"
+ );
+
+ return BlocklistPrivate.GfxBlocklistRS._initialized;
+ });
+
+ ok(initialized, "Gfx Blocklist was initialized")
+});
+ </script>
+</head>
+<body>
+</body>
+</html>
diff --git a/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html b/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html
new file mode 100644
index 0000000000..acf646bd3c
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=887098
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 887098</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+ /* exported loaded */
+
+ /** Test for Bug 887098 **/
+ SimpleTest.waitForExplicitFinish();
+ /* globals $,evalRef */
+
+ async function loaded() {
+ if (!SpecialPowers.Services.prefs.getBoolPref("extensions.InstallTrigger.enabled") ||
+ !SpecialPowers.Services.prefs.getBoolPref("extensions.InstallTriggerImpl.enabled")) {
+ ok(true, "InstallTrigger is not enabled");
+ SimpleTest.finish();
+ return;
+ }
+
+ await SpecialPowers.pushPrefEnv({
+ set: [
+ // Bug 1703215: Using SpecialPowers causes about:mozilla to be loaded in the wrong
+ // process, hence we have to flip the pref and don't enforce IPC based Principal Vetting.
+ ["dom.security.enforceIPCBasedPrincipalVetting", false],
+ // Relax the user input requirements while running this test.
+ ["xpinstall.userActivation.required", false],
+ ],
+ });
+
+ var iwin = $("ifr").contentWindow;
+ var href = SpecialPowers.wrap(iwin).location.href;
+ if (/file_empty/.test(href)) {
+ window.evalRef = iwin.eval;
+ window.installTriggerRef = iwin.InstallTrigger; // Force lazy instantiation.
+ // about:mozilla is privileged, so we need to be privileged to load it.
+ SpecialPowers.wrap(iwin).location.href = "about:mozilla";
+ } else {
+ is(href, "about:mozilla", "Successfully navigated to about:mozilla");
+ try {
+ evalRef('InstallTrigger.install({URL: "chrome://global/skin/global.css"});');
+ ok(false, "Should have thrown when trying to install restricted URI from InstallTrigger");
+ } catch (e) {
+ // XXXgijs this test broke because of the switch to webidl. I'm told
+ // it has to do with compartments and the fact that we eval in "about:mozilla".
+ // Tracking in bug 1007671
+ todo(/permission/.test(e), "We should throw a security exception. Got: " + e);
+ }
+ SimpleTest.finish();
+ }
+ }
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=887098">Mozilla Bug 887098</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<iframe onload="loaded();" id="ifr" src="file_empty.html"></iframe>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/toolkit/mozapps/extensions/test/mochitest/test_default_theme.html b/toolkit/mozapps/extensions/test/mochitest/test_default_theme.html
new file mode 100644
index 0000000000..9b48c7136c
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/mochitest/test_default_theme.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test for correct installation of default theme</title>
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
+ <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css">
+</head>
+<body>
+
+<script>
+"use strict";
+
+const {AddonManager} = ChromeUtils.importESModule(
+ "resource://gre/modules/AddonManager.sys.mjs"
+);
+const {AppConstants} = ChromeUtils.importESModule(
+ "resource://gre/modules/AppConstants.sys.mjs"
+);
+
+add_task(async function() {
+ let addon = await AddonManager.getAddonByID("default-theme@mozilla.org");
+
+ // Dev edition uses a different default theme on desktop.
+ const expectActive = (!AppConstants.MOZ_DEV_EDITION ||
+ AppConstants.MOZ_BUILD_APP !== "browser");
+
+ ok(addon != null, "Default theme exists");
+ is(addon.type, "theme", "Add-on type is correct");
+ is(addon.isActive, expectActive, "Add-on is active?");
+ is(addon.hidden, false, "Add-on is not hidden");
+});
+
+</script>
+</body>
+</html>