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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial