toolkit/mozapps/extensions/test/browser/browser_eula.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 3 */
michael@0 4
michael@0 5 // Tests that the eula is shown correctly for search results
michael@0 6
michael@0 7 var gManagerWindow;
michael@0 8 var gCategoryUtilities;
michael@0 9
michael@0 10 var gApp = document.getElementById("bundle_brand").getString("brandShortName");
michael@0 11 var gSearchCount = 0;
michael@0 12
michael@0 13 function test() {
michael@0 14 requestLongerTimeout(2);
michael@0 15 waitForExplicitFinish();
michael@0 16
michael@0 17 // Turn on searching for this test
michael@0 18 Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
michael@0 19 Services.prefs.setCharPref("extensions.getAddons.search.url", TESTROOT + "browser_eula.xml");
michael@0 20
michael@0 21 open_manager(null, function(aWindow) {
michael@0 22 gManagerWindow = aWindow;
michael@0 23 gCategoryUtilities = new CategoryUtilities(gManagerWindow);
michael@0 24 run_next_test();
michael@0 25 });
michael@0 26 }
michael@0 27
michael@0 28 function end_test() {
michael@0 29 close_manager(gManagerWindow, finish);
michael@0 30 }
michael@0 31
michael@0 32 function get_node(parent, anonid) {
michael@0 33 return parent.ownerDocument.getAnonymousElementByAttribute(parent, "anonid", anonid);
michael@0 34 }
michael@0 35
michael@0 36 function installSearchResult(aCallback) {
michael@0 37 var searchBox = gManagerWindow.document.getElementById("header-search");
michael@0 38 // Search for something different each time
michael@0 39 searchBox.value = "foo" + gSearchCount;
michael@0 40 gSearchCount++;
michael@0 41
michael@0 42 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
michael@0 43 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
michael@0 44
michael@0 45 wait_for_view_load(gManagerWindow, function() {
michael@0 46 let remote = gManagerWindow.document.getElementById("search-filter-remote")
michael@0 47 EventUtils.synthesizeMouseAtCenter(remote, { }, gManagerWindow);
michael@0 48
michael@0 49 let item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
michael@0 50 ok(!!item, "Should see the search result in the list");
michael@0 51
michael@0 52 let status = get_node(item, "install-status");
michael@0 53 EventUtils.synthesizeMouseAtCenter(get_node(status, "install-remote-btn"), {}, gManagerWindow);
michael@0 54
michael@0 55 item.mInstall.addListener({
michael@0 56 onInstallEnded: function() {
michael@0 57 executeSoon(aCallback);
michael@0 58 }
michael@0 59 });
michael@0 60 });
michael@0 61 }
michael@0 62
michael@0 63 // Install an add-on through the search page, accept the EULA and then undo it
michael@0 64 add_test(function() {
michael@0 65 // Accept the EULA when it appears
michael@0 66 let sawEULA = false;
michael@0 67 wait_for_window_open(function(aWindow) {
michael@0 68 sawEULA = true;
michael@0 69 is(aWindow.location.href, "chrome://mozapps/content/extensions/eula.xul", "Window opened should be correct");
michael@0 70 is(aWindow.document.getElementById("eula").value, "This is the EULA for this add-on", "EULA should be correct");
michael@0 71
michael@0 72 aWindow.document.documentElement.acceptDialog();
michael@0 73 });
michael@0 74
michael@0 75 installSearchResult(function() {
michael@0 76 ok(sawEULA, "Should have seen the EULA");
michael@0 77
michael@0 78 AddonManager.getAllInstalls(function(aInstalls) {
michael@0 79 is(aInstalls.length, 1, "Should be one pending install");
michael@0 80 aInstalls[0].cancel();
michael@0 81
michael@0 82 run_next_test();
michael@0 83 });
michael@0 84 });
michael@0 85 });

mercurial