summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/browser/browser_sidebar_restore_category.js
blob: 4c5b1e25f0cc84d74e25a249907ac3f882bf4c99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

// Test that the selected category is persisted across loads of the manager

add_task(async function testCategoryRestore() {
  let win = await loadInitialView("extension");
  let utils = new CategoryUtilities(win);

  // Open the plugins category
  await utils.openType("plugin");

  // Re-open the manager
  await closeView(win);
  win = await loadInitialView();
  utils = new CategoryUtilities(win);

  is(
    utils.selectedCategory,
    "plugin",
    "Should have shown the plugins category"
  );

  // Open the extensions category
  await utils.openType("extension");

  // Re-open the manager
  await closeView(win);
  win = await loadInitialView();
  utils = new CategoryUtilities(win);

  is(
    utils.selectedCategory,
    "extension",
    "Should have shown the extensions category"
  );

  await closeView(win);
});

add_task(async function testInvalidAddonType() {
  let win = await loadInitialView("invalid");

  let categoryUtils = new CategoryUtilities(win);
  is(
    categoryUtils.getSelectedViewId(),
    win.gViewController.defaultViewId,
    "default view is selected"
  );
  is(
    win.gViewController.currentViewId,
    win.gViewController.defaultViewId,
    "default view is shown"
  );

  await closeView(win);
});

add_task(async function testInvalidViewId() {
  let win = await loadInitialView("addons://invalid/view");

  let categoryUtils = new CategoryUtilities(win);
  is(
    categoryUtils.getSelectedViewId(),
    win.gViewController.defaultViewId,
    "default view is selected"
  );
  is(
    win.gViewController.currentViewId,
    win.gViewController.defaultViewId,
    "default view is shown"
  );

  await closeView(win);
});