Bug 623750: browser_bug596336.js cannot run by itself. r=Unfocused, a=tests

This commit is contained in:
Dave Townsend 2011-01-06 15:45:25 -08:00
parent 8f61f2c5d1
commit c35b10906d
3 changed files with 47 additions and 46 deletions

View File

@ -16,7 +16,7 @@ var gContextMenu;
function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
@ -68,7 +68,7 @@ function check_contextmenu(aIsTheme, aIsEnabled, aIsRemote, aIsDetails, aIsSingl
else
is_element_visible(gManagerWindow.document.getElementById("menuitem_enableItem"),
"'Enable' should be visible");
if (aIsTheme || !aIsEnabled || aIsRemote)
is_element_hidden(gManagerWindow.document.getElementById("menuitem_disableItem"),
"'Disable' should be hidden");
@ -82,7 +82,7 @@ function check_contextmenu(aIsTheme, aIsEnabled, aIsRemote, aIsDetails, aIsSingl
else
is_element_visible(gManagerWindow.document.getElementById("menuitem_enableTheme"),
"'Wear Theme' should be visible");
if (!aIsTheme || !aIsEnabled || aIsRemote || aIsSingleItemCase)
is_element_hidden(gManagerWindow.document.getElementById("menuitem_disableTheme"),
"'Stop Wearing Theme' should be hidden");
@ -96,19 +96,19 @@ function check_contextmenu(aIsTheme, aIsEnabled, aIsRemote, aIsDetails, aIsSingl
else
is_element_hidden(gManagerWindow.document.getElementById("menuitem_installItem"),
"'Install' should be hidden");
if (aIsDetails)
is_element_hidden(gManagerWindow.document.getElementById("menuitem_showDetails"),
is_element_hidden(gManagerWindow.document.getElementById("menuitem_showDetails"),
"'Show More Information' should be hidden in details view");
else
is_element_visible(gManagerWindow.document.getElementById("menuitem_showDetails"),
is_element_visible(gManagerWindow.document.getElementById("menuitem_showDetails"),
"'Show More Information' should be visible in list view");
if (aIsSingleItemCase)
is_element_hidden(gManagerWindow.document.getElementById("addonitem-menuseparator"),
is_element_hidden(gManagerWindow.document.getElementById("addonitem-menuseparator"),
"Menu separator should be hidden with only one menu item");
else
is_element_visible(gManagerWindow.document.getElementById("addonitem-menuseparator"),
is_element_visible(gManagerWindow.document.getElementById("addonitem-menuseparator"),
"Menu separator should be visible with multiple menu items");
}
@ -155,16 +155,16 @@ add_test(function() {
gManagerWindow.loadView("addons://list/theme");
wait_for_view_load(gManagerWindow, function() {
var el = get_addon_element(gManagerWindow, "theme1@tests.mozilla.org");
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(true, true, false, false, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on enabled theme item");
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
@ -193,12 +193,12 @@ add_test(function() {
add_test(function() {
gManagerWindow.loadView("addons://detail/addon1@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, true, false, true, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
@ -214,12 +214,12 @@ add_test(function() {
add_test(function() {
gManagerWindow.loadView("addons://detail/addon2@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, false, false, true, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
@ -235,12 +235,12 @@ add_test(function() {
add_test(function() {
gManagerWindow.loadView("addons://detail/theme1@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(true, true, false, true, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
@ -256,12 +256,12 @@ add_test(function() {
add_test(function() {
gManagerWindow.loadView("addons://detail/theme2@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(true, false, false, true, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
@ -276,12 +276,12 @@ add_test(function() {
add_test(function() {
gManagerWindow.loadView("addons://detail/theme3@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(true, true, false, true, true);
gContextMenu.hidePopup();
run_next_test();
}, false);
@ -309,22 +309,22 @@ add_test(function() {
var filter = gManagerWindow.document.getElementById("search-filter-remote");
EventUtils.synthesizeMouseAtCenter(filter, { }, gManagerWindow);
executeSoon(function() {
var el = get_addon_element(gManagerWindow, "remote1@tests.mozilla.org");
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, false, true, false, false);
gContextMenu.hidePopup();
run_next_test();
}, false);
info("Opening context menu on remote extension item");
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
});
});
});
@ -333,14 +333,21 @@ add_test(function() {
add_test(function() {
gManagerWindow.loadView("addons://detail/remote1@tests.mozilla.org");
wait_for_view_load(gManagerWindow, function() {
gContextMenu.addEventListener("popupshown", function() {
gContextMenu.removeEventListener("popupshown", arguments.callee, false);
check_contextmenu(false, false, true, true, false);
gContextMenu.hidePopup();
run_next_test();
// Delete the created install
AddonManager.getAllInstalls(function(aInstalls) {
is(aInstalls.length, 1, "Should be one available install");
aInstalls[0].cancel();
run_next_test();
});
}, false);
info("Opening context menu on remote extension, in detail view");

View File

@ -19,13 +19,7 @@ function test() {
}
function end_test() {
// 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);
});
close_manager(gManagerWindow, finish);
}
function get_list_item_count() {

View File

@ -472,7 +472,7 @@ MockProvider.prototype = {
addons: null,
installs: null,
started: null,
apiDelay: 100,
apiDelay: 10,
callbackTimers: null,
useAsyncCallbacks: null,