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