summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/content-tabs/browser_addonsMgr.js
blob: 411ddb362de154b55b7d2d08ce40037f6ecb19bb (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

var { content_tab_e, wait_for_content_tab_load } = ChromeUtils.import(
  "resource://testing-common/mozmill/ContentTabHelpers.jsm"
);
var { mc } = ChromeUtils.import(
  "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);
var {
  click_through_appmenu,
  plan_for_modal_dialog,
  wait_for_browser_load,
  wait_for_modal_dialog,
  wait_for_window_close,
} = ChromeUtils.import("resource://testing-common/mozmill/WindowHelpers.jsm");

add_task(async function test_open_addons_with_url() {
  mc.window.openAddonsMgr("addons://list/theme");
  await new Promise(resolve => setTimeout(resolve));

  let tab = mc.window.document.getElementById("tabmail").currentTabInfo;
  wait_for_content_tab_load(tab, "about:addons", 10000);
  let categoriesBox = tab.browser.contentDocument.getElementById("categories");
  Assert.equal(
    categoriesBox.selectedChild.getAttribute("viewid"),
    "addons://list/theme",
    "Themes category should be selected!"
  );

  mc.window.document.getElementById("tabmail").switchToTab(0); // switch to 3pane
  mc.window.document.getElementById("tabmail").closeTab(tab);
});

/**
 * Bug 1462923
 * Check if the "Tools->Add-on Options" menu item works and shows our add-on.
 * This relies on the MozMill extension having optionsURL defined in install.rdf,
 * however simplistic the preferences XUL document may be.
 */
add_task(function test_addon_prefs() {
  // Open Add-on Options.
  const subview = click_through_appmenu(
    [{ id: "appmenu_addons" }],
    null,
    mc.window
  );

  plan_for_modal_dialog("mozmill-prefs", function (controller) {
    // Add | await new Promise(resolve => setTimeout(resolve, 1000));|
    // here to see the popup dialog.
    controller.window.close();
  });

  // MozMill add-on should be somewhere in the list. When found, click it.
  let foundAddon = false;
  for (let item of subview.children) {
    if (
      item.tagName == "toolbarbutton" &&
      item.getAttribute("collapsed") != "true" &&
      item.label == "MozMill"
    ) {
      foundAddon = true;
      EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, mc.window);
      break;
    }
  }
  Assert.ok(foundAddon);

  // Wait for the options dialog to open and close.
  wait_for_modal_dialog();
  wait_for_window_close();
}).skip();