Bug 912151 - Do not check for attachment keywords when the compose window is not ready. r=mkmelin
authoraceman <acelists@atlas.sk>
Mon, 02 Dec 2013 09:32:27 -0500
changeset 16948 e035e1c899bdde72ae2aeeceaa595a92f6c8a582
parent 16947 27e9cb30c006738fc8a8070f30764a627ccd2f3c
child 16949 3a23862e6d1661db88ec04e0198c6443a9bebbf3
push id1074
push userbugzilla@standard8.plus.com
push dateMon, 03 Feb 2014 22:47:23 +0000
treeherdercomm-beta@6b791b5369ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs912151
Bug 912151 - Do not check for attachment keywords when the compose window is not ready. r=mkmelin
mail/components/compose/content/MsgComposeCommands.js
mail/test/mozmill/cloudfile/test-cloudfile-attachment-urls.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -4556,17 +4556,20 @@ const gAttachmentNotifier =
       this._obs.disconnect();
 
     this._obs = null;
   },
 
   event: {
     notify: function(timer)
     {
-      CheckForAttachmentNotification(true);
+      // Only run the checker if the compose window is initialized
+      // and not shutting down.
+      if (gMsgCompose)
+        CheckForAttachmentNotification(true);
     }
   },
 
   timer: Components.classes["@mozilla.org/timer;1"]
                    .createInstance(Components.interfaces.nsITimer)
 };
 
 function InitEditor()
--- a/mail/test/mozmill/cloudfile/test-cloudfile-attachment-urls.js
+++ b/mail/test/mozmill/cloudfile/test-cloudfile-attachment-urls.js
@@ -345,16 +345,18 @@ function subtest_removing_filelinks_remo
   cw.window.goDoCommand("cmd_delete");
 
   // Wait for the root to be removed.
   let mailBody = get_compose_body(cw);
   cw.waitFor(function() {
     let result = mailBody.querySelector(root.id);
     return (result == null);
   }, "Timed out waiting for attachment container to be removed");
+
+  close_window(cw);
 }
 
 /**
  * Test that if we write some text in an empty message (no signature),
  * and the selection is at the end of a line of text, attaching some Filelinks
  * causes the attachment URL container to be separated from the text by
  * two br tags.
  */
@@ -651,16 +653,18 @@ function subtest_adding_filelinks_to_for
     let textNode = assert_previous_text(br.previousSibling, aText);
   } else {
     // Otherwise, there's only 1 br, and that br should be the first element
     // of the message body.
     let br = assert_previous_nodes("br", root, 1);
     let mailBody = get_compose_body(cw);
     assert_equals(br, mailBody.firstChild);
   }
+
+  close_window(cw);
 }
 
 /**
  * Test that if we convert a Filelink from one provider to another, that the
  * old Filelink is removed, and a new Filelink is added for the new provider.
  * We test this on both HTML and plaintext mail.
  */
 function test_converting_filelink_updates_urls() {
@@ -692,16 +696,18 @@ function subtest_converting_filelink_upd
     cw.window.convertSelectedToCloudAttachment(providerB);
     [root, list, urls] = wait_for_attachment_urls(cw, kFiles.length);
 
     let newUrl = urls[i];
 
     assert_not_equals(url, newUrl,
                       "The original URL should have been replaced");
   }
+
+  close_window(cw);
 }
 
 /**
  * Test that if we convert a Filelink to a normal attachment that the
  * Filelink is removed from the message body.
  */
 function test_converting_filelink_to_normal_removes_url() {
   try_with_plaintext_and_html_mail(
@@ -732,16 +738,18 @@ function subtest_converting_filelink_to_
     assert_equals(urls.length, kFiles.length - (i + 1));
   }
 
   // At this point, the root should also have been removed.
   let mailBody = get_compose_body(cw);
   root = mailBody.querySelector("#cloudAttachmentListRoot");
   if (root)
     throw new Error("Should not have found the cloudAttachmentListRoot");
+
+  close_window(cw);
 }
 
 /**
  * Tests that if the user manually removes the Filelinks from the message body
  * that it doesn't break future Filelink insertions. Tests both HTML and
  * plaintext composers.
  */
 function test_filelinks_work_after_manual_removal() {
@@ -765,16 +773,18 @@ function subtest_filelinks_work_after_ma
 
   // Now remove the root node from the document body
   let mailBody = get_compose_body(cw);
   mailBody.removeChild(root);
 
   gMockFilePicker.returnFiles = collectFiles(["./data/testFile3"], __file__);
   cw.window.attachToCloud(provider);
   [root, list, urls] = wait_for_attachment_urls(cw, 1);
+
+  close_window(cw);
 }
 
 /**
  * Test that if the users selection caret is on a newline when the URL
  * insertion occurs, that the caret does not move when the insertion is
  * complete. Tests both HTML and plaintext composers.
  */
 function test_insertion_restores_caret_point() {
@@ -806,9 +816,11 @@ function subtest_insertion_restores_care
   let [root, list, urls] = wait_for_attachment_urls(cw, kFiles.length);
 
   // Type some text.
   const kTypedIn = "Test";
   type_in_composer(cw, [kTypedIn]);
 
   // That text should be inserted just above the root attachment URL node.
   let textNode = assert_previous_text(root.previousSibling, [kTypedIn]);
+
+  close_window(cw);
 }