diff options
Diffstat (limited to 'toolkit/mozapps/extensions/test/mochitest')
5 files changed, 95 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/mochitest/chrome.ini b/toolkit/mozapps/extensions/test/mochitest/chrome.ini new file mode 100644 index 0000000000..a8a8d49e3c --- /dev/null +++ b/toolkit/mozapps/extensions/test/mochitest/chrome.ini @@ -0,0 +1,2 @@ + +[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.ini b/toolkit/mozapps/extensions/test/mochitest/mochitest.ini new file mode 100644 index 0000000000..82799c0776 --- /dev/null +++ b/toolkit/mozapps/extensions/test/mochitest/mochitest.ini @@ -0,0 +1,5 @@ +[DEFAULT] +support-files = + file_empty.html + +[test_bug887098.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..45cf1a9bb5 --- /dev/null +++ b/toolkit/mozapps/extensions/test/mochitest/test_bug887098.html @@ -0,0 +1,53 @@ +<!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 */ + + function loaded() { + 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..3896b22032 --- /dev/null +++ b/toolkit/mozapps/extensions/test/mochitest/test_default_theme.html @@ -0,0 +1,33 @@ +<!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.import("resource://gre/modules/AddonManager.jsm"); +const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); + +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> |