summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/import/test/unit/test_bug_437556.js
blob: 284309a2dc8d3903dea97cec6a7123fc9eb47cc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * Test for a regression of Bug 437556: mailnews crashes while importing an
 * address book if a field map is required but not set.
 */
function run_test() {
  var file = do_get_file("resources/basic_addressbook.csv");
  var errorStr = Cc["@mozilla.org/supports-string;1"].createInstance(
    Ci.nsISupportsString
  );
  // get the Address Book text import interface and make sure it succeeded
  var helper = new AbImportHelper(file, "Text file");
  helper.setFieldMap(null);
  helper.setAddressBookLocation(file);

  var abInterface = helper.getInterface();
  Assert.notEqual(abInterface, null);
  // prepare to start the import
  Assert.ok(abInterface.WantsProgress());
  // start the import
  // BeginImport should return false and log an error if the fieldMap isn't set
  Assert.ok(!abInterface.BeginImport(null, errorStr));
  Assert.notEqual(errorStr, "");
}