summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/webextensions/test/browser/browser_eula.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-10 02:49:12 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-10 02:49:12 -0500
commit4fb11cd5966461bccc3ed1599b808237be6b0de9 (patch)
treed7f0ccd49cebb3544d52635ff1bd6ed4d763823f /toolkit/mozapps/webextensions/test/browser/browser_eula.js
parentf164d9124708b50789dbb6959e1de96cc5697c48 (diff)
downloadUXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar
UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar.gz
UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar.lz
UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar.xz
UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.zip
Move WebExtensions enabled Add-ons Manager
Diffstat (limited to 'toolkit/mozapps/webextensions/test/browser/browser_eula.js')
-rw-r--r--toolkit/mozapps/webextensions/test/browser/browser_eula.js85
1 files changed, 85 insertions, 0 deletions
diff --git a/toolkit/mozapps/webextensions/test/browser/browser_eula.js b/toolkit/mozapps/webextensions/test/browser/browser_eula.js
new file mode 100644
index 000000000..befe9f1f2
--- /dev/null
+++ b/toolkit/mozapps/webextensions/test/browser/browser_eula.js
@@ -0,0 +1,85 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Tests that the eula is shown correctly for search results
+
+var gManagerWindow;
+var gCategoryUtilities;
+
+var gApp = document.getElementById("bundle_brand").getString("brandShortName");
+var gSearchCount = 0;
+
+function test() {
+ requestLongerTimeout(2);
+ waitForExplicitFinish();
+
+ // Turn on searching for this test
+ Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
+ Services.prefs.setCharPref("extensions.getAddons.search.url", TESTROOT + "browser_eula.xml");
+
+ open_manager(null, function(aWindow) {
+ gManagerWindow = aWindow;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ run_next_test();
+ });
+}
+
+function end_test() {
+ close_manager(gManagerWindow, finish);
+}
+
+function get_node(parent, anonid) {
+ return parent.ownerDocument.getAnonymousElementByAttribute(parent, "anonid", anonid);
+}
+
+function installSearchResult(aCallback) {
+ var searchBox = gManagerWindow.document.getElementById("header-search");
+ // Search for something different each time
+ searchBox.value = "foo" + gSearchCount;
+ gSearchCount++;
+
+ EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
+ EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
+
+ wait_for_view_load(gManagerWindow, function() {
+ let remote = gManagerWindow.document.getElementById("search-filter-remote")
+ EventUtils.synthesizeMouseAtCenter(remote, { }, gManagerWindow);
+
+ let item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
+ ok(!!item, "Should see the search result in the list");
+
+ let status = get_node(item, "install-status");
+ EventUtils.synthesizeMouseAtCenter(get_node(status, "install-remote-btn"), {}, gManagerWindow);
+
+ item.mInstall.addListener({
+ onInstallEnded: function() {
+ executeSoon(aCallback);
+ }
+ });
+ });
+}
+
+// Install an add-on through the search page, accept the EULA and then undo it
+add_test(function() {
+ // Accept the EULA when it appears
+ let sawEULA = false;
+ wait_for_window_open(function(aWindow) {
+ sawEULA = true;
+ is(aWindow.location.href, "chrome://mozapps/content/extensions/eula.xul", "Window opened should be correct");
+ is(aWindow.document.getElementById("eula").value, "This is the EULA for this add-on", "EULA should be correct");
+
+ aWindow.document.documentElement.acceptDialog();
+ });
+
+ installSearchResult(function() {
+ ok(sawEULA, "Should have seen the EULA");
+
+ AddonManager.getAllInstalls(function(aInstalls) {
+ is(aInstalls.length, 1, "Should be one pending install");
+ aInstalls[0].cancel();
+
+ run_next_test();
+ });
+ });
+});