зеркало из https://github.com/mozilla/gecko-dev.git
Bug 605499: Tests for showing EULA for extension installs. r=Unfocused, a=tests
This commit is contained in:
Родитель
847d5f59c1
Коммит
a71c6c9372
|
@ -84,6 +84,8 @@ _TEST_FILES = \
|
|||
browser_recentupdates.js \
|
||||
browser_manualupdates.js \
|
||||
browser_globalwarnings.js \
|
||||
browser_eula.js \
|
||||
browser_eula.xml \
|
||||
redirect.sjs \
|
||||
releaseNotes.xhtml \
|
||||
$(NULL)
|
||||
|
|
|
@ -32,7 +32,14 @@ function test() {
|
|||
function end_test() {
|
||||
Services.prefs.clearUserPref("extensions.update.url");
|
||||
|
||||
// Test generates a lot of available installs so just cancel them all
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
aInstalls.forEach(function(aInstall) {
|
||||
aInstall.cancel();
|
||||
});
|
||||
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
function install_test_addons(aCallback) {
|
||||
|
|
|
@ -28,7 +28,15 @@ function test() {
|
|||
|
||||
function end_test() {
|
||||
Services.prefs.clearUserPref(PREF_GETADDONS_GETSEARCHRESULTS);
|
||||
|
||||
// Test generates a lot of available installs so just cancel them all
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
aInstalls.forEach(function(aInstall) {
|
||||
aInstall.cancel();
|
||||
});
|
||||
|
||||
close_manager(gManagerWindow, finish);
|
||||
});
|
||||
}
|
||||
|
||||
function search(aRemoteSearch, aCallback) {
|
||||
|
|
|
@ -19,8 +19,12 @@ function test() {
|
|||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, function() {
|
||||
finish();
|
||||
// Test generates an available installs so just cancel it
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
is(aInstalls.length, 1, "Should be one available install");
|
||||
aInstalls[0].cancel();
|
||||
|
||||
close_manager(gManagerWindow, finish);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/* 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, function() {
|
||||
Services.prefs.clearUserPref("extensions.getAddons.search.url");
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="1">
|
||||
<addon>
|
||||
<name>Install Tests</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>addon1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test add-on</summary>
|
||||
<description>Test add-on</description>
|
||||
<eula>This is the EULA for this add-on</eula>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="2">http://example.com/browser/toolkit/mozapps/extensions/test/browser/addons/browser_install1_2.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
|
@ -34,9 +34,9 @@ function end_test() {
|
|||
|
||||
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
|
||||
aAddon.uninstall();
|
||||
});
|
||||
finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function get_node(parent, anonid) {
|
||||
|
|
|
@ -41,6 +41,18 @@ registerCleanupFunction(function() {
|
|||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
||||
// We can for now know that getAllInstalls actually calls its callback before
|
||||
// it returns so this will complete before the next test start.
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
aInstalls.forEach(function(aInstall) {
|
||||
if (aInstall instanceof MockInstall)
|
||||
return;
|
||||
|
||||
ok(false, "Should not have seen an install of " + aInstall.sourceURI.spec + " in state " + aInstall.state);
|
||||
aInstall.cancel();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function add_test(test) {
|
||||
|
@ -232,6 +244,29 @@ function restart_manager(aManagerWindow, aView, aCallback, aLoadCallback) {
|
|||
});
|
||||
}
|
||||
|
||||
function wait_for_window_open(aCallback) {
|
||||
Services.wm.addListener({
|
||||
onOpenWindow: function(aWindow) {
|
||||
Services.wm.removeListener(this);
|
||||
|
||||
let domwindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowInternal);
|
||||
domwindow.addEventListener("load", function() {
|
||||
domwindow.removeEventListener("load", arguments.callee, false);
|
||||
executeSoon(function() {
|
||||
aCallback(domwindow);
|
||||
});
|
||||
}, false);
|
||||
},
|
||||
|
||||
onCloseWindow: function(aWindow) {
|
||||
},
|
||||
|
||||
onWindowTitleChange: function(aWindow, aTitle) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function is_hidden(aElement) {
|
||||
var style = aElement.ownerDocument.defaultView.getComputedStyle(aElement, "");
|
||||
if (style.display == "none")
|
||||
|
|
Загрузка…
Ссылка в новой задаче