1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/browser/browser_bug562899.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +// Simulates quickly switching between different list views to verify that only 1.9 +// the last selected is displayed 1.10 + 1.11 +let tempScope = {}; 1.12 +Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", tempScope); 1.13 +let LightweightThemeManager = tempScope.LightweightThemeManager; 1.14 + 1.15 +const xpi = "browser/toolkit/mozapps/extensions/test/browser/browser_installssl.xpi"; 1.16 + 1.17 +var gManagerWindow; 1.18 +var gCategoryUtilities; 1.19 + 1.20 +function test() { 1.21 + waitForExplicitFinish(); 1.22 + 1.23 + // Add a lightweight theme so at least one theme exists 1.24 + LightweightThemeManager.currentTheme = { 1.25 + id: "test", 1.26 + name: "Test lightweight theme", 1.27 + headerURL: "http://example.com/header.png" 1.28 + }; 1.29 + 1.30 + open_manager(null, function(aWindow) { 1.31 + gManagerWindow = aWindow; 1.32 + gCategoryUtilities = new CategoryUtilities(gManagerWindow); 1.33 + run_next_test(); 1.34 + }); 1.35 +} 1.36 + 1.37 +function end_test() { 1.38 + close_manager(gManagerWindow, function() { 1.39 + LightweightThemeManager.forgetUsedTheme("test"); 1.40 + finish(); 1.41 + }); 1.42 +} 1.43 + 1.44 +// Tests that loading a second view before the first has not finished loading 1.45 +// does not merge the results 1.46 +add_test(function() { 1.47 + var themeCount = null; 1.48 + var pluginCount = null; 1.49 + var themeItem = gCategoryUtilities.get("theme"); 1.50 + var pluginItem = gCategoryUtilities.get("plugin"); 1.51 + var list = gManagerWindow.document.getElementById("addon-list"); 1.52 + 1.53 + gCategoryUtilities.open(themeItem, function() { 1.54 + themeCount = list.childNodes.length; 1.55 + ok(themeCount > 0, "Test is useless if there are no themes"); 1.56 + 1.57 + gCategoryUtilities.open(pluginItem, function() { 1.58 + pluginCount = list.childNodes.length; 1.59 + ok(pluginCount > 0, "Test is useless if there are no plugins"); 1.60 + 1.61 + gCategoryUtilities.open(themeItem); 1.62 + 1.63 + gCategoryUtilities.open(pluginItem, function() { 1.64 + is(list.childNodes.length, pluginCount, "Should only see the plugins"); 1.65 + 1.66 + var item = list.firstChild; 1.67 + while (item) { 1.68 + is(item.getAttribute("type"), "plugin", "All items should be plugins"); 1.69 + item = item.nextSibling; 1.70 + } 1.71 + 1.72 + // Tests that switching to, from, to the same pane in quick succession 1.73 + // still only shows the right number of results 1.74 + 1.75 + gCategoryUtilities.open(themeItem); 1.76 + gCategoryUtilities.open(pluginItem); 1.77 + gCategoryUtilities.open(themeItem, function() { 1.78 + is(list.childNodes.length, themeCount, "Should only see the theme"); 1.79 + 1.80 + var item = list.firstChild; 1.81 + while (item) { 1.82 + is(item.getAttribute("type"), "theme", "All items should be theme"); 1.83 + item = item.nextSibling; 1.84 + } 1.85 + 1.86 + run_next_test(); 1.87 + }); 1.88 + }); 1.89 + }); 1.90 + }); 1.91 +});