Attachment #538442: replace all uses of waitForEval, v1 for bug #662960

View | Details | Raw Unified | Return to bug 662960
Collapse All | Expand All

(-)a/mail/test/mozmill/account/test-mail-account-setup-wizard.js (-7 / +11 lines)
Line     Link Here 
 Lines 117-148   function test_mail_account_setup() { Link Here 
117
    input_value(awc, user.password);
117
    input_value(awc, user.password);
118
118
119
    // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
119
    // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
120
    awc.e("next_button").click();
120
    awc.e("next_button").click();
121
121
122
    let config = null;
122
    let config = null;
123
123
124
    // XXX: This should probably use a notification, once we fix bug 561143.
124
    // XXX: This should probably use a notification, once we fix bug 561143.
125
    awc.waitForEval("subject._currentConfig != null", 8000, 600,
125
    awc.waitFor(function () awc.window.gEmailConfigWizard._currentConfig != null,
126
                    awc.window.gEmailConfigWizard);
126
                "Timeout waiting for current config to become non-null",
127
                8000, 600);
127
    config = awc.window.gEmailConfigWizard.getConcreteConfig();
128
    config = awc.window.gEmailConfigWizard.getConcreteConfig();
128
129
129
    // Open the advanced settings (Account Manager) to create the account
130
    // Open the advanced settings (Account Manager) to create the account
130
    // immediately.  We use an invalid email/password so the setup will fail
131
    // immediately.  We use an invalid email/password so the setup will fail
131
    // anyway.
132
    // anyway.
132
    open_advanced_settings_from_account_wizard(subtest_verify_account, awc);
133
    open_advanced_settings_from_account_wizard(subtest_verify_account, awc);
133
134
134
    // Clean up
135
    // Clean up
135
    pref.clearUserPref(pref_name);
136
    pref.clearUserPref(pref_name);
136
  });
137
  });
137
}
138
}
138
139
139
function subtest_verify_account(amc) {
140
function subtest_verify_account(amc) {
140
  amc.waitForEval("subject.currentAccount != null", 6000, 600, amc.window);
141
  amc.waitFor(function () amc.window.currentAccount != null,
142
              "Timeout waiting for currentAccount to become non-null");
141
  account = amc.window.currentAccount;
143
  account = amc.window.currentAccount;
142
  let identity = account.defaultIdentity;
144
  let identity = account.defaultIdentity;
143
  incoming = account.incomingServer;
145
  incoming = account.incomingServer;
144
  outgoing = amc.window.smtpService.getServerByKey(identity.smtpServerKey);
146
  outgoing = amc.window.smtpService.getServerByKey(identity.smtpServerKey);
145
147
146
  let config = {
148
  let config = {
147
    "incoming server username": {
149
    "incoming server username": {
148
      actual: incoming.username, expected: user.email.split("@")[0]
150
      actual: incoming.username, expected: user.email.split("@")[0]
 Lines 203-224   function test_bad_password_uses_old_sett Link Here 
203
      awc.keypress(null, "VK_TAB", {});
205
      awc.keypress(null, "VK_TAB", {});
204
      input_value(awc, user.password);
206
      input_value(awc, user.password);
205
207
206
      // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
208
      // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
207
      awc.e("next_button").click();
209
      awc.e("next_button").click();
208
210
209
      let config = null;
211
      let config = null;
210
212
211
      awc.waitForEval("subject.disabled == false && subject.hidden == false",
213
      awc.waitFor(function () (this.disabled == false && this.hidden == false),
212
                      8000, 600, awc.e("create_button"));
214
                  "Timeout waiting for create button to be visible and active",
215
                  8000, 600, awc.e("create_button"));
213
      awc.e("create_button").click();
216
      awc.e("create_button").click();
214
217
215
      awc.waitForEval("subject.disabled == false", 8000, 600,
218
      awc.waitFor(function () (this.disabled == false),
216
                      awc.e("create_button"));
219
                  "Timeout waiting for create button to be visible and active",
220
                  8000, 600, awc.e("create_button"));
217
      awc.e("create_button").click();
221
      awc.e("create_button").click();
218
      awc.e("manual-edit_button").click();
222
      awc.e("manual-edit_button").click();
219
223
220
      // Make sure all the values are the same as in the user object.
224
      // Make sure all the values are the same as in the user object.
221
      awc.sleep(1000);
225
      awc.sleep(1000);
222
      assert_equals(awc.e("outgoing_hostname").value, user.outgoingHost,
226
      assert_equals(awc.e("outgoing_hostname").value, user.outgoingHost,
223
                    "Outgoing server changed!");
227
                    "Outgoing server changed!");
224
      assert_equals(awc.e("incoming_hostname").value, user.incomingHost,
228
      assert_equals(awc.e("incoming_hostname").value, user.incomingHost,
(-)a/mail/test/mozmill/account/test-retest-config.js (-6 / +9 lines)
Line     Link Here 
 Lines 85-122   function test_re_test_config() { Link Here 
85
    input_value(awc, user.name);
85
    input_value(awc, user.name);
86
    awc.keypress(null, "VK_TAB", {});
86
    awc.keypress(null, "VK_TAB", {});
87
    input_value(awc, user.email);
87
    input_value(awc, user.email);
88
88
89
    // Click "continue" button
89
    // Click "continue" button
90
    awc.e("next_button").click();
90
    awc.e("next_button").click();
91
91
92
    // Wait for 'edit' button to be enabled
92
    // Wait for 'edit' button to be enabled
93
    awc.waitForEval("subject.disabled == false && subject.hidden == false",
93
    awc.waitFor(function () (this.disabled == false && this.hidden == false),
94
                    8000, 600, awc.e("create_button"));
94
                "Timeout waiting for edit button to be enabled",
95
                8000, 600, awc.e("create_button"));
95
96
96
    awc.e("manual-edit_button").click();
97
    awc.e("manual-edit_button").click();
97
98
98
    // Click "re-test" button
99
    // Click "re-test" button
99
    awc.e("half-manual-test_button").click();
100
    awc.e("half-manual-test_button").click();
100
101
101
    awc.waitForEval("subject.disabled == false", 20000, 600,
102
    awc.waitFor(function () (this.disabled == false),
102
                    awc.e("half-manual-test_button"));
103
                "Timeout waiting for re-test button to be enabled",
104
                20000, 600, awc.e("half-manual-test_button"));
103
105
104
    // There used to be a "start over" button (line commented out below). Now just
106
    // There used to be a "start over" button (line commented out below). Now just
105
    // changing the value of the email field does the trick.
107
    // changing the value of the email field does the trick.
106
    awc.e("realname").focus();
108
    awc.e("realname").focus();
107
    awc.keypress(null, "VK_TAB", {});
109
    awc.keypress(null, "VK_TAB", {});
108
    input_value(awc, user.altEmail);
110
    input_value(awc, user.altEmail);
109
    awc.keypress(null, "VK_TAB", {});
111
    awc.keypress(null, "VK_TAB", {});
110
112
111
    // Wait for the "continue" button to be back, which means we're back to the
113
    // Wait for the "continue" button to be back, which means we're back to the
112
    // original state.
114
    // original state.
113
    awc.waitForEval("subject.hidden == false", 20000, 600,
115
    awc.waitFor(function () this.hidden == false,
114
                    awc.e("next_button"));
116
                "Timeout waiting for continue button to be visible",
117
                20000, 600, awc.e("next_button"));
115
118
116
    awc.e("next_button").click();
119
    awc.e("next_button").click();
117
120
118
    // Previously, we'd switched to the manual editing state. Now we've started
121
    // Previously, we'd switched to the manual editing state. Now we've started
119
    // over, we should make sure the information is presented back in its original
122
    // over, we should make sure the information is presented back in its original
120
    // "automatic" mode.
123
    // "automatic" mode.
121
    assert_true(!awc.e("manual-edit_button").hidden,
124
    assert_true(!awc.e("manual-edit_button").hidden,
122
      "We're not back to the original state!");
125
      "We're not back to the original state!");
(-)a/mail/test/mozmill/addrbook/test-address-book.js (-2 / +4 lines)
Line     Link Here 
 Lines 118-135   function setupModule(module) Link Here 
118
  addrBook3.addMailList(mListC);
118
  addrBook3.addMailList(mListC);
119
119
120
  mListD = create_mailing_list("ML D");
120
  mListD = create_mailing_list("ML D");
121
  addrBook3.addMailList(mListD);
121
  addrBook3.addMailList(mListD);
122
122
123
  // There are 7 address books (Personal, AB 1, AB 2, AB 3, AB 4, LDAP Book
123
  // There are 7 address books (Personal, AB 1, AB 2, AB 3, AB 4, LDAP Book
124
  // and Collected Address Book.  So let's ensure that those address books
124
  // and Collected Address Book.  So let's ensure that those address books
125
  // exist in the tree view before executing our tests.
125
  // exist in the tree view before executing our tests.
126
  abController.waitForEval("subject.window.gDirectoryTreeView.rowCount == 7",
126
  abController.waitFor(
127
                           1000, 10, abController);
127
    function () (abController.window.gDirectoryTreeView.rowCount == 7),
128
    "Timeout waiting for all 7 address books to show up in the tree view",
129
    1000, 10);
128
}
130
}
129
131
130
/* Test that the address book manager automatically sorts
132
/* Test that the address book manager automatically sorts
131
 * address books.
133
 * address books.
132
 *
134
 *
133
 * Currently, we sort address books as follows:
135
 * Currently, we sort address books as follows:
134
 * 1. Personal Address Book
136
 * 1. Personal Address Book
135
 * 2. Mork Address Books
137
 * 2. Mork Address Books
(-)a/mail/test/mozmill/composition/test-forward-headers.js (-2 / +4 lines)
Line     Link Here 
 Lines 111-127   function test_forward_inline () { Link Here 
111
  let done = {};
111
  let done = {};
112
  mc.window.MsgHdrToMimeMessage(fMsgHdr, function(aMsgHdr, aMimeMsg) {
112
  mc.window.MsgHdrToMimeMessage(fMsgHdr, function(aMsgHdr, aMimeMsg) {
113
    assert_equals(aMimeMsg.headers["x-forwarded-message-id"],
113
    assert_equals(aMimeMsg.headers["x-forwarded-message-id"],
114
      "<"+oMsgHdr.messageId+">");
114
      "<"+oMsgHdr.messageId+">");
115
    assert_equals(aMimeMsg.headers["references"],
115
    assert_equals(aMimeMsg.headers["references"],
116
      "<"+oMsgHdr.messageId+">");
116
      "<"+oMsgHdr.messageId+">");
117
    done.value = true;
117
    done.value = true;
118
  });
118
  });
119
  mc.waitForEval("subject.value==true", 30000, 100, done);
119
  mc.waitFor(function () done.value == true,
120
             "Timeout waiting for message to be streamed", 30000, 100);
120
121
121
  press_delete(mc);
122
  press_delete(mc);
122
}
123
}
123
124
124
function test_forward_as_attachments () {
125
function test_forward_as_attachments () {
125
  be_in_folder(folder);
126
  be_in_folder(folder);
126
  // original message header
127
  // original message header
127
  let oMsgHdr0 = select_click_row(0);
128
  let oMsgHdr0 = select_click_row(0);
 Lines 143-154   function test_forward_as_attachments () Link Here 
143
  let done = {};
144
  let done = {};
144
  mc.window.MsgHdrToMimeMessage(fMsgHdr, function(aMsgHdr, aMimeMsg) {
145
  mc.window.MsgHdrToMimeMessage(fMsgHdr, function(aMsgHdr, aMimeMsg) {
145
    assert_equals(aMimeMsg.headers["x-forwarded-message-id"],
146
    assert_equals(aMimeMsg.headers["x-forwarded-message-id"],
146
      "<"+oMsgHdr0.messageId+"> <"+oMsgHdr1.messageId+">");
147
      "<"+oMsgHdr0.messageId+"> <"+oMsgHdr1.messageId+">");
147
    assert_equals(aMimeMsg.headers["references"],
148
    assert_equals(aMimeMsg.headers["references"],
148
      "<"+oMsgHdr0.messageId+"> <"+oMsgHdr1.messageId+">");
149
      "<"+oMsgHdr0.messageId+"> <"+oMsgHdr1.messageId+">");
149
    done.value = true;
150
    done.value = true;
150
  });
151
  });
151
  mc.waitForEval("subject.value==true", 30000, 100, done);
152
  mc.waitFor(function () done.value == true,
153
             "Timeout waiting for message to be streamed", 30000, 100);
152
154
153
  press_delete(mc);
155
  press_delete(mc);
154
}
156
}
(-)a/mail/test/mozmill/content-policy/test-compose-mailto.js (-9 / +5 lines)
Line     Link Here 
 Lines 34-50    Link Here 
34
 * the terms of any one of the MPL, the GPL or the LGPL.
34
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 *
35
 *
36
 * ***** END LICENSE BLOCK ***** */
36
 * ***** END LICENSE BLOCK ***** */
37
37
38
var MODULE_NAME = 'test-compose-mailto';
38
var MODULE_NAME = 'test-compose-mailto';
39
39
40
var RELATIVE_ROOT = '../shared-modules';
40
var RELATIVE_ROOT = '../shared-modules';
41
var MODULE_REQUIRES = ['folder-display-helpers', 'compose-helpers',
41
var MODULE_REQUIRES = ['folder-display-helpers', 'compose-helpers',
42
                       'window-helpers', 'keyboard-helpers'];
42
                       'window-helpers', 'keyboard-helpers',
43
                       'content-tab-helpers'];
43
var jumlib = {};
44
var jumlib = {};
44
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
45
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
45
var elib = {};
46
var elib = {};
46
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
47
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
47
48
48
var folder = null;
49
var folder = null;
49
var composeHelper = null;
50
var composeHelper = null;
50
var windowHelper = null;
51
var windowHelper = null;
 Lines 61-91   var setupModule = function (module) { Link Here 
61
  let fdh = collector.getModule('folder-display-helpers');
62
  let fdh = collector.getModule('folder-display-helpers');
62
  fdh.installInto(module);
63
  fdh.installInto(module);
63
  let kh = collector.getModule('keyboard-helpers');
64
  let kh = collector.getModule('keyboard-helpers');
64
  kh.installInto(module);
65
  kh.installInto(module);
65
  composeHelper = collector.getModule('compose-helpers');
66
  composeHelper = collector.getModule('compose-helpers');
66
  composeHelper.installInto(module);
67
  composeHelper.installInto(module);
67
  windowHelper = collector.getModule('window-helpers');
68
  windowHelper = collector.getModule('window-helpers');
68
  windowHelper.installInto(module);
69
  windowHelper.installInto(module);
70
  let cth = collector.getModule("content-tab-helpers");
71
  cth.installInto(module);
69
};
72
};
70
73
71
function test_openComposeFromMailToLink() {
74
function test_openComposeFromMailToLink() {
72
  // Open a content tab with the mailto link in it.
75
  // Open a content tab with the mailto link in it.
73
    // To open a tab we're going to have to cheat and use tabmail so we can load
76
    // To open a tab we're going to have to cheat and use tabmail so we can load
74
  // in the data of what we want.
77
  // in the data of what we want.
75
  gPreCount = mc.tabmail.tabContainer.childNodes.length;
78
  gPreCount = mc.tabmail.tabContainer.childNodes.length;
76
79
  gNewTab = open_content_tab_with_url(url + "mailtolink.html");
77
  gNewTab = mc.tabmail.openTab("contentTab", { contentPage: url + "mailtolink.html" });
78
79
  mc.waitForEval("subject.busy == false", 5000, 100, gNewTab);
80
81
  if (mc.tabmail.tabContainer.childNodes.length != gPreCount + 1)
82
    throw new Error("The content tab didn't open");
83
84
  gComposeWin = composeHelper.open_compose_with_element_click("mailtolink");
80
  gComposeWin = composeHelper.open_compose_with_element_click("mailtolink");
85
}
81
}
86
82
87
function test_checkInsertImage() {
83
function test_checkInsertImage() {
88
  // First focus on the editor element
84
  // First focus on the editor element
89
  gComposeWin.e("content-frame").focus();
85
  gComposeWin.e("content-frame").focus();
90
86
91
  // Now open the image window
87
  // Now open the image window
(-)a/mail/test/mozmill/content-policy/test-dns-prefetch.js (-7 / +5 lines)
Line     Link Here 
 Lines 42-58    Link Here 
42
 * the provisions above, a recipient may use your version of this file under
42
 * the provisions above, a recipient may use your version of this file under
43
 * the terms of any one of the MPL, the GPL or the LGPL.
43
 * the terms of any one of the MPL, the GPL or the LGPL.
44
 *
44
 *
45
 * ***** END LICENSE BLOCK ***** */
45
 * ***** END LICENSE BLOCK ***** */
46
46
47
var MODULE_NAME = 'test-exposed-in-content-tabs';
47
var MODULE_NAME = 'test-exposed-in-content-tabs';
48
48
49
var RELATIVE_ROOT = '../shared-modules';
49
var RELATIVE_ROOT = '../shared-modules';
50
var MODULE_REQUIRES = ['folder-display-helpers', 'compose-helpers'];
50
var MODULE_REQUIRES = ['folder-display-helpers', 'compose-helpers',
51
                       'content-tab-helpers'];
51
var jumlib = {};
52
var jumlib = {};
52
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
53
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
53
var elib = {};
54
var elib = {};
54
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
55
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
55
56
56
var folder = null;
57
var folder = null;
57
var composeHelper = null;
58
var composeHelper = null;
58
var gMsgNo = 0;
59
var gMsgNo = 0;
 Lines 69-84   const msgBody = '<!DOCTYPE HTML PUBLIC " Link Here 
69
'dns prefetch test message\n' +
70
'dns prefetch test message\n' +
70
'</body>\n</html>\n';
71
'</body>\n</html>\n';
71
72
72
var setupModule = function (module) {
73
var setupModule = function (module) {
73
  let fdh = collector.getModule('folder-display-helpers');
74
  let fdh = collector.getModule('folder-display-helpers');
74
  fdh.installInto(module);
75
  fdh.installInto(module);
75
  composeHelper = collector.getModule('compose-helpers');
76
  composeHelper = collector.getModule('compose-helpers');
76
  composeHelper.installInto(module);
77
  composeHelper.installInto(module);
78
  let cth = collector.getModule('content-tab-helpers');
79
  cth.installInto(module);
77
80
78
  folder = create_folder("dnsPrefetch");
81
  folder = create_folder("dnsPrefetch");
79
};
82
};
80
83
81
function addToFolder(aSubject, aBody, aFolder) {
84
function addToFolder(aSubject, aBody, aFolder) {
82
85
83
  let msgId = Components.classes["@mozilla.org/uuid-generator;1"]
86
  let msgId = Components.classes["@mozilla.org/uuid-generator;1"]
84
                          .getService(Components.interfaces.nsIUUIDGenerator)
87
                          .getService(Components.interfaces.nsIUUIDGenerator)
 Lines 192-213   function test_dnsPrefetch_compose() { Link Here 
192
function test_dnsPrefetch_contentTab() {
195
function test_dnsPrefetch_contentTab() {
193
  // To open a tab we're going to have to cheat and use tabmail so we can load
196
  // To open a tab we're going to have to cheat and use tabmail so we can load
194
  // in the data of what we want.
197
  // in the data of what we want.
195
  let preCount = mc.tabmail.tabContainer.childNodes.length;
198
  let preCount = mc.tabmail.tabContainer.childNodes.length;
196
199
197
  let dataurl = 'data:text/html,<html><head><title>test dns prefetch</title>' +
200
  let dataurl = 'data:text/html,<html><head><title>test dns prefetch</title>' +
198
    '</head><body>test dns prefetch</body></html>';
201
    '</head><body>test dns prefetch</body></html>';
199
202
200
  let newTab = mc.tabmail.openTab("contentTab", { contentPage: dataurl });
203
  let newTab = open_content_tab_with_url(dataurl);
201
202
  mc.waitForEval("subject.busy == false", 5000, 100, newTab);
203
204
  if (mc.tabmail.tabContainer.childNodes.length != preCount + 1)
205
    throw new Error("The content tab didn't open");
206
204
207
  // XXX this should be a check for DNS prefetch being enabled, but bug 545407
205
  // XXX this should be a check for DNS prefetch being enabled, but bug 545407
208
  // needs fixing for that to work.
206
  // needs fixing for that to work.
209
  var versionChecker =
207
  var versionChecker =
210
    Components.classes["@mozilla.org/xpcom/version-comparator;1"]
208
    Components.classes["@mozilla.org/xpcom/version-comparator;1"]
211
              .getService(Components.interfaces.nsIVersionComparator);
209
              .getService(Components.interfaces.nsIVersionComparator);
212
210
213
  if (versionChecker.compare(mc.window.Application.version, "3.2a1pre") >= 0) {
211
  if (versionChecker.compare(mc.window.Application.version, "3.2a1pre") >= 0) {
(-)a/mail/test/mozmill/content-policy/test-exposed-in-content-tabs.js (-7 / +5 lines)
Line     Link Here 
 Lines 40-56    Link Here 
40
 * the provisions above, a recipient may use your version of this file under
40
 * the provisions above, a recipient may use your version of this file under
41
 * the terms of any one of the MPL, the GPL or the LGPL.
41
 * the terms of any one of the MPL, the GPL or the LGPL.
42
 *
42
 *
43
 * ***** END LICENSE BLOCK ***** */
43
 * ***** END LICENSE BLOCK ***** */
44
44
45
var MODULE_NAME = 'test-exposed-in-content-tabs';
45
var MODULE_NAME = 'test-exposed-in-content-tabs';
46
46
47
var RELATIVE_ROOT = '../shared-modules';
47
var RELATIVE_ROOT = '../shared-modules';
48
var MODULE_REQUIRES = ['folder-display-helpers', 'compose-helpers'];
48
var MODULE_REQUIRES = ['folder-display-helpers', 'compose-helpers',
49
                       'content-tab-helpers'];
49
var jumlib = {};
50
var jumlib = {};
50
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
51
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
51
var elib = {};
52
var elib = {};
52
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
53
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
53
54
54
var folder = null;
55
var folder = null;
55
var composeHelper = null;
56
var composeHelper = null;
56
var gMsgNo = 0;
57
var gMsgNo = 0;
 Lines 70-85   const msgBody = '<!DOCTYPE HTML PUBLIC " Link Here 
70
'<img id="testelement" src="' + url + 'pass.png"/>\n' +
71
'<img id="testelement" src="' + url + 'pass.png"/>\n' +
71
'</body>\n</html>\n';
72
'</body>\n</html>\n';
72
73
73
var setupModule = function (module) {
74
var setupModule = function (module) {
74
  let fdh = collector.getModule('folder-display-helpers');
75
  let fdh = collector.getModule('folder-display-helpers');
75
  fdh.installInto(module);
76
  fdh.installInto(module);
76
  composeHelper = collector.getModule('compose-helpers');
77
  composeHelper = collector.getModule('compose-helpers');
77
  composeHelper.installInto(module);
78
  composeHelper.installInto(module);
79
  let cth = collector.getModule('content-tab-helpers');
80
  cth.installInto(module);
78
81
79
  folder = create_folder("exposedInContent");
82
  folder = create_folder("exposedInContent");
80
};
83
};
81
84
82
function addToFolder(aSubject, aBody, aFolder) {
85
function addToFolder(aSubject, aBody, aFolder) {
83
86
84
  let msgId = Components.classes["@mozilla.org/uuid-generator;1"]
87
  let msgId = Components.classes["@mozilla.org/uuid-generator;1"]
85
                          .getService(Components.interfaces.nsIUUIDGenerator)
88
                          .getService(Components.interfaces.nsIUUIDGenerator)
 Lines 140-161   function addMsgToFolder(folder) { Link Here 
140
function checkContentTab(msgURL) {
143
function checkContentTab(msgURL) {
141
  // To open a tab we're going to have to cheat and use tabmail so we can load
144
  // To open a tab we're going to have to cheat and use tabmail so we can load
142
  // in the data of what we want.
145
  // in the data of what we want.
143
  let preCount = mc.tabmail.tabContainer.childNodes.length;
146
  let preCount = mc.tabmail.tabContainer.childNodes.length;
144
147
145
  let dataurl = 'data:text/html,<html><head><title>test exposed</title>' +
148
  let dataurl = 'data:text/html,<html><head><title>test exposed</title>' +
146
    '</head><body><iframe id="msgIframe" src="' + msgURL + '"/></body></html>';
149
    '</head><body><iframe id="msgIframe" src="' + msgURL + '"/></body></html>';
147
150
148
  let newTab = mc.tabmail.openTab("contentTab", { contentPage: dataurl });
151
  let newTab = open_content_tab_with_url(dataurl);
149
150
  mc.waitForEval("subject.busy == false", 5000, 100, newTab);
151
152
  if (mc.tabmail.tabContainer.childNodes.length != preCount + 1)
153
    throw new Error("The content tab didn't open");
154
152
155
  if (mc.window.content.document.getElementById("msgIframe")
153
  if (mc.window.content.document.getElementById("msgIframe")
156
        .contentDocument.URL != "about:blank")
154
        .contentDocument.URL != "about:blank")
157
    throw new Error("Message display/access has not been blocked from remote content!");
155
    throw new Error("Message display/access has not been blocked from remote content!");
158
156
159
  mc.tabmail.closeTab(newTab);
157
  mc.tabmail.closeTab(newTab);
160
158
161
  if (mc.tabmail.tabContainer.childNodes.length != preCount)
159
  if (mc.tabmail.tabContainer.childNodes.length != preCount)
(-)a/mail/test/mozmill/content-policy/test-general-content-policy.js (-7 / +5 lines)
Line     Link Here 
 Lines 49-65    Link Here 
49
 * the provisions above, a recipient may use your version of this file under
49
 * the provisions above, a recipient may use your version of this file under
50
 * the terms of any one of the MPL, the GPL or the LGPL.
50
 * the terms of any one of the MPL, the GPL or the LGPL.
51
 *
51
 *
52
 * ***** END LICENSE BLOCK ***** */
52
 * ***** END LICENSE BLOCK ***** */
53
53
54
var MODULE_NAME = 'test-general-content-policy';
54
var MODULE_NAME = 'test-general-content-policy';
55
55
56
var RELATIVE_ROOT = '../shared-modules';
56
var RELATIVE_ROOT = '../shared-modules';
57
var MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers', 'compose-helpers'];
57
var MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers',
58
                       'compose-helpers', 'content-tab-helpers'];
58
var jumlib = {};
59
var jumlib = {};
59
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
60
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
60
var elib = {};
61
var elib = {};
61
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
62
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
62
63
63
var folder = null;
64
var folder = null;
64
var composeHelper = null;
65
var composeHelper = null;
65
var gMsgNo = 0;
66
var gMsgNo = 0;
 Lines 127-142   const msgBodyEnd = '</body>\n</html>\n'; Link Here 
127
128
128
var setupModule = function (module) {
129
var setupModule = function (module) {
129
  let fdh = collector.getModule('folder-display-helpers');
130
  let fdh = collector.getModule('folder-display-helpers');
130
  fdh.installInto(module);
131
  fdh.installInto(module);
131
  let wh = collector.getModule('window-helpers');
132
  let wh = collector.getModule('window-helpers');
132
  wh.installInto(module);
133
  wh.installInto(module);
133
  composeHelper = collector.getModule('compose-helpers');
134
  composeHelper = collector.getModule('compose-helpers');
134
  composeHelper.installInto(module);
135
  composeHelper.installInto(module);
136
  let cth = collector.getModule('content-tab-helpers');
137
  cth.installInto(module);
135
138
136
  folder = create_folder("generalContentPolicy");
139
  folder = create_folder("generalContentPolicy");
137
};
140
};
138
141
139
function addToFolder(aSubject, aBody, aFolder) {
142
function addToFolder(aSubject, aBody, aFolder) {
140
143
141
  let msgId = Components.classes["@mozilla.org/uuid-generator;1"]
144
  let msgId = Components.classes["@mozilla.org/uuid-generator;1"]
142
                          .getService(Components.interfaces.nsIUUIDGenerator)
145
                          .getService(Components.interfaces.nsIUUIDGenerator)
 Lines 248-269   function allowRemoteContentAndCheck(test Link Here 
248
    throw new Error(test.type + " has been unexpectedly blocked in message content");
251
    throw new Error(test.type + " has been unexpectedly blocked in message content");
249
}
252
}
250
253
251
function checkContentTab(test) {
254
function checkContentTab(test) {
252
  // To open a tab we're going to have to cheat and use tabmail so we can load
255
  // To open a tab we're going to have to cheat and use tabmail so we can load
253
  // in the data of what we want.
256
  // in the data of what we want.
254
  let preCount = mc.tabmail.tabContainer.childNodes.length;
257
  let preCount = mc.tabmail.tabContainer.childNodes.length;
255
258
256
  let newTab = mc.tabmail.openTab("contentTab", { contentPage: url + test.webPage });
259
  let newTab = open_content_tab_with_url(url + test.webPage);
257
258
  mc.waitForEval("subject.busy == false", 5000, 100, newTab);
259
260
  if (mc.tabmail.tabContainer.childNodes.length != preCount + 1)
261
    throw new Error("The content tab didn't open");
262
260
263
  if (!test.checkForAllowed(mc.window.content.document
261
  if (!test.checkForAllowed(mc.window.content.document
264
                              .getElementById("testelement")))
262
                              .getElementById("testelement")))
265
    throw new Error(test.type + " has been unexpectedly blocked in content tab");
263
    throw new Error(test.type + " has been unexpectedly blocked in content tab");
266
264
267
  mc.tabmail.closeTab(newTab);
265
  mc.tabmail.closeTab(newTab);
268
266
269
  if (mc.tabmail.tabContainer.childNodes.length != preCount)
267
  if (mc.tabmail.tabContainer.childNodes.length != preCount)
(-)a/mail/test/mozmill/content-policy/test-plugins-policy.js (-7 / +5 lines)
Line     Link Here 
 Lines 40-56    Link Here 
40
 * the provisions above, a recipient may use your version of this file under
40
 * the provisions above, a recipient may use your version of this file under
41
 * the terms of any one of the MPL, the GPL or the LGPL.
41
 * the terms of any one of the MPL, the GPL or the LGPL.
42
 *
42
 *
43
 * ***** END LICENSE BLOCK ***** */
43
 * ***** END LICENSE BLOCK ***** */
44
44
45
var MODULE_NAME = 'test-plugins-policy';
45
var MODULE_NAME = 'test-plugins-policy';
46
46
47
var RELATIVE_ROOT = '../shared-modules';
47
var RELATIVE_ROOT = '../shared-modules';
48
var MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers', 'compose-helpers'];
48
var MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers',
49
                       'compose-helpers', 'content-tab-helpers'];
49
var jumlib = {};
50
var jumlib = {};
50
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
51
Components.utils.import("resource://mozmill/modules/jum.js", jumlib);
51
var elib = {};
52
var elib = {};
52
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
53
Components.utils.import('resource://mozmill/modules/elementslib.js', elib);
53
54
54
Components.utils.import("resource://gre/modules/Services.jsm");
55
Components.utils.import("resource://gre/modules/Services.jsm");
55
56
56
var folder = null;
57
var folder = null;
 Lines 74-89   const msgBody = '<!DOCTYPE HTML PUBLIC " Link Here 
74
75
75
var setupModule = function (module) {
76
var setupModule = function (module) {
76
  let fdh = collector.getModule('folder-display-helpers');
77
  let fdh = collector.getModule('folder-display-helpers');
77
  fdh.installInto(module);
78
  fdh.installInto(module);
78
  let wh = collector.getModule('window-helpers');
79
  let wh = collector.getModule('window-helpers');
79
  wh.installInto(module);
80
  wh.installInto(module);
80
  composeHelper = collector.getModule('compose-helpers');
81
  composeHelper = collector.getModule('compose-helpers');
81
  composeHelper.installInto(module);
82
  composeHelper.installInto(module);
83
  let cth = collector.getModule('content-tab-helpers');
84
  cth.installInto(module);
82
85
83
  folder = create_folder("pluginPolicy");
86
  folder = create_folder("pluginPolicy");
84
};
87
};
85
88
86
function addToFolder(aSubject, aBody, aFolder) {
89
function addToFolder(aSubject, aBody, aFolder) {
87
  let msgId = Components.classes["@mozilla.org/uuid-generator;1"]
90
  let msgId = Components.classes["@mozilla.org/uuid-generator;1"]
88
                          .getService(Components.interfaces.nsIUUIDGenerator)
91
                          .getService(Components.interfaces.nsIUUIDGenerator)
89
                          .generateUUID() +"@mozillamessaging.invalid";
92
                          .generateUUID() +"@mozillamessaging.invalid";
 Lines 215-236   function test_checkStandaloneMessageWind Link Here 
215
  checkStandaloneMessageWindow(false);
218
  checkStandaloneMessageWindow(false);
216
}
219
}
217
220
218
function test_checkContentTab() {
221
function test_checkContentTab() {
219
  // To open a tab we're going to have to cheat and use tabmail so we can load
222
  // To open a tab we're going to have to cheat and use tabmail so we can load
220
  // in the data of what we want.
223
  // in the data of what we want.
221
  let preCount = mc.tabmail.tabContainer.childNodes.length;
224
  let preCount = mc.tabmail.tabContainer.childNodes.length;
222
225
223
  let newTab = mc.tabmail.openTab("contentTab", { contentPage: url + "plugin.html" });
226
  let newTab = open_content_tab_with_url(url + "plugin.html");
224
225
  mc.waitForEval("subject.busy == false", 5000, 100, newTab);
226
227
  if (mc.tabmail.tabContainer.childNodes.length != preCount + 1)
228
    throw new Error("The content tab didn't open");
229
227
230
  if (!isPluginLoaded(mc.tabmail.getBrowserForSelectedTab().contentDocument))
228
  if (!isPluginLoaded(mc.tabmail.getBrowserForSelectedTab().contentDocument))
231
    throw new Error("Plugin has been unexpectedly blocked in content tab");
229
    throw new Error("Plugin has been unexpectedly blocked in content tab");
232
230
233
  mc.tabmail.closeTab(newTab);
231
  mc.tabmail.closeTab(newTab);
234
232
235
  if (mc.tabmail.tabContainer.childNodes.length != preCount)
233
  if (mc.tabmail.tabContainer.childNodes.length != preCount)
236
    throw new Error("The content tab didn't close");
234
    throw new Error("The content tab didn't close");
(-)a/mail/test/mozmill/content-tabs/test-about-support.js (-8 / +2 lines)
Line     Link Here 
 Lines 36-54    Link Here 
36
 * ***** END LICENSE BLOCK ***** */
36
 * ***** END LICENSE BLOCK ***** */
37
37
38
var MODULE_NAME = 'test-about-support';
38
var MODULE_NAME = 'test-about-support';
39
39
40
var RELATIVE_ROOT = '../shared-modules';
40
var RELATIVE_ROOT = '../shared-modules';
41
var MODULE_REQUIRES = ['folder-display-helpers', 'content-tab-helpers',
41
var MODULE_REQUIRES = ['folder-display-helpers', 'content-tab-helpers',
42
                       'compose-helpers', 'window-helpers'];
42
                       'compose-helpers', 'window-helpers'];
43
43
44
var controller = {};
45
Components.utils.import('resource://mozmill/modules/controller.js', controller);
46
47
Components.utils.import("resource://gre/modules/Services.jsm");
44
Components.utils.import("resource://gre/modules/Services.jsm");
48
45
49
function setupModule(module) {
46
function setupModule(module) {
50
  let fdh = collector.getModule("folder-display-helpers");
47
  let fdh = collector.getModule("folder-display-helpers");
51
  fdh.installInto(module);
48
  fdh.installInto(module);
52
  let cth = collector.getModule("content-tab-helpers");
49
  let cth = collector.getModule("content-tab-helpers");
53
  cth.installInto(module);
50
  cth.installInto(module);
54
  let ch = collector.getModule("compose-helpers");
51
  let ch = collector.getModule("compose-helpers");
 Lines 86-106   const ABOUT_SUPPORT_ERROR_STRINGS = ["un Link Here 
86
 *
83
 *
87
 * @returns the about:support tab.
84
 * @returns the about:support tab.
88
 */
85
 */
89
function open_about_support() {
86
function open_about_support() {
90
  let tab = open_content_tab_with_click(mc.menus.helpMenu.aboutsupport_open);
87
  let tab = open_content_tab_with_click(mc.menus.helpMenu.aboutsupport_open);
91
  assert_content_tab_has_url(tab, "about:support");
88
  assert_content_tab_has_url(tab, "about:support");
92
  // We have one variable that's asynchronously populated -- wait for it to be
89
  // We have one variable that's asynchronously populated -- wait for it to be
93
  // populated.
90
  // populated.
94
  if (!controller.waitForEval("subject.gExtensions !== undefined",
91
  mc.waitFor(function () tab.browser.contentWindow.gExtensions !== undefined,
95
                              NORMAL_TIMEOUT, FAST_INTERVAL,
92
             "Timeout waiting for about:support's gExtensions to populate.");
96
                              tab.browser.contentWindow)) {
97
    mark_failure(["Timeout waiting for about:support's gExtensions to populate."]);
98
  }
99
  return tab;
93
  return tab;
100
}
94
}
101
95
102
/**
96
/**
103
 * Opens a compose window containing the troubleshooting information.
97
 * Opens a compose window containing the troubleshooting information.
104
 *
98
 *
105
 * @param aTab The about:support tab.
99
 * @param aTab The about:support tab.
106
 */
100
 */
(-)a/mail/test/mozmill/content-tabs/test-install-xpi.js (-1 / +2 lines)
Line     Link Here 
 Lines 62-78   const ALERT_TIMEOUT = 10000; Link Here 
62
let AlertWatcher = {
62
let AlertWatcher = {
63
  planForAlert: function(aController) {
63
  planForAlert: function(aController) {
64
    this.alerted = false;
64
    this.alerted = false;
65
    aController.window.document.addEventListener("AlertActive",
65
    aController.window.document.addEventListener("AlertActive",
66
                                                 this.alertActive, false);
66
                                                 this.alertActive, false);
67
  },
67
  },
68
  waitForAlert: function(aController) {
68
  waitForAlert: function(aController) {
69
    if (!this.alerted) {
69
    if (!this.alerted) {
70
      aController.waitForEval("subject.alerted", ALERT_TIMEOUT, 100, this);
70
      aController.waitFor(function () this.alerted, "Timeout waiting for alert",
71
                          ALERT_TIMEOUT, 100, this);
71
    }
72
    }
72
    aController.window.document.removeEventListener("AlertActive",
73
    aController.window.document.removeEventListener("AlertActive",
73
                                                    this.alertActive, false);
74
                                                    this.alertActive, false);
74
  },
75
  },
75
  alerted: false,
76
  alerted: false,
76
  alertActive: function() {
77
  alertActive: function() {
77
    AlertWatcher.alerted = true;
78
    AlertWatcher.alerted = true;
78
  }
79
  }
(-)a/mail/test/mozmill/content-tabs/test-lwthemes.js (-5 / +7 lines)
Line     Link Here 
 Lines 67-91   const ALERT_TIMEOUT = 10000; Link Here 
67
67
68
let AlertWatcher = {
68
let AlertWatcher = {
69
  planForAlert: function(aController) {
69
  planForAlert: function(aController) {
70
    this.alerted = false;
70
    this.alerted = false;
71
    aController.window.document.addEventListener("AlertActive",
71
    aController.window.document.addEventListener("AlertActive",
72
                                                 this.alertActive, false);
72
                                                 this.alertActive, false);
73
  },
73
  },
74
  waitForAlert: function(aController) {
74
  waitForAlert: function(aController) {
75
    if (!this.alerted)
75
    if (!this.alerted) {
76
      aController.waitForEval("subject.alerted", ALERT_TIMEOUT, 100, this);
76
      aController.waitFor(function () this.alerted, "Timeout waiting for alert",
77
77
                          ALERT_TIMEOUT, 100, this);
78
    }
78
    // Double check the notification box has finished animating.
79
    // Double check the notification box has finished animating.
79
    let notificationBox =
80
    let notificationBox =
80
      mc.tabmail.selectedTab.panel.getElementsByTagName("notificationbox")[0];
81
      mc.tabmail.selectedTab.panel.getElementsByTagName("notificationbox")[0];
81
    if (notificationBox && notificationBox._animating)
82
    if (notificationBox && notificationBox._animating)
82
      aController.waitForEval("!subject._animating", ALERT_TIMEOUT, 100,
83
      aController.waitFor(function () !notificationBox._animating,
83
                              notificationBox);
84
                          "Timeout waiting for notification box animation to finish",
85
                          ALERT_TIMEOUT, 100);
84
86
85
    aController.window.document.removeEventListener("AlertActive",
87
    aController.window.document.removeEventListener("AlertActive",
86
                                                    this.alertActive, false);
88
                                                    this.alertActive, false);
87
  },
89
  },
88
  alerted: false,
90
  alerted: false,
89
  alertActive: function() {
91
  alertActive: function() {
90
    AlertWatcher.alerted = true;
92
    AlertWatcher.alerted = true;
91
  }
93
  }
(-)a/mail/test/mozmill/cookies/test-cookies.js (-28 / +9 lines)
Line     Link Here 
 Lines 39-100    Link Here 
39
 * Test file to check that cookies are correctly enabled in Thunderbird.
39
 * Test file to check that cookies are correctly enabled in Thunderbird.
40
 *
40
 *
41
 * XXX: Still need to check remote content in messages.
41
 * XXX: Still need to check remote content in messages.
42
 */
42
 */
43
43
44
var MODULE_NAME = 'test-cookies';
44
var MODULE_NAME = 'test-cookies';
45
45
46
var RELATIVE_ROOT = "../shared-modules";
46
var RELATIVE_ROOT = "../shared-modules";
47
var MODULE_REQUIRES = ['window-helpers'];
47
var MODULE_REQUIRES = ['window-helpers', 'content-tab-helpers', 'folder-display-helpers'];
48
48
49
var controller = {};
50
Components.utils.import('resource://mozmill/modules/controller.js', controller);
51
var mozmill = {}; Components.utils.import('resource://mozmill/modules/mozmill.js', mozmill);
49
var mozmill = {}; Components.utils.import('resource://mozmill/modules/mozmill.js', mozmill);
52
var elementslib = {}; Components.utils.import('resource://mozmill/modules/elementslib.js', elementslib);
50
var elementslib = {}; Components.utils.import('resource://mozmill/modules/elementslib.js', elementslib);
53
51
54
// The main controller.
55
var mc;
56
57
// The windowHelper module.
58
var windowHelper;
59
60
var newTab = null;
61
62
// RELATIVE_ROOT messes with the collector, so we have to bring the path back
52
// RELATIVE_ROOT messes with the collector, so we have to bring the path back
63
// so we get the right path for the resources.
53
// so we get the right path for the resources.
64
var url = collector.addHttpResource('../cookies/html', 'cookies');
54
var url = collector.addHttpResource('../cookies/html', 'cookies');
65
55
66
function setupModule(module) {
56
function setupModule(module) {
67
  windowHelper = collector.getModule('window-helpers');
57
  let fdh = collector.getModule("folder-display-helpers");
68
  mc = windowHelper.wait_for_existing_window("mail:3pane");
58
  fdh.installInto(module);
69
  windowHelper.augment_controller(mc);
59
  let wh = collector.getModule('window-helpers');
60
  wh.installInto(module);
61
  let cth = collector.getModule("content-tab-helpers");
62
  cth.installInto(module);
70
}
63
}
71
64
72
/**
65
/**
73
 * Test deleting junk messages with no messages marked as junk.
66
 * Test deleting junk messages with no messages marked as junk.
74
 */
67
 */
75
function test_load_cookie_page() {
68
function test_load_cookie_page() {
76
  newTab = mc.tabmail.openTab("contentTab",
69
  open_content_tab_with_url(url + "cookietest1.html");
77
                              {contentPage: url + "cookietest1.html"});
78
79
  if (!newTab)
80
    throw new Error("Expected new tab info to be returned from openTab");
81
82
  mc.waitForEval("subject.busy == false", 5000, 100, newTab);
83
}
70
}
84
71
85
function test_load_cookie_result_page() {
72
function test_load_cookie_result_page() {
86
  newTab = mc.tabmail.openTab("contentTab",
73
  open_content_tab_with_url(url + "cookietest2.html");
87
                              {contentPage: url + "cookietest2.html"});
88
89
  if (!newTab)
90
    throw new Error("Expected new tab info to be returned from openTab");
91
92
  mc.waitForEval("subject.busy == false", 5000, 100, newTab);
93
74
94
  if (mc.window.content.document.title != "Cookie Test 2")
75
  if (mc.window.content.document.title != "Cookie Test 2")
95
    throw new Error("The cookie test 2 page is not the selected tab or not content-primary");
76
    throw new Error("The cookie test 2 page is not the selected tab or not content-primary");
96
77
97
  let cookie = mc.window.content.wrappedJSObject.theCookie;
78
  let cookie = mc.window.content.wrappedJSObject.theCookie;
98
79
99
  dump("Cookie is: " + cookie + "\n");
80
  dump("Cookie is: " + cookie + "\n");
100
81
(-)a/mail/test/mozmill/folder-display/test-recent-menu.js (-2 / +2 lines)
Line     Link Here 
 Lines 85-102   function test_move_message() { Link Here 
85
    SetMessageKey: function(aKey) { },
85
    SetMessageKey: function(aKey) { },
86
    SetMessageId: function(aMessageId) {},
86
    SetMessageId: function(aMessageId) {},
87
    OnStopCopy: function(aStatus) {
87
    OnStopCopy: function(aStatus) {
88
      this.copyDone = true;
88
      this.copyDone = true;
89
    }
89
    }
90
  };
90
  };
91
  MailServices.copy.CopyMessages(folder1, array, folder2, true,
91
  MailServices.copy.CopyMessages(folder1, array, folder2, true,
92
                                 copyListener, mc.window.msgWindow, true);
92
                                 copyListener, mc.window.msgWindow, true);
93
  mc.waitForEval("subject.copyDone == true",
93
  mc.waitFor(function () copyListener.copyDone,
94
                          10000, 100, copyListener);
94
             "Timeout waiting for copy to complete", 10000, 100);
95
  // We've moved a message to aaafolder2 - it should appear in recent list now.
95
  // We've moved a message to aaafolder2 - it should appear in recent list now.
96
  mc.click_menus_in_sequence(mc.e("mailContext"), [{id: "mailContext-moveMenu"},
96
  mc.click_menus_in_sequence(mc.e("mailContext"), [{id: "mailContext-moveMenu"},
97
                                                   {label: "Recent"}]);
97
                                                   {label: "Recent"}]);
98
  // firstChild is move menu popup, its child is Recent, its child is menuPopup,
98
  // firstChild is move menu popup, its child is Recent, its child is menuPopup,
99
  // and menuPopup's children are what we want.
99
  // and menuPopup's children are what we want.
100
  let recentChildren = mc.eid("mailContext-moveMenu")
100
  let recentChildren = mc.eid("mailContext-moveMenu")
101
                       .node.firstChild.firstChild.firstChild.children;
101
                       .node.firstChild.firstChild.firstChild.children;
102
  assert_equals(recentChildren.length, gInitRecentMenuCount + 1,
102
  assert_equals(recentChildren.length, gInitRecentMenuCount + 1,
(-)a/mail/test/mozmill/folder-display/test-savedsearch-reload-after-compact.js (-2 / +2 lines)
Line     Link Here 
 Lines 84-100   function test_setup_virtual_folder_and_c Link Here 
84
    OnStartRunningUrl: function (aUrl) {
84
    OnStartRunningUrl: function (aUrl) {
85
    },
85
    },
86
    OnStopRunningUrl: function (aUrl, aExitCode) {
86
    OnStopRunningUrl: function (aUrl, aExitCode) {
87
      this.compactDone = true;
87
      this.compactDone = true;
88
    }
88
    }
89
  };
89
  };
90
  otherFolder.compactAll(urlListener, null, false);
90
  otherFolder.compactAll(urlListener, null, false);
91
91
92
  mc.waitForEval("subject.compactDone == true",
92
  mc.waitFor(function () urlListener.compactDone,
93
                          10000, 100, urlListener);
93
             "Timeout waiting for compact to complete", 10000, 100);
94
94
95
  // Let the event queue clear.
95
  // Let the event queue clear.
96
  mc.sleep(0);
96
  mc.sleep(0);
97
  // Check view is still valid
97
  // Check view is still valid
98
  let msgHdr = mc.dbView.getMsgHdrAt(0);
98
  let msgHdr = mc.dbView.getMsgHdrAt(0);
99
}
99
}
100
100
(-)a/mail/test/mozmill/instrumentation/test-instrument-setup.js (-2 / +3 lines)
Line     Link Here 
 Lines 88-105   function test_mail_account_setup() { Link Here 
88
  input_value(awc, user.email);
88
  input_value(awc, user.email);
89
89
90
  // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
90
  // Load the autoconfig file from http://localhost:433**/autoconfig/example.com
91
  awc.e("next_button").click();
91
  awc.e("next_button").click();
92
92
93
  let config = null;
93
  let config = null;
94
94
95
  // XXX: This should probably use a notification, once we fix bug 561143.
95
  // XXX: This should probably use a notification, once we fix bug 561143.
96
  awc.waitForEval("subject._currentConfig != null", 8000, 600,
96
  awc.waitFor(function () awc.window.gEmailConfigWizard._currentConfig != null,
97
                  awc.window.gEmailConfigWizard);
97
              "Timeout waiting for current config to become non-null",
98
              8000, 600);
98
  config = awc.window.gEmailConfigWizard._currentConfig;
99
  config = awc.window.gEmailConfigWizard._currentConfig;
99
  plan_for_window_close(awc);
100
  plan_for_window_close(awc);
100
  awc.e("create_button").click();
101
  awc.e("create_button").click();
101
102
102
  // Clean up
103
  // Clean up
103
  pref.clearUserPref(pref_name);
104
  pref.clearUserPref(pref_name);
104
  wait_for_window_close();
105
  wait_for_window_close();
105
  remove_account();
106
  remove_account();
(-)a/mail/test/mozmill/quick-filter-bar/test-display-issues.js (-1 / +2 lines)
Line     Link Here 
 Lines 56-72   function setupModule(module) { Link Here 
56
  let qfb = collector.getModule('quick-filter-bar-helper');
56
  let qfb = collector.getModule('quick-filter-bar-helper');
57
  qfb.installInto(module);
57
  qfb.installInto(module);
58
58
59
  folder = create_folder("QuickFilterBarDisplayIssues");
59
  folder = create_folder("QuickFilterBarDisplayIssues");
60
  be_in_folder(folder);
60
  be_in_folder(folder);
61
}
61
}
62
62
63
function wait_for_resize(width) {
63
function wait_for_resize(width) {
64
  mc.waitForEval("subject.outerWidth == " + width, 1000, 50, mc.window);
64
  mc.waitFor(function () (mc.window.outerWidth == width),
65
             "Timeout waiting for resize", 1000, 50);
65
}
66
}
66
67
67
function resize_to(width, height) {
68
function resize_to(width, height) {
68
  mark_action("test", "resize_to", [width, "x", height]);
69
  mark_action("test", "resize_to", [width, "x", height]);
69
  mc.window.resizeTo(width, height);
70
  mc.window.resizeTo(width, height);
70
  // Give the event loop a spin in order to let the reality of an asynchronously
71
  // Give the event loop a spin in order to let the reality of an asynchronously
71
  //  interacting window manager have its impact.  This still may not be
72
  //  interacting window manager have its impact.  This still may not be
72
  //  sufficient.
73
  //  sufficient.
(-)a/mail/test/mozmill/shared-modules/test-account-manager-helpers.js (-4 / +6 lines)
Line     Link Here 
 Lines 40-55   var Cc = Components.classes; Link Here 
40
var Cu = Components.utils;
40
var Cu = Components.utils;
41
41
42
var elib = {};
42
var elib = {};
43
Cu.import('resource://mozmill/modules/elementslib.js', elib);
43
Cu.import('resource://mozmill/modules/elementslib.js', elib);
44
var mozmill = {};
44
var mozmill = {};
45
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
45
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
46
var EventUtils = {};
46
var EventUtils = {};
47
Cu.import('resource://mozmill/stdlib/EventUtils.js', EventUtils);
47
Cu.import('resource://mozmill/stdlib/EventUtils.js', EventUtils);
48
var utils = {};
49
Cu.import('resource://mozmill/modules/utils.js', utils);
48
50
49
const MODULE_NAME = 'account-manager-helpers';
51
const MODULE_NAME = 'account-manager-helpers';
50
const RELATIVE_ROOT = '../shared-modules';
52
const RELATIVE_ROOT = '../shared-modules';
51
53
52
// we need this for the main controller
54
// we need this for the main controller
53
const MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers'];
55
const MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers'];
54
56
55
var wh, fdh, mc;
57
var wh, fdh, mc;
 Lines 98-115   function open_advanced_settings_from_acc Link Here 
98
100
99
/**
101
/**
100
 * Click a row in the account settings tree
102
 * Click a row in the account settings tree
101
 *
103
 *
102
 * @param controller the Mozmill controller for the account settings dialog
104
 * @param controller the Mozmill controller for the account settings dialog
103
 * @param rowIndex the row to click
105
 * @param rowIndex the row to click
104
 */
106
 */
105
function click_account_tree_row(controller, rowIndex) {
107
function click_account_tree_row(controller, rowIndex) {
106
  controller.waitForEval("subject.currentAccount != null", 6000, 600,
108
  utils.waitFor(function () controller.window.currentAccount != null,
107
                         controller.window);
109
                "Timeout waiting for currentAccount to become non-null");
108
110
109
  var tree = controller.window.document.getElementById("accounttree");
111
  var tree = controller.window.document.getElementById("accounttree");
110
  var selection = tree.view.selection;
112
  var selection = tree.view.selection;
111
  selection.select(rowIndex);
113
  selection.select(rowIndex);
112
  tree.treeBoxObject.ensureRowIsVisible(rowIndex);
114
  tree.treeBoxObject.ensureRowIsVisible(rowIndex);
113
115
114
  // get cell coordinates
116
  // get cell coordinates
115
  var x = {}, y = {}, width = {}, height = {};
117
  var x = {}, y = {}, width = {}, height = {};
 Lines 117-127   function click_account_tree_row(controll Link Here 
117
  tree.treeBoxObject.getCoordsForCellItem(rowIndex, column, "text",
119
  tree.treeBoxObject.getCoordsForCellItem(rowIndex, column, "text",
118
                                           x, y, width, height);
120
                                           x, y, width, height);
119
121
120
  controller.sleep(0);
122
  controller.sleep(0);
121
  EventUtils.synthesizeMouse(tree.body, x.value + 4, y.value + 4,
123
  EventUtils.synthesizeMouse(tree.body, x.value + 4, y.value + 4,
122
                             {}, tree.ownerDocument.defaultView);
124
                             {}, tree.ownerDocument.defaultView);
123
  controller.sleep(0);
125
  controller.sleep(0);
124
126
125
  controller.waitForEval("subject.pendingAccount == null", 6000, 600,
127
  utils.waitFor(function () controller.window.pendingAccount == null,
126
                         controller.window);
128
                "Timeout waiting for pendingAccount to become null");
127
}
129
}
(-)a/mail/test/mozmill/shared-modules/test-compose-helpers.js (-2 / +5 lines)
Line     Link Here 
 Lines 38-53    Link Here 
38
var Ci = Components.interfaces;
38
var Ci = Components.interfaces;
39
var Cc = Components.classes;
39
var Cc = Components.classes;
40
var Cu = Components.utils;
40
var Cu = Components.utils;
41
41
42
var elib = {};
42
var elib = {};
43
Cu.import('resource://mozmill/modules/elementslib.js', elib);
43
Cu.import('resource://mozmill/modules/elementslib.js', elib);
44
var mozmill = {};
44
var mozmill = {};
45
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
45
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
46
var utils = {};
47
Cu.import('resource://mozmill/modules/utils.js', utils);
46
48
47
const MODULE_NAME = 'compose-helpers';
49
const MODULE_NAME = 'compose-helpers';
48
50
49
const RELATIVE_ROOT = '../shared-modules';
51
const RELATIVE_ROOT = '../shared-modules';
50
52
51
// we need this for the main controller
53
// we need this for the main controller
52
const MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers'];
54
const MODULE_REQUIRES = ['folder-display-helpers', 'window-helpers'];
53
55
 Lines 219-236   function wait_for_compose_window(aContro Link Here 
219
          this.editorLoaded = true;
221
          this.editorLoaded = true;
220
        }
222
        }
221
      }
223
      }
222
    };
224
    };
223
225
224
    editor.commandManager.addCommandObserver(editorObserver,
226
    editor.commandManager.addCommandObserver(editorObserver,
225
                                             "obs_documentCreated");
227
                                             "obs_documentCreated");
226
228
227
    aController.waitForEval("subject.editorLoaded == true",
229
    utils.waitFor(function () editorObserver.editorLoaded,
228
                            10000, 100, editorObserver);
230
                  "Timeout waiting for compose window editor to load",
231
                  10000, 100);
229
232
230
    // Let the event queue clear.
233
    // Let the event queue clear.
231
    aController.sleep(0);
234
    aController.sleep(0);
232
235
233
    editor.commandManager.removeCommandObserver(editorObserver,
236
    editor.commandManager.removeCommandObserver(editorObserver,
234
                                                "obs_documentCreated");
237
                                                "obs_documentCreated");
235
  }
238
  }
236
239
(-)a/mail/test/mozmill/shared-modules/test-content-tab-helpers.js (-15 / +15 lines)
Line     Link Here 
 Lines 38-55    Link Here 
38
var Ci = Components.interfaces;
38
var Ci = Components.interfaces;
39
var Cc = Components.classes;
39
var Cc = Components.classes;
40
var Cu = Components.utils;
40
var Cu = Components.utils;
41
41
42
var elib = {};
42
var elib = {};
43
Cu.import('resource://mozmill/modules/elementslib.js', elib);
43
Cu.import('resource://mozmill/modules/elementslib.js', elib);
44
var mozmill = {};
44
var mozmill = {};
45
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
45
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
46
var controller = {};
46
var utils = {};
47
Cu.import('resource://mozmill/modules/controller.js', controller);
47
Cu.import('resource://mozmill/modules/utils.js', utils);
48
48
49
const MODULE_NAME = 'content-tab-helpers';
49
const MODULE_NAME = 'content-tab-helpers';
50
50
51
const RELATIVE_ROOT = '../shared-modules';
51
const RELATIVE_ROOT = '../shared-modules';
52
52
53
// we need this for the main controller
53
// we need this for the main controller
54
const MODULE_REQUIRES = ['folder-display-helpers'];
54
const MODULE_REQUIRES = ['folder-display-helpers'];
55
55
 Lines 106-125   function open_content_tab_with_url(aURL, Link Here 
106
    aBackground = false;
106
    aBackground = false;
107
  if (aController === undefined)
107
  if (aController === undefined)
108
    aController = mc;
108
    aController = mc;
109
109
110
  let preCount = mc.tabmail.tabContainer.childNodes.length;
110
  let preCount = mc.tabmail.tabContainer.childNodes.length;
111
  let newTab = mc.tabmail.openTab("contentTab", {contentPage: aURL,
111
  let newTab = mc.tabmail.openTab("contentTab", {contentPage: aURL,
112
                                                 background: aBackground,
112
                                                 background: aBackground,
113
                                                 clickHandler: aClickHandler});
113
                                                 clickHandler: aClickHandler});
114
  if (!controller.waitForEval("subject.childNodes.length == " + (preCount + 1),
114
  utils.waitFor(function () (
115
                              FAST_TIMEOUT, FAST_INTERVAL,
115
                  aController.tabmail.tabContainer.childNodes.length == preCount + 1),
116
                              aController.tabmail.tabContainer))
116
                "Timeout waiting for the content tab to open with URL: " + aURL,
117
    mark_failure(["Timeout waiting for the content tab to open with URL:", aURL]);
117
                FAST_TIMEOUT, FAST_INTERVAL);
118
118
119
  // We append new tabs at the end, so check the last one.
119
  // We append new tabs at the end, so check the last one.
120
  let expectedNewTab = aController.tabmail.tabInfo[preCount];
120
  let expectedNewTab = aController.tabmail.tabInfo[preCount];
121
  folderDisplayHelper.assert_selected_tab(expectedNewTab);
121
  folderDisplayHelper.assert_selected_tab(expectedNewTab);
122
  wait_for_content_tab_load(expectedNewTab);
122
  wait_for_content_tab_load(expectedNewTab);
123
  return expectedNewTab;
123
  return expectedNewTab;
124
}
124
}
125
125
 Lines 134-153   function open_content_tab_with_url(aURL, Link Here 
134
 * @returns The newly-opened tab.
134
 * @returns The newly-opened tab.
135
 */
135
 */
136
function open_content_tab_with_click(aElem, aController) {
136
function open_content_tab_with_click(aElem, aController) {
137
  if (aController === undefined)
137
  if (aController === undefined)
138
    aController = mc;
138
    aController = mc;
139
139
140
  let preCount = aController.tabmail.tabContainer.childNodes.length;
140
  let preCount = aController.tabmail.tabContainer.childNodes.length;
141
  aController.click(new elib.Elem(aElem));
141
  aController.click(new elib.Elem(aElem));
142
  if (!controller.waitForEval("subject.childNodes.length == " + (preCount + 1),
142
  utils.waitFor(function () (
143
                              FAST_TIMEOUT, FAST_INTERVAL,
143
                  aController.tabmail.tabContainer.childNodes.length == preCount + 1),
144
                              aController.tabmail.tabContainer))
144
                "Timeout waiting for the content tab to open",
145
    mark_failure(["Timeout waiting for the content tab to open"]);
145
                FAST_TIMEOUT, FAST_INTERVAL);
146
146
147
  // We append new tabs at the end, so check the last one.
147
  // We append new tabs at the end, so check the last one.
148
  let expectedNewTab = aController.tabmail.tabInfo[preCount];
148
  let expectedNewTab = aController.tabmail.tabInfo[preCount];
149
  folderDisplayHelper.assert_selected_tab(expectedNewTab);
149
  folderDisplayHelper.assert_selected_tab(expectedNewTab);
150
  folderDisplayHelper.assert_tab_mode_name(expectedNewTab, "contentTab");
150
  folderDisplayHelper.assert_tab_mode_name(expectedNewTab, "contentTab");
151
  wait_for_content_tab_load(expectedNewTab);
151
  wait_for_content_tab_load(expectedNewTab);
152
  return expectedNewTab;
152
  return expectedNewTab;
153
}
153
}
 Lines 186-204   function wait_for_content_tab_load(aTab) Link Here 
186
      return false;
186
      return false;
187
    // Also require that our tab infrastructure thinks that the page is loaded.
187
    // Also require that our tab infrastructure thinks that the page is loaded.
188
    if (aTab.busy)
188
    if (aTab.busy)
189
      return false;
189
      return false;
190
    // Finally, require that the tab's browser thinks that no page is being loaded.
190
    // Finally, require that the tab's browser thinks that no page is being loaded.
191
    return !(aTab.browser.isLoadingDocument);
191
    return !(aTab.browser.isLoadingDocument);
192
  }
192
  }
193
193
194
  if (!controller.waitForEval("subject()", NORMAL_TIMEOUT, FAST_INTERVAL,
194
  utils.waitFor(isLoadedChecker,
195
                              isLoadedChecker))
195
                "Timeout waiting for the content tab page to load.");
196
    mark_failure(["Timeout waiting for the content tab page to load."]);
197
  // the above may return immediately, meaning the event queue might not get a
196
  // the above may return immediately, meaning the event queue might not get a
198
  //  chance.  give it a chance now.
197
  //  chance.  give it a chance now.
199
  mc.sleep(0);
198
  mc.sleep(0);
200
}
199
}
201
200
202
/**
201
/**
203
 * Assert that the given content tab has the given URL (string) loaded.
202
 * Assert that the given content tab has the given URL (string) loaded.
204
 */
203
 */
 Lines 264-281   function assert_content_tab_element_visi Link Here 
264
263
265
/**
264
/**
266
 * Waits for the element's display property to be the given value.
265
 * Waits for the element's display property to be the given value.
267
 */
266
 */
268
function wait_for_content_tab_element_display_value(aTab, aElem, aValue) {
267
function wait_for_content_tab_element_display_value(aTab, aElem, aValue) {
269
  function isValue() {
268
  function isValue() {
270
    return get_content_tab_element_display(aTab, aElem) == aValue;
269
    return get_content_tab_element_display(aTab, aElem) == aValue;
271
  }
270
  }
272
  if (!controller.waitForEval("subject()", NORMAL_TIMEOUT, FAST_INTERVAL,
271
  try {
273
                              isValue)) {
272
    utils.waitFor(isValue);
273
  } catch (e if e instanceof utils.TimeoutError) {
274
    mark_failure(["Timeout waiting for element", aElem, "to have display value",
274
    mark_failure(["Timeout waiting for element", aElem, "to have display value",
275
                  aValue]);
275
                  aValue]);
276
  }
276
  }
277
}
277
}
278
278
279
/**
279
/**
280
 * Asserts that the given text is present on the content tab's page.
280
 * Asserts that the given text is present on the content tab's page.
281
 */
281
 */
(-)a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js (-25 / +31 lines)
Line     Link Here 
 Lines 45-60   Cu.import('resource://mozmill/stdlib/Eve Link Here 
45
var mozmill = {};
45
var mozmill = {};
46
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
46
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
47
var controller = {};
47
var controller = {};
48
Cu.import('resource://mozmill/modules/controller.js', controller);
48
Cu.import('resource://mozmill/modules/controller.js', controller);
49
var frame = {};
49
var frame = {};
50
Cu.import('resource://mozmill/modules/frame.js', frame);
50
Cu.import('resource://mozmill/modules/frame.js', frame);
51
var os = {};
51
var os = {};
52
Cu.import('resource://mozmill/stdlib/os.js', os);
52
Cu.import('resource://mozmill/stdlib/os.js', os);
53
var utils = {};
54
Cu.import('resource://mozmill/modules/utils.js', utils);
53
55
54
Cu.import("resource:///modules/gloda/log4moz.js");
56
Cu.import("resource:///modules/gloda/log4moz.js");
55
57
56
const MODULE_NAME = 'folder-display-helpers';
58
const MODULE_NAME = 'folder-display-helpers';
57
59
58
const RELATIVE_ROOT = '../shared-modules';
60
const RELATIVE_ROOT = '../shared-modules';
59
// we need window-helpers for augment_controller
61
// we need window-helpers for augment_controller
60
const MODULE_REQUIRES = ['window-helpers'];
62
const MODULE_REQUIRES = ['window-helpers'];
 Lines 409-427   function teardownImporter(customTeardown Link Here 
409
/*
411
/*
410
 * Although we all agree that the use of generators when dealing with async
412
 * Although we all agree that the use of generators when dealing with async
411
 *  operations is awesome, the mozmill idiom is for calls to be synchronous and
413
 *  operations is awesome, the mozmill idiom is for calls to be synchronous and
412
 *  just spin event loops when they need to wait for things to happen.  This
414
 *  just spin event loops when they need to wait for things to happen.  This
413
 *  does make the test code significantly less confusing, so we do it too.
415
 *  does make the test code significantly less confusing, so we do it too.
414
 * All of our operations are synchronous and just spin until they are happy.
416
 * All of our operations are synchronous and just spin until they are happy.
415
 */
417
 */
416
418
417
const NORMAL_TIMEOUT = 6000;
418
const FAST_INTERVAL = 100;
419
420
/**
419
/**
421
 * Create a folder and rebuild the folder tree view.
420
 * Create a folder and rebuild the folder tree view.
422
 */
421
 */
423
function create_folder(aFolderName) {
422
function create_folder(aFolderName) {
424
  let folder = testHelperModule.make_empty_folder(aFolderName);
423
  let folder = testHelperModule.make_empty_folder(aFolderName);
425
  mc.folderTreeView.mode = "all";
424
  mc.folderTreeView.mode = "all";
426
  return folder;
425
  return folder;
427
}
426
}
 Lines 483-501   function enter_folder(aFolder) { Link Here 
483
  mark_action("fdh", "enter_folder", [aFolder]);
482
  mark_action("fdh", "enter_folder", [aFolder]);
484
483
485
  // this selection event may not be synchronous...
484
  // this selection event may not be synchronous...
486
  mc.folderTreeView.selectFolder(aFolder);
485
  mc.folderTreeView.selectFolder(aFolder);
487
  // ... so wait until it goes through by waiting on the displayedFolder...
486
  // ... so wait until it goes through by waiting on the displayedFolder...
488
  function isDisplayedFolder() {
487
  function isDisplayedFolder() {
489
    return mc.folderDisplay.displayedFolder == aFolder;
488
    return mc.folderDisplay.displayedFolder == aFolder;
490
  }
489
  }
491
  if (!controller.waitForEval('subject()', NORMAL_TIMEOUT, FAST_INTERVAL,
490
  utils.waitFor(isDisplayedFolder,
492
                              isDisplayedFolder))
491
                "Timeout trying to enter folder" + aFolder.URI);
493
    mark_failure(["Timeout trying to enter folder", aFolder.URI]);
494
492
495
  wait_for_all_messages_to_load();
493
  wait_for_all_messages_to_load();
496
494
497
  // and drain the event queue
495
  // and drain the event queue
498
  controller.sleep(0);
496
  controller.sleep(0);
499
}
497
}
500
498
501
/**
499
/**
 Lines 872-889   function select_none(aController) { Link Here 
872
  focus_thread_tree();
870
  focus_thread_tree();
873
  aController.dbView.selection.clearSelection();
871
  aController.dbView.selection.clearSelection();
874
  // Because the selection event may not be generated immediately, we need to
872
  // Because the selection event may not be generated immediately, we need to
875
  //  spin until the message display thinks it is not displaying a message,
873
  //  spin until the message display thinks it is not displaying a message,
876
  //  which is the sign that the event actually happened.
874
  //  which is the sign that the event actually happened.
877
  function noMessageChecker() {
875
  function noMessageChecker() {
878
    return aController.messageDisplay.displayedMessage == null;
876
    return aController.messageDisplay.displayedMessage == null;
879
  }
877
  }
880
  controller.sleep('subject()',
878
  try {
881
                   NORMAL_TIMEOUT, FAST_INTERVAL, noMessageChecker);
879
    utils.waitFor(noMessageChecker);
880
  } catch (e if e instanceof utils.TimeoutError) {
881
    mark_failure(["Timeout waiting for displayedMessage to become null.",
882
                  "Current value: ",
883
                  aController.messageDisplay.displayedMessage]);
884
  }
882
  wait_for_blank_content_pane(aController);
885
  wait_for_blank_content_pane(aController);
883
}
886
}
884
887
885
/**
888
/**
886
 * Normalize a view index to be an absolute index, handling slice-style negative
889
 * Normalize a view index to be an absolute index, handling slice-style negative
887
 *  references as well as piercing complex things like message headers and
890
 *  references as well as piercing complex things like message headers and
888
 *  synthetic message sets.
891
 *  synthetic message sets.
889
 *
892
 *
 Lines 1357-1373   function delete_via_popup() { Link Here 
1357
  mc.click(mc.eid("mailContext-delete"));
1360
  mc.click(mc.eid("mailContext-delete"));
1358
  // for reasons unknown, the pop-up does not close itself?
1361
  // for reasons unknown, the pop-up does not close itself?
1359
  close_popup(mc, mc.eid("mailContext"));
1362
  close_popup(mc, mc.eid("mailContext"));
1360
  wait_for_folder_events();
1363
  wait_for_folder_events();
1361
}
1364
}
1362
1365
1363
function wait_for_popup_to_open(popupElem) {
1366
function wait_for_popup_to_open(popupElem) {
1364
  mark_action("fdh", "wait_for_popup_to_open", [popupElem]);
1367
  mark_action("fdh", "wait_for_popup_to_open", [popupElem]);
1365
  mc.waitForEval("subject.state == 'open'", 1000, 50, popupElem);
1368
  utils.waitFor(function () popupElem.state == "open",
1369
                "Timeout waiting for popup to open", 1000, 50);
1366
}
1370
}
1367
1371
1368
/**
1372
/**
1369
 * Close the open pop-up.
1373
 * Close the open pop-up.
1370
 */
1374
 */
1371
function close_popup(aController, eid) {
1375
function close_popup(aController, eid) {
1372
  if (aController == null)
1376
  if (aController == null)
1373
    aController = mc;
1377
    aController = mc;
 Lines 1380-1398   function close_popup(aController, eid) { Link Here 
1380
  }
1384
  }
1381
  mark_action("fdh", "close_popup", [elem]);
1385
  mark_action("fdh", "close_popup", [elem]);
1382
  // if it's in the process of closing, don't push escape
1386
  // if it's in the process of closing, don't push escape
1383
  if (elem.state == "hiding")
1387
  if (elem.state == "hiding")
1384
    mark_action("fdh", "close_popup",
1388
    mark_action("fdh", "close_popup",
1385
                ["popup suspiciously already closing..."]);
1389
                ["popup suspiciously already closing..."]);
1386
  else // actually push escape because it's not closing/closed
1390
  else // actually push escape because it's not closing/closed
1387
    aController.keypress(eid, "VK_ESCAPE", {});
1391
    aController.keypress(eid, "VK_ESCAPE", {});
1388
   if (!controller.waitForEval("subject.state == 'closed'", 1000, 50,
1392
  utils.waitFor(function () elem.state == "closed", "Popup did not close!",
1389
                               elem))
1393
                1000, 50);
1390
     throw new Error("Popup did not close!");
1391
}
1394
}
1392
1395
1393
/**
1396
/**
1394
 * Pretend we are pressing the delete key, triggering message deletion of the
1397
 * Pretend we are pressing the delete key, triggering message deletion of the
1395
 *  selected messages.
1398
 *  selected messages.
1396
 *
1399
 *
1397
 * @param aController The controller in whose context to do this, defaults to
1400
 * @param aController The controller in whose context to do this, defaults to
1398
 *     |mc| if omitted.
1401
 *     |mc| if omitted.
 Lines 1437-1455   function archive_selected_messages(aCont Link Here 
1437
  if (expectedCount && aController.messageDisplay.visible)
1440
  if (expectedCount && aController.messageDisplay.visible)
1438
    plan_for_message_display(aController);
1441
    plan_for_message_display(aController);
1439
  aController.keypress(null, "a", {});
1442
  aController.keypress(null, "a", {});
1440
1443
1441
  // Wait for the view rowCount to decrease by the number of selected messages.
1444
  // Wait for the view rowCount to decrease by the number of selected messages.
1442
  let messagesDeletedFromView = function() {
1445
  let messagesDeletedFromView = function() {
1443
    return aController.dbView.rowCount == expectedCount;
1446
    return aController.dbView.rowCount == expectedCount;
1444
  };
1447
  };
1445
  controller.waitForEval('subject()',
1448
  utils.waitFor(messagesDeletedFromView,
1446
                         NORMAL_TIMEOUT,
1449
                "Timeout waiting for messages to be archived");
1447
                         FAST_INTERVAL, messagesDeletedFromView);
1448
  wait_for_message_display_completion(
1450
  wait_for_message_display_completion(
1449
    aController, expectedCount && aController.messageDisplay.visible);
1451
    aController, expectedCount && aController.messageDisplay.visible);
1450
  // The above may return immediately, meaning the event queue might not get a
1452
  // The above may return immediately, meaning the event queue might not get a
1451
  //  chance.  give it a chance now.
1453
  //  chance.  give it a chance now.
1452
  aController.sleep(0);
1454
  aController.sleep(0);
1453
}
1455
}
1454
1456
1455
/**
1457
/**
 Lines 1481-1499   function press_enter(aController) { Link Here 
1481
 *  search.
1483
 *  search.
1482
 * This method is generally called automatically most of the time, and you
1484
 * This method is generally called automatically most of the time, and you
1483
 *  should not need to call it yourself unless you are operating outside the
1485
 *  should not need to call it yourself unless you are operating outside the
1484
 *  helper methods in this file.
1486
 *  helper methods in this file.
1485
 */
1487
 */
1486
function wait_for_all_messages_to_load(aController) {
1488
function wait_for_all_messages_to_load(aController) {
1487
  if (aController == null)
1489
  if (aController == null)
1488
    aController = mc;
1490
    aController = mc;
1489
  if (!controller.waitForEval('subject.allMessagesLoaded', NORMAL_TIMEOUT,
1491
  utils.waitFor(function () aController.folderDisplay.allMessagesLoaded,
1490
                              FAST_INTERVAL, aController.folderDisplay))
1492
                "Messages never finished loading.  Timed Out.");
1491
    mark_failure(["Messages never finished loading.  Timed Out."]);
1492
  // the above may return immediately, meaning the event queue might not get a
1493
  // the above may return immediately, meaning the event queue might not get a
1493
  //  chance.  give it a chance now.
1494
  //  chance.  give it a chance now.
1494
  aController.sleep(0);
1495
  aController.sleep(0);
1495
}
1496
}
1496
1497
1497
/**
1498
/**
1498
 * Call this before triggering a message display that you are going to wait for
1499
 * Call this before triggering a message display that you are going to wait for
1499
 *  using |wait_for_message_display_completion| where you are passing true for
1500
 *  using |wait_for_message_display_completion| where you are passing true for
 Lines 1590-1608   function wait_for_message_display_comple Link Here 
1590
      let urlRunningObj = {};
1591
      let urlRunningObj = {};
1591
      uri.GetUrlState(urlRunningObj);
1592
      uri.GetUrlState(urlRunningObj);
1592
      // GetUrlState returns true if the url is still running
1593
      // GetUrlState returns true if the url is still running
1593
      return !urlRunningObj.value;
1594
      return !urlRunningObj.value;
1594
    }
1595
    }
1595
    // not a mailnews URL, just check the busy flags...
1596
    // not a mailnews URL, just check the busy flags...
1596
    return !docShell.busyFlags;
1597
    return !docShell.busyFlags;
1597
  };
1598
  };
1598
  if (!controller.waitForEval('subject()', NORMAL_TIMEOUT, FAST_INTERVAL,
1599
  utils.waitFor(isLoadedChecker,
1599
                              isLoadedChecker))
1600
                "Timed out waiting for message display completion.");
1600
    mark_failure(["Timed out waiting for message display completion."]);
1601
  // the above may return immediately, meaning the event queue might not get a
1601
  // the above may return immediately, meaning the event queue might not get a
1602
  //  chance.  give it a chance now.
1602
  //  chance.  give it a chance now.
1603
  aController.sleep(0);
1603
  aController.sleep(0);
1604
  mark_action("fdhb", "/wait_for_message_display_completion",
1604
  mark_action("fdhb", "/wait_for_message_display_completion",
1605
              ["waited?", checkCount > 1]);
1605
              ["waited?", checkCount > 1]);
1606
}
1606
}
1607
1607
1608
/**
1608
/**
 Lines 1615-1634   function wait_for_message_display_comple Link Here 
1615
function wait_for_blank_content_pane(aController) {
1615
function wait_for_blank_content_pane(aController) {
1616
  if (aController == null)
1616
  if (aController == null)
1617
    aController = mc;
1617
    aController = mc;
1618
  mark_action("fdh", "wait_for_blank_content_pane", []);
1618
  mark_action("fdh", "wait_for_blank_content_pane", []);
1619
1619
1620
  let isBlankChecker = function() {
1620
  let isBlankChecker = function() {
1621
    return aController.window.content.location.href == "about:blank";
1621
    return aController.window.content.location.href == "about:blank";
1622
  };
1622
  };
1623
  if (!controller.waitForEval('subject()', NORMAL_TIMEOUT, FAST_INTERVAL,
1623
  try {
1624
                              isBlankChecker))
1624
    utils.waitFor(isBlankChecker);
1625
  } catch (e if e instanceof utils.TimeoutError) {
1625
    mark_failure(["Timeout waiting for blank content pane.  Current location:",
1626
    mark_failure(["Timeout waiting for blank content pane.  Current location:",
1626
                  aController.window.content.location.href]);
1627
                  aController.window.content.location.href]);
1628
  }
1629
1627
  // the above may return immediately, meaning the event queue might not get a
1630
  // the above may return immediately, meaning the event queue might not get a
1628
  //  chance.  give it a chance now.
1631
  //  chance.  give it a chance now.
1629
  aController.sleep(0);
1632
  aController.sleep(0);
1630
  mark_action("fdh", "/wait_for_blank_content_pane", []);
1633
  mark_action("fdh", "/wait_for_blank_content_pane", []);
1631
}
1634
}
1632
1635
1633
1636
1634
var FolderListener = {
1637
var FolderListener = {
 Lines 1652-1670   var FolderListener = { Link Here 
1652
    this.sawEvents = false;
1655
    this.sawEvents = false;
1653
    this.watchingFor = [];
1656
    this.watchingFor = [];
1654
    for (let i = 0; i < arguments.length; i++)
1657
    for (let i = 0; i < arguments.length; i++)
1655
      this.watchingFor[i] = arguments[i];
1658
      this.watchingFor[i] = arguments[i];
1656
  },
1659
  },
1657
  waitForEvents: function FolderListener_waitForEvents() {
1660
  waitForEvents: function FolderListener_waitForEvents() {
1658
    if (this.sawEvents)
1661
    if (this.sawEvents)
1659
      return;
1662
      return;
1660
    if (!controller.waitForEval('subject.sawEvents', NORMAL_TIMEOUT,
1663
    let self = this;
1661
                                FAST_INTERVAL, this))
1664
    try {
1665
      utils.waitFor(function () self.sawEvents);
1666
    } catch (e if e instanceof utils.TimeoutError) {
1662
      mark_failure(["Timeout waiting for events:", this.watchingFor]);
1667
      mark_failure(["Timeout waiting for events:", this.watchingFor]);
1668
    }
1663
  },
1669
  },
1664
1670
1665
  OnItemEvent: function FolderNotificationHelper_OnItemEvent(
1671
  OnItemEvent: function FolderNotificationHelper_OnItemEvent(
1666
      aFolder, aEvent) {
1672
      aFolder, aEvent) {
1667
    if (!this.watchingFor)
1673
    if (!this.watchingFor)
1668
      return;
1674
      return;
1669
    if (this.watchingFor.indexOf(aEvent.toString()) != -1) {
1675
    if (this.watchingFor.indexOf(aEvent.toString()) != -1) {
1670
      this.watchingFor = null;
1676
      this.watchingFor = null;
(-)a/mail/test/mozmill/shared-modules/test-junk-helpers.js (-10 / +6 lines)
Line     Link Here 
 Lines 38-66    Link Here 
38
var Ci = Components.interfaces;
38
var Ci = Components.interfaces;
39
var Cc = Components.classes;
39
var Cc = Components.classes;
40
var Cu = Components.utils;
40
var Cu = Components.utils;
41
41
42
var elib = {};
42
var elib = {};
43
Cu.import('resource://mozmill/modules/elementslib.js', elib);
43
Cu.import('resource://mozmill/modules/elementslib.js', elib);
44
var mozmill = {};
44
var mozmill = {};
45
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
45
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
46
var controller = {};
46
var utils = {};
47
Cu.import('resource://mozmill/modules/controller.js', controller);
47
Cu.import("resource://mozmill/modules/utils.js", utils);
48
48
49
const MODULE_NAME = 'junk-helpers';
49
const MODULE_NAME = 'junk-helpers';
50
50
51
const RELATIVE_ROOT = '../shared-modules';
51
const RELATIVE_ROOT = '../shared-modules';
52
52
53
// we need this for the main controller
53
// we need this for the main controller
54
const MODULE_REQUIRES = ['folder-display-helpers'];
54
const MODULE_REQUIRES = ['folder-display-helpers'];
55
55
56
const NORMAL_TIMEOUT = 6000;
57
const FAST_INTERVAL = 100;
58
59
var folderDisplayHelper;
56
var folderDisplayHelper;
60
var mc;
57
var mc;
61
58
62
// logHelper (and therefore folderDisplayHelper) exports
59
// logHelper (and therefore folderDisplayHelper) exports
63
var mark_failure;
60
var mark_failure;
64
61
65
function setupModule() {
62
function setupModule() {
66
  folderDisplayHelper = collector.getModule('folder-display-helpers');
63
  folderDisplayHelper = collector.getModule('folder-display-helpers');
 Lines 169-189   function delete_mail_marked_as_junk(aNum Link Here 
169
    //       allow listeners to be passed in.
166
    //       allow listeners to be passed in.
170
    //
167
    //
171
    // The solution adopted is to use a combination of 3 and having
168
    // The solution adopted is to use a combination of 3 and having
172
    // deleteJunkInFolder return the number of messages deleted. This embraces
169
    // deleteJunkInFolder return the number of messages deleted. This embraces
173
    // the unavoidability of a) above, solves b), and side-steps c) (which is
170
    // the unavoidability of a) above, solves b), and side-steps c) (which is
174
    // fine, because we already have all sorts of events when messages are
171
    // fine, because we already have all sorts of events when messages are
175
    // deleted). The only assumption is that deleteJunkInFolder is synchronous
172
    // deleted). The only assumption is that deleteJunkInFolder is synchronous
176
    // if no messages are deleted.
173
    // if no messages are deleted.
177
    if (!controller.waitForEval("subject != null", NORMAL_TIMEOUT,
174
    utils.waitFor(function () numMessagesDeleted != null,
178
                                FAST_INTERVAL, numMessagesDeleted))
175
                  "Timeout waiting for numMessagesDeleted to turn " +
179
      mark_failure(["Timeout waiting for numMessagesDeleted to turn " +
176
                  "non-null. This either means that deleteJunkInFolder " +
180
                    "non-null. This either means that deleteJunkInFolder " +
177
                  "didn't get called or that it didn't return a value.");
181
                    "didn't get called or that it didn't return a value."]);
182
178
183
    // Check the number of deleted messages.
179
    // Check the number of deleted messages.
184
    if (aNumDeletesExpected != numMessagesDeleted)
180
    if (aNumDeletesExpected != numMessagesDeleted)
185
      mark_failure(["Expected", aNumDeletesExpected, "deletes, but",
181
      mark_failure(["Expected", aNumDeletesExpected, "deletes, but",
186
                    numMessagesDeleted, "happened"]);
182
                    numMessagesDeleted, "happened"]);
187
  }
183
  }
188
  finally {
184
  finally {
189
    aController.window.deleteJunkInFolder = realDeleteJunkInFolder;
185
    aController.window.deleteJunkInFolder = realDeleteJunkInFolder;
(-)a/mail/test/mozmill/shared-modules/test-pref-window-helpers.js (-10 / +4 lines)
Line     Link Here 
 Lines 39-66    Link Here 
39
/*
39
/*
40
 * Helpers to deal with the preferences window.
40
 * Helpers to deal with the preferences window.
41
 */
41
 */
42
42
43
var Ci = Components.interfaces;
43
var Ci = Components.interfaces;
44
var Cc = Components.classes;
44
var Cc = Components.classes;
45
var Cu = Components.utils;
45
var Cu = Components.utils;
46
46
47
var controller = {};
47
var utils = {};
48
Cu.import("resource://mozmill/modules/controller.js", controller);
48
Cu.import("resource://mozmill/modules/utils.js", utils);
49
49
50
const MODULE_NAME = "pref-window-helpers";
50
const MODULE_NAME = "pref-window-helpers";
51
51
52
const RELATIVE_ROOT = "../shared-modules";
52
const RELATIVE_ROOT = "../shared-modules";
53
53
54
const MODULE_REQUIRES = ["folder-display-helpers", "window-helpers"];
54
const MODULE_REQUIRES = ["folder-display-helpers", "window-helpers"];
55
55
56
const NORMAL_TIMEOUT = 6000;
57
const FAST_INTERVAL = 100;
58
59
var fdh;
56
var fdh;
60
var wh;
57
var wh;
61
58
62
function setupModule() {
59
function setupModule() {
63
  fdh = collector.getModule("folder-display-helpers");
60
  fdh = collector.getModule("folder-display-helpers");
64
  wh = collector.getModule("window-helpers");
61
  wh = collector.getModule("window-helpers");
65
}
62
}
66
63
 Lines 86-105   function installInto(module) { Link Here 
86
 */
83
 */
87
function open_pref_window(aPaneID, aCallback) {
84
function open_pref_window(aPaneID, aCallback) {
88
  function waitForPaneLoad(prefc) {
85
  function waitForPaneLoad(prefc) {
89
    let pane = prefc.e(aPaneID);
86
    let pane = prefc.e(aPaneID);
90
    function paneLoadedChecker() {
87
    function paneLoadedChecker() {
91
      return pane.loaded;
88
      return pane.loaded;
92
    }
89
    }
93
90
94
    if (!controller.waitForEval("subject()", NORMAL_TIMEOUT, FAST_INTERVAL,
91
    utils.waitFor(paneLoadedChecker,
95
                                paneLoadedChecker))
92
                  "Timed out waiting for prefpane " + aPaneID + " to load.");
96
      throw new Error("Timed out waiting for prefpane " + aPaneID +
97
                      " to load.");
98
99
    aCallback(prefc);
93
    aCallback(prefc);
100
  }
94
  }
101
95
102
  wh.plan_for_modal_dialog("Mail:Preferences", waitForPaneLoad);
96
  wh.plan_for_modal_dialog("Mail:Preferences", waitForPaneLoad);
103
  fdh.mc.window.openOptionsDialog(aPaneID);
97
  fdh.mc.window.openOptionsDialog(aPaneID);
104
  wh.wait_for_modal_dialog("Mail:Preferences");
98
  wh.wait_for_modal_dialog("Mail:Preferences");
105
}
99
}
(-)a/mail/test/mozmill/shared-modules/test-window-helpers.js (-34 / +29 lines)
Line     Link Here 
 Lines 42-57   var Cu = Components.utils; Link Here 
42
var mozmill = {};
42
var mozmill = {};
43
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
43
Cu.import('resource://mozmill/modules/mozmill.js', mozmill);
44
var controller = {};
44
var controller = {};
45
Cu.import('resource://mozmill/modules/controller.js', controller);
45
Cu.import('resource://mozmill/modules/controller.js', controller);
46
var elib = {};
46
var elib = {};
47
Cu.import('resource://mozmill/modules/elementslib.js', elib);
47
Cu.import('resource://mozmill/modules/elementslib.js', elib);
48
var frame = {};
48
var frame = {};
49
Cu.import('resource://mozmill/modules/frame.js', frame);
49
Cu.import('resource://mozmill/modules/frame.js', frame);
50
var utils = {};
51
Cu.import('resource://mozmill/modules/utils.js', utils);
50
52
51
Cu.import('resource:///modules/iteratorUtils.jsm');
53
Cu.import('resource:///modules/iteratorUtils.jsm');
52
54
53
const MODULE_NAME = 'window-helpers';
55
const MODULE_NAME = 'window-helpers';
54
56
55
/**
57
/**
56
 * Timeout to use when waiting for the first window ever to load.  This is
58
 * Timeout to use when waiting for the first window ever to load.  This is
57
 *  long because we are basically waiting for the entire app startup process.
59
 *  long because we are basically waiting for the entire app startup process.
 Lines 270-293   var WindowWatcher = { Link Here 
270
  waitingForOpen: null,
272
  waitingForOpen: null,
271
  /**
273
  /**
272
   * Wait for the given windowType to open and finish loading.
274
   * Wait for the given windowType to open and finish loading.
273
   *
275
   *
274
   * @return The window wrapped in a MozMillController.
276
   * @return The window wrapped in a MozMillController.
275
   */
277
   */
276
  waitForWindowOpen: function WindowWatcher_waitForWindowOpen(aWindowType) {
278
  waitForWindowOpen: function WindowWatcher_waitForWindowOpen(aWindowType) {
277
    this.waitingForOpen = aWindowType;
279
    this.waitingForOpen = aWindowType;
278
    if (!controller.waitForEval(
280
    utils.waitFor(function () this.monitorizeOpen(),
279
          'subject.monitorizeOpen()',
281
                  "Timed out waiting for window open!",
280
          this._firstWindowOpened ? WINDOW_OPEN_TIMEOUT_MS
282
                  this._firstWindowOpened ? WINDOW_OPEN_TIMEOUT_MS
281
            : FIRST_WINDOW_EVER_TIMEOUT_MS,
283
                    : FIRST_WINDOW_EVER_TIMEOUT_MS,
282
          this._firstWindowOpened ? WINDOW_OPEN_CHECK_INTERVAL_MS
284
                  this._firstWindowOpened ? WINDOW_OPEN_CHECK_INTERVAL_MS
283
            : FIRST_WINDOW_CHECK_INTERVAL_MS,
285
                    : FIRST_WINDOW_CHECK_INTERVAL_MS,
284
          this))
286
                  this);
285
      throw new Error("Timed out waiting for window open!");
287
286
    this.waitingForOpen = null;
288
    this.waitingForOpen = null;
287
    let xulWindow = this.waitingList[aWindowType];
289
    let xulWindow = this.waitingList[aWindowType];
288
    let domWindow = xulWindow.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
290
    let domWindow = xulWindow.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
289
                                      .getInterface(Ci.nsIDOMWindowInternal);
291
                                      .getInterface(Ci.nsIDOMWindowInternal);
290
    delete this.waitingList[aWindowType];
292
    delete this.waitingList[aWindowType];
291
    // spin the event loop to make sure any setTimeout 0 calls have gotten their
293
    // spin the event loop to make sure any setTimeout 0 calls have gotten their
292
    //  time in the sun.
294
    //  time in the sun.
293
    controller.sleep(0);
295
    controller.sleep(0);
 Lines 296-313   var WindowWatcher = { Link Here 
296
    mark_action("winhelp", "new MozMillController()", [aWindowType]);
298
    mark_action("winhelp", "new MozMillController()", [aWindowType]);
297
    let c = new controller.MozMillController(domWindow);
299
    let c = new controller.MozMillController(domWindow);
298
    mark_action("winhelp", "/new MozMillController()", [aWindowType]);
300
    mark_action("winhelp", "/new MozMillController()", [aWindowType]);
299
    return c;
301
    return c;
300
  },
302
  },
301
303
302
  /**
304
  /**
303
   * Because the modal dialog spins its own event loop, the mozmill idiom of
305
   * Because the modal dialog spins its own event loop, the mozmill idiom of
304
   *  spinning your own event-loop as performed by waitForEval is no good.  We
306
   *  spinning your own event-loop as performed by waitFor is no good.  We use
305
   *  use this timer to generate our events so that we can have a waitForEval
307
   *  this timer to generate our events so that we can have a waitFor
306
   *  equivalent.
308
   *  equivalent.
307
   *
309
   *
308
   * We only have one timer right now because modal dialogs that spawn modal
310
   * We only have one timer right now because modal dialogs that spawn modal
309
   *  dialogs are not tremendously likely.
311
   *  dialogs are not tremendously likely.
310
   */
312
   */
311
  _timer: null,
313
  _timer: null,
312
  _timerRuntimeSoFar: 0,
314
  _timerRuntimeSoFar: 0,
313
  /**
315
  /**
 Lines 372-391   var WindowWatcher = { Link Here 
372
   * Symmetry for planForModalDialog; conceptually provides the waiting.  In
374
   * Symmetry for planForModalDialog; conceptually provides the waiting.  In
373
   *  reality, all we do is potentially soak up the event loop a little to
375
   *  reality, all we do is potentially soak up the event loop a little to
374
   */
376
   */
375
  waitForModalDialog: function WindowWatcher_waitForModalDialog(aWindowType, aTimeout) {
377
  waitForModalDialog: function WindowWatcher_waitForModalDialog(aWindowType, aTimeout) {
376
    // did the window already come and go?
378
    // did the window already come and go?
377
    if (this.subTestFunc == null)
379
    if (this.subTestFunc == null)
378
      return;
380
      return;
379
    // spin the event loop until we the window has come and gone.
381
    // spin the event loop until we the window has come and gone.
380
    if (!controller.waitForEval(
382
    utils.waitFor(function () (this.waitingForOpen == null &&
381
           'subject.waitingForOpen == null && subject.monitorizeClose()',
383
                               this.monitorizeClose()),
382
            aTimeout || WINDOW_OPEN_TIMEOUT_MS, WINDOW_OPEN_CHECK_INTERVAL_MS, this))
384
                  "Timeout waiting for modal dialog to open.",
383
      throw new Error("Timeout waiting for modal dialog to open.");
385
                  aTimeout || WINDOW_OPEN_TIMEOUT_MS,
386
                  WINDOW_OPEN_CHECK_INTERVAL_MS, this);
384
    this.waitingForClose = null;
387
    this.waitingForClose = null;
385
  },
388
  },
386
389
387
  planForWindowClose: function WindowWatcher_planForWindowClose(aXULWindow) {
390
  planForWindowClose: function WindowWatcher_planForWindowClose(aXULWindow) {
388
    let windowType =
391
    let windowType =
389
      aXULWindow.document.documentElement.getAttribute("windowtype") ||
392
      aXULWindow.document.documentElement.getAttribute("windowtype") ||
390
      aXULWindow.document.documentElement.getAttribute("id");
393
      aXULWindow.document.documentElement.getAttribute("id");
391
    this.waitingList[windowType] = aXULWindow;
394
    this.waitingList[windowType] = aXULWindow;
 Lines 393-412   var WindowWatcher = { Link Here 
393
  },
396
  },
394
397
395
  /**
398
  /**
396
   * The current windowType we are waiting to close.  Same deal as
399
   * The current windowType we are waiting to close.  Same deal as
397
   *  waitingForOpen, this makes the eval less crazy.
400
   *  waitingForOpen, this makes the eval less crazy.
398
   */
401
   */
399
  waitingForClose: null,
402
  waitingForClose: null,
400
  waitForWindowClose: function WindowWatcher_waitForWindowClose() {
403
  waitForWindowClose: function WindowWatcher_waitForWindowClose() {
401
    if (!controller.waitForEval('subject.monitorizeClose()',
404
    utils.waitFor(function () this.monitorizeClose(),
402
                                WINDOW_CLOSE_TIMEOUT_MS,
405
                  "Timeout waiting for window to close!",
403
                                WINDOW_CLOSE_CHECK_INTERVAL_MS, this))
406
      WINDOW_CLOSE_TIMEOUT_MS, WINDOW_CLOSE_CHECK_INTERVAL_MS, this);
404
      throw new Error("Timeout waiting for window to close!");
405
    let didDisappear = this.waitingList[this.waitingForClose] == null;
407
    let didDisappear = this.waitingList[this.waitingForClose] == null;
406
    delete this.waitingList[windowType];
408
    delete this.waitingList[windowType];
407
    let windowType = this.waitingForClose;
409
    let windowType = this.waitingForClose;
408
    this.waitingForClose = null;
410
    this.waitingForClose = null;
409
    if (!didDisappear)
411
    if (!didDisappear)
410
      throw new Error(windowType + " window did not disappear!");
412
      throw new Error(windowType + " window did not disappear!");
411
  },
413
  },
412
414
 Lines 683-703   function plan_for_observable_event(aTopi Link Here 
683
 * @param aTopic The topic sent via the observer service.
685
 * @param aTopic The topic sent via the observer service.
684
 */
686
 */
685
function wait_for_observable_event(aTopic) {
687
function wait_for_observable_event(aTopic) {
686
  mark_action("fdh", "wait_for_observable_event", [aTopic]);
688
  mark_action("fdh", "wait_for_observable_event", [aTopic]);
687
  try {
689
  try {
688
    function areWeThereYet() {
690
    function areWeThereYet() {
689
      return observationSaw[aTopic];
691
      return observationSaw[aTopic];
690
    }
692
    }
691
    if (!controller.waitForEval(
693
    utils.waitFor(areWeThereYet,
692
          'subject()',
694
                  "Timed out waiting for notification: " + aTopic);
693
          3000, 50,
694
          areWeThereYet))
695
      throw new Error("Timed out waiting for notification: " + aTopic);
696
  }
695
  }
697
  finally {
696
  finally {
698
    obsService.removeObserver(observationWaitFuncs[aTopic], aTopic);
697
    obsService.removeObserver(observationWaitFuncs[aTopic], aTopic);
699
    delete observationWaitFuncs[aTopic];
698
    delete observationWaitFuncs[aTopic];
700
    delete observationSaw[aTopic];
699
    delete observationSaw[aTopic];
701
  }
700
  }
702
}
701
}
703
702
 Lines 845-864   var AugmentEverybodyWith = { Link Here 
845
     *     attribute with a single value.  We pick the menu option whose DOM
844
     *     attribute with a single value.  We pick the menu option whose DOM
846
     *     node has an attribute with that name and value.  We click whatever we
845
     *     node has an attribute with that name and value.  We click whatever we
847
     *     find.  We throw if we don't find what you were asking for.
846
     *     find.  We throw if we don't find what you were asking for.
848
     */
847
     */
849
    click_menus_in_sequence: function _click_menus(aRootPopup, aActions) {
848
    click_menus_in_sequence: function _click_menus(aRootPopup, aActions) {
850
      if (aRootPopup.state == "closed")
849
      if (aRootPopup.state == "closed")
851
        aRootPopup.openPopup(null, "", 0, 0, true, true);
850
        aRootPopup.openPopup(null, "", 0, 0, true, true);
852
      if (aRootPopup.state != "open") { // handle "showing"
851
      if (aRootPopup.state != "open") { // handle "showing"
853
        if (!controller.waitForEval("subject.state == 'open'", 1000, 50,
852
        utils.waitFor(function () aRootPopup.state == "open",
854
                                    aRootPopup)) {
853
                      "Popup never opened!", 1000, 50);
855
          throw new Error("Popup never opened!");
856
        }
857
      }
854
      }
858
      // These popups sadly do not close themselves, so we need to keep track
855
      // These popups sadly do not close themselves, so we need to keep track
859
      //  of them so we can make sure they end up closed.
856
      //  of them so we can make sure they end up closed.
860
      let closeStack = [aRootPopup];
857
      let closeStack = [aRootPopup];
861
858
862
      let curPopup = aRootPopup;
859
      let curPopup = aRootPopup;
863
      for each (let [iAction, actionObj] in Iterator(aActions)) {
860
      for each (let [iAction, actionObj] in Iterator(aActions)) {
864
        let matchingNode = null;
861
        let matchingNode = null;
 Lines 884-912   var AugmentEverybodyWith = { Link Here 
884
        if (!matchingNode)
881
        if (!matchingNode)
885
          throw new Error("Did not find matching menu item for action index " +
882
          throw new Error("Did not find matching menu item for action index " +
886
                          iAction);
883
                          iAction);
887
884
888
        this.click(new elib.Elem(matchingNode));
885
        this.click(new elib.Elem(matchingNode));
889
        if ("menupopup" in matchingNode) {
886
        if ("menupopup" in matchingNode) {
890
          curPopup = matchingNode.menupopup;
887
          curPopup = matchingNode.menupopup;
891
          closeStack.push(curPopup);
888
          closeStack.push(curPopup);
892
          if (!controller.waitForEval("subject.state == 'open'", 1000, 50,
889
          utils.waitFor(function () curPopup.state == "open",
893
                                      curPopup)) {
890
                        "Popup never opened at action depth: " + iAction,
894
            throw new Error("Popup never opened at action depth: " + iAction);
891
                        1000, 50);
895
          }
896
        }
892
        }
897
      }
893
      }
898
894
899
      while (closeStack.length) {
895
      while (closeStack.length) {
900
        curPopup = closeStack.pop();
896
        curPopup = closeStack.pop();
901
        this.keypress(new elib.Elem(curPopup), "VK_ESCAPE", {});
897
        this.keypress(new elib.Elem(curPopup), "VK_ESCAPE", {});
902
        if (!controller.waitForEval("subject.state == 'closed'", 1000, 50,
898
        utils.waitFor(function () curPopup.state == "closed",
903
                                    curPopup))
899
                      "Popup did not close!", 1000, 50);
904
          throw new Error("Popup did not close!");
905
      }
900
      }
906
    },
901
    },
907
902
908
    /**
903
    /**
909
     * mark_action helper method that produces something that can be concat()ed
904
     * mark_action helper method that produces something that can be concat()ed
910
     *  onto a list being passed to mark_action in order to describe the focus
905
     *  onto a list being passed to mark_action in order to describe the focus
911
     *  state of the window.  For now this will be a variable-length list but
906
     *  state of the window.  For now this will be a variable-length list but
912
     *  could be changed to a single object in the future.
907
     *  could be changed to a single object in the future.

Return to bug 662960