Bug 1375376 - Add a test for clicking on addbook: link from vCard displayed inline. r=jorgk
authoraceman <acelists@atlas.sk>
Sat, 01 Jul 2017 12:41:00 +0200
changeset 28406 7d0b8cd8b49d7e192ecc10c0c70a13af6a2a8f87
parent 28405 8f2f953f2ed32a1eb84344ea69a7cb9d09957301
child 28407 eb90850d4a8fda98a79d16acc6d7cb3087f0e812
push id1986
push userclokep@gmail.com
push dateWed, 02 Aug 2017 14:43:31 +0000
treeherdercomm-beta@b51c9adf2c9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1375376
Bug 1375376 - Add a test for clicking on addbook: link from vCard displayed inline. r=jorgk
mail/test/mozmill/message-window/test-vcard-actions.js
mail/test/mozmill/message-window/test-vcard-icon.eml
mailnews/addrbook/content/abNewCardDialog.xul
new file mode 100644
--- /dev/null
+++ b/mail/test/mozmill/message-window/test-vcard-actions.js
@@ -0,0 +1,56 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * Tests for attached vcards.
+ */
+
+// make SOLO_TEST=message-window/test-vcard-actions.js mozmill-one
+
+var MODULE_NAME = "test-vcard-actions";
+
+var RELATIVE_ROOT = "../shared-modules";
+var MODULE_REQUIRES = ["folder-display-helpers", "window-helpers",
+                       "address-book-helpers"];
+
+var os = {};
+Cu.import('resource://mozmill/stdlib/os.js', os);
+
+function setupModule(module) {
+  for (let lib of MODULE_REQUIRES) {
+    collector.getModule(lib).installInto(module);
+  }
+}
+
+/**
+ * Bug 1374779
+ * Check if clicking attached vcard image opens new card dialog and adds a contact.
+ */
+function test_check_vcard_icon() {
+  let file = os.getFileForPath(os.abspath("./test-vcard-icon.eml", os.getFileForPath(__file__)));
+  let msgc = open_message_from_file(file);
+
+  let newcards = get_cards_in_all_address_books_for_email("meister@example.com");
+  assert_equals(newcards.length, 0);
+
+  function subtest_check_card(cardc) {
+    // Check new card is properly prefilled.
+    let emailField = cardc.e("PrimaryEmail");
+    assert_equals(emailField.value, "meister@example.com");
+    cardc.window.document.documentElement.acceptDialog();
+  }
+
+  // Click icon on the vcard block.
+  let vcard = msgc.e("messagepane").contentDocument.querySelector(".moz-vcard-badge");
+  // Check new card dialog opens.
+  plan_for_modal_dialog("mailnews:newcarddialog", subtest_check_card);
+  msgc.click(new elementslib.Elem(vcard));
+  wait_for_modal_dialog("mailnews:newcarddialog");
+
+  // Check new card was created from the vcard.
+  newcards = get_cards_in_all_address_books_for_email("meister@example.com");
+  assert_equals(newcards.length, 1);
+
+  close_window(msgc);
+}
new file mode 100644
--- /dev/null
+++ b/mail/test/mozmill/message-window/test-vcard-icon.eml
@@ -0,0 +1,41 @@
+From - Tue Jun 20 20:58:09 2017
+X-Account-Key: account1
+X-UIDL: UID111111-1111111111
+X-Mozilla-Status: 0001
+X-Mozilla-Status2: 00000000
+X-Mozilla-Keys:                                                                                 
+Delivery-date: Tue, 20 Jun 2017 20:46:01 +0200
+MIME-Version: 1.0
+Message-ID: <vcard@link.invalid>
+From: <meister@mail.example.com>
+To: Hugo <hugo@example.com>
+Subject: Click on inline vCard and hang
+Content-Type: multipart/mixed;
+ boundary=sgnirk-111111111111111
+Date: Tue, 20 Jun 2017 20:45:48 +0200
+
+--sgnirk-111111111111111
+Content-Type: text/html; charset=UTF-8
+
+<html><head></head>
+<body>
+<div style="font-family: Verdana;font-size: 12.0px;">
+<div>
+<div>
+<div>Hallo Hugo</div>
+
+<div>Set attachments to inline display and click on the addbook: link in the vCard.</div>
+
+</div></div></body></html>
+--sgnirk-111111111111111
+Content-Type: text/x-vcard; charset=UTF-8
+Content-Disposition: attachment; filename="Meister.vcf"
+
+BEGIN:VCARD
+VERSION:3.0
+FN:Meister
+EMAIL;TYPE=WORK,PREF:meister@example.com
+END:VCARD
+
+--sgnirk-111111111111111--
+
--- a/mailnews/addrbook/content/abNewCardDialog.xul
+++ b/mailnews/addrbook/content/abNewCardDialog.xul
@@ -6,16 +6,17 @@
 <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
 
 <?xul-overlay href="chrome://messenger/content/addressbook/abCardOverlay.xul"?>
 
 <!DOCTYPE dialog SYSTEM "chrome://messenger/locale/addressbook/abNewCardDialog.dtd">
 
 <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     id="abcardWindow"
+    windowtype="mailnews:newcarddialog"
     onload="OnLoadNewCard()"
     ondialogaccept="return NewCardOKButton();">
 
   <stringbundleset id="stringbundleset"/>
 
   <hbox align="center">
 
     <label id="abPopupLabel" control="abPopup" value="&chooseAddressBook.label;" accesskey="&chooseAddressBook.accesskey;"/>