toolkit/mozapps/extensions/test/browser/browser_bug562899.js

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 3 */
michael@0 4
michael@0 5 // Simulates quickly switching between different list views to verify that only
michael@0 6 // the last selected is displayed
michael@0 7
michael@0 8 let tempScope = {};
michael@0 9 Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", tempScope);
michael@0 10 let LightweightThemeManager = tempScope.LightweightThemeManager;
michael@0 11
michael@0 12 const xpi = "browser/toolkit/mozapps/extensions/test/browser/browser_installssl.xpi";
michael@0 13
michael@0 14 var gManagerWindow;
michael@0 15 var gCategoryUtilities;
michael@0 16
michael@0 17 function test() {
michael@0 18 waitForExplicitFinish();
michael@0 19
michael@0 20 // Add a lightweight theme so at least one theme exists
michael@0 21 LightweightThemeManager.currentTheme = {
michael@0 22 id: "test",
michael@0 23 name: "Test lightweight theme",
michael@0 24 headerURL: "http://example.com/header.png"
michael@0 25 };
michael@0 26
michael@0 27 open_manager(null, function(aWindow) {
michael@0 28 gManagerWindow = aWindow;
michael@0 29 gCategoryUtilities = new CategoryUtilities(gManagerWindow);
michael@0 30 run_next_test();
michael@0 31 });
michael@0 32 }
michael@0 33
michael@0 34 function end_test() {
michael@0 35 close_manager(gManagerWindow, function() {
michael@0 36 LightweightThemeManager.forgetUsedTheme("test");
michael@0 37 finish();
michael@0 38 });
michael@0 39 }
michael@0 40
michael@0 41 // Tests that loading a second view before the first has not finished loading
michael@0 42 // does not merge the results
michael@0 43 add_test(function() {
michael@0 44 var themeCount = null;
michael@0 45 var pluginCount = null;
michael@0 46 var themeItem = gCategoryUtilities.get("theme");
michael@0 47 var pluginItem = gCategoryUtilities.get("plugin");
michael@0 48 var list = gManagerWindow.document.getElementById("addon-list");
michael@0 49
michael@0 50 gCategoryUtilities.open(themeItem, function() {
michael@0 51 themeCount = list.childNodes.length;
michael@0 52 ok(themeCount > 0, "Test is useless if there are no themes");
michael@0 53
michael@0 54 gCategoryUtilities.open(pluginItem, function() {
michael@0 55 pluginCount = list.childNodes.length;
michael@0 56 ok(pluginCount > 0, "Test is useless if there are no plugins");
michael@0 57
michael@0 58 gCategoryUtilities.open(themeItem);
michael@0 59
michael@0 60 gCategoryUtilities.open(pluginItem, function() {
michael@0 61 is(list.childNodes.length, pluginCount, "Should only see the plugins");
michael@0 62
michael@0 63 var item = list.firstChild;
michael@0 64 while (item) {
michael@0 65 is(item.getAttribute("type"), "plugin", "All items should be plugins");
michael@0 66 item = item.nextSibling;
michael@0 67 }
michael@0 68
michael@0 69 // Tests that switching to, from, to the same pane in quick succession
michael@0 70 // still only shows the right number of results
michael@0 71
michael@0 72 gCategoryUtilities.open(themeItem);
michael@0 73 gCategoryUtilities.open(pluginItem);
michael@0 74 gCategoryUtilities.open(themeItem, function() {
michael@0 75 is(list.childNodes.length, themeCount, "Should only see the theme");
michael@0 76
michael@0 77 var item = list.firstChild;
michael@0 78 while (item) {
michael@0 79 is(item.getAttribute("type"), "theme", "All items should be theme");
michael@0 80 item = item.nextSibling;
michael@0 81 }
michael@0 82
michael@0 83 run_next_test();
michael@0 84 });
michael@0 85 });
michael@0 86 });
michael@0 87 });
michael@0 88 });

mercurial