2010-06-16 20:13:20 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Simulates quickly switching between different list views to verify that only
|
|
|
|
// the last selected is displayed
|
|
|
|
|
|
|
|
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm");
|
|
|
|
|
|
|
|
const xpi = "browser/toolkit/mozapps/extensions/test/browser/browser_installssl.xpi";
|
|
|
|
|
|
|
|
var gManagerWindow;
|
2010-07-16 11:17:35 -07:00
|
|
|
var gCategoryUtilities;
|
2010-06-16 20:13:20 -07:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
// Add a lightweight theme so at least one theme exists
|
|
|
|
LightweightThemeManager.currentTheme = {
|
|
|
|
id: "test",
|
|
|
|
name: "Test lightweight theme",
|
|
|
|
headerURL: "http://example.com/header.png"
|
|
|
|
};
|
|
|
|
|
|
|
|
open_manager(null, function(aWindow) {
|
|
|
|
gManagerWindow = aWindow;
|
2010-07-16 11:17:35 -07:00
|
|
|
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
2010-06-16 20:13:20 -07:00
|
|
|
run_next_test();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function end_test() {
|
2010-06-24 12:50:04 -07:00
|
|
|
close_manager(gManagerWindow, function() {
|
|
|
|
LightweightThemeManager.forgetUsedTheme("test");
|
|
|
|
finish();
|
|
|
|
});
|
2010-06-16 20:13:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Tests that loading a second view before the first has not finished loading
|
|
|
|
// does not merge the results
|
|
|
|
add_test(function() {
|
|
|
|
var themeCount = null;
|
|
|
|
var pluginCount = null;
|
2010-07-16 11:17:35 -07:00
|
|
|
var themeItem = gCategoryUtilities.get("theme");
|
|
|
|
var pluginItem = gCategoryUtilities.get("plugin");
|
2010-06-16 20:13:20 -07:00
|
|
|
var list = gManagerWindow.document.getElementById("addon-list");
|
|
|
|
|
2010-07-16 11:17:35 -07:00
|
|
|
gCategoryUtilities.open(themeItem, function() {
|
2010-06-16 20:13:20 -07:00
|
|
|
themeCount = list.childNodes.length;
|
|
|
|
ok(themeCount > 0, "Test is useless if there are no themes");
|
|
|
|
|
2010-07-16 11:17:35 -07:00
|
|
|
gCategoryUtilities.open(pluginItem, function() {
|
2010-06-16 20:13:20 -07:00
|
|
|
pluginCount = list.childNodes.length;
|
|
|
|
ok(pluginCount > 0, "Test is useless if there are no plugins");
|
|
|
|
|
2010-07-16 11:17:35 -07:00
|
|
|
gCategoryUtilities.open(themeItem);
|
2010-06-16 20:13:20 -07:00
|
|
|
|
2010-07-16 11:17:35 -07:00
|
|
|
gCategoryUtilities.open(pluginItem, function() {
|
2010-06-16 20:13:20 -07:00
|
|
|
is(list.childNodes.length, pluginCount, "Should only see the plugins");
|
|
|
|
|
|
|
|
var item = list.firstChild;
|
|
|
|
while (item) {
|
|
|
|
is(item.getAttribute("type"), "plugin", "All items should be plugins");
|
|
|
|
item = item.nextSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tests that switching to, from, to the same pane in quick succession
|
|
|
|
// still only shows the right number of results
|
|
|
|
|
2010-07-16 11:17:35 -07:00
|
|
|
gCategoryUtilities.open(themeItem);
|
|
|
|
gCategoryUtilities.open(pluginItem);
|
|
|
|
gCategoryUtilities.open(themeItem, function() {
|
2010-06-16 20:13:20 -07:00
|
|
|
is(list.childNodes.length, themeCount, "Should only see the theme");
|
|
|
|
|
|
|
|
var item = list.firstChild;
|
|
|
|
while (item) {
|
|
|
|
is(item.getAttribute("type"), "theme", "All items should be theme");
|
|
|
|
item = item.nextSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
run_next_test();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|