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.

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

mercurial