diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
commit | 203eb0f61a09372310a2a8fb57e169cb3f47800b (patch) | |
tree | 8490329d3dae4de3c7ffd127bce1f65fdc009abd /toolkit/mozapps/extensions/test/browser/browser_eula.js | |
parent | e45706ca3acbb6530419433212becc61d5953a2d (diff) | |
parent | 8f6d3dab81c7f8f97ef197e26ab9439b09735b8f (diff) | |
download | UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.gz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.lz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.xz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.zip |
Merge branch 'ext-work'FF_Checkpoint_1
Diffstat (limited to 'toolkit/mozapps/extensions/test/browser/browser_eula.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/browser/browser_eula.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_eula.js b/toolkit/mozapps/extensions/test/browser/browser_eula.js new file mode 100644 index 000000000..befe9f1f2 --- /dev/null +++ b/toolkit/mozapps/extensions/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(); + }); + }); +}); |