summaryrefslogtreecommitdiffstats
path: root/comm/mail/test/browser/shared-modules/PrefTabHelpers.jsm
blob: 9f56fd2c25d660716ffb1e75b29bdb9457c270d4 (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
/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */

/*
 * Helpers to deal with the preferences tab.
 */

"use strict";

const EXPORTED_SYMBOLS = ["close_pref_tab", "open_pref_tab"];

var utils = ChromeUtils.import("resource://testing-common/mozmill/utils.jsm");

var fdh = ChromeUtils.import(
  "resource://testing-common/mozmill/FolderDisplayHelpers.jsm"
);
var cth = ChromeUtils.import(
  "resource://testing-common/mozmill/ContentTabHelpers.jsm"
);

/**
 * Open the preferences tab with the given pane displayed. The pane needs to
 * be one of the prefpane ids in mail/components/preferences/preferences.xhtml.
 *
 * @param aPaneID The ID of the pref pane to display (see
 *     mail/components/preferences/preferences.xhtml for valid IDs.)
 */
function open_pref_tab(aPaneID, aScrollTo) {
  let tab = cth.open_content_tab_with_click(
    function () {
      fdh.mc.window.openOptionsDialog(aPaneID, aScrollTo);
    },
    "about:preferences",
    fdh.mc,
    "preferencesTab"
  );
  utils.waitFor(
    () => tab.browser.contentWindow.gLastCategory.category == aPaneID,
    "Timed out waiting for prefpane " + aPaneID + " to load."
  );
  return tab;
}

/**
 * Close the preferences tab.
 *
 * @param aTab  The content tab to close.
 */
function close_pref_tab(aTab) {
  fdh.mc.window.document.getElementById("tabmail").closeTab(aTab);
}