fix clicking on mailto links, mailto url cloning not correct, r=neil a=Standard8, bug 691288
authorDavid Bienvenu <bienvenu@nventure.com>
Fri, 07 Oct 2011 08:33:19 -0700
changeset 9278 132257a4c0a0ec72b7bc0b8f7b313cf581973eaa
parent 9277 f9c99ccc688da358ccf9b50326cdfecdc722ad91
child 9279 98b40acdbdead0064986a9e70433967ed5706d6e
push id230
push userbugzilla@standard8.plus.com
push dateTue, 08 Nov 2011 22:55:24 +0000
treeherdercomm-beta@63dad5648415 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil, Standard8, bug
bugs691288
fix clicking on mailto links, mailto url cloning not correct, r=neil a=Standard8, bug 691288
mailnews/compose/src/nsSmtpUrl.cpp
mailnews/compose/test/unit/test_mailtoURL.js
--- a/mailnews/compose/src/nsSmtpUrl.cpp
+++ b/mailnews/compose/src/nsSmtpUrl.cpp
@@ -666,16 +666,17 @@ NS_IMETHODIMP nsMailtoUrl::Clone(nsIURI 
   nsRefPtr<nsMailtoUrl> clone = new nsMailtoUrl();
 
   if (!clone)
     return NS_ERROR_OUT_OF_MEMORY;
 
   nsresult rv = m_baseURL->Clone(getter_AddRefs(clone->m_baseURL));
   NS_ENSURE_SUCCESS(rv, rv);
 
+  clone->ParseUrl();
   *_retval = clone.forget().get();
   return NS_OK;
 }	
 
 NS_IMETHODIMP nsMailtoUrl::Resolve(const nsACString &relativePath, nsACString &result) 
 {
 	return m_baseURL->Resolve(relativePath, result);
 }
--- a/mailnews/compose/test/unit/test_mailtoURL.js
+++ b/mailnews/compose/test/unit/test_mailtoURL.js
@@ -1,22 +1,21 @@
 /*
  * Test suite for mailto: URLs
  */
+Components.utils.import("resource://gre/modules/Services.jsm");
 
 const nsIMailtoUrl = Components.interfaces.nsIMailtoUrl;
 const COMPOSE_HTML = Components.interfaces.nsIMsgCompFormat.HTML;
 const COMPOSE_DEFAULT = Components.interfaces.nsIMsgCompFormat.Default;
 
 function run_test() {
 
   function test(aTest) {
-    var ios = Components.classes["@mozilla.org/network/io-service;1"]
-                        .getService(Components.interfaces.nsIIOService);
-    var uri = ios.newURI(aTest.url, null, null);
+    var uri = Services.io.newURI(aTest.url, null, null);
     uri = uri.QueryInterface(Components.interfaces.nsIMailtoUrl);
 
     var to = {}, cc = {}, bcc = {}, subject = {}, body = {}, html = {},
         reference = {}, newsgroup = {}, composeformat = {};
     uri.GetMessageContents(to, cc, bcc, subject, body, html, reference,
                            newsgroup, composeformat);
     do_check_eq(aTest.to, to.value);
     do_check_eq(aTest.cc, cc.value);
@@ -34,16 +33,24 @@ function run_test() {
     do_check_eq(aTest.priority, uri.priorityPart);
     do_check_eq(aTest.newshost, uri.newsHostPart);
     do_check_true(uri.equals(uri));
   }
 
   for (var i = 0; i < tests.length; i++)
     test(tests[i]);
 
+  // Test cloning reparses the url by checking the to field.
+  let uriToClone = Services.io.newURI(tests[0].url, null, null);
+  let clonedUrl = uriToClone.clone().QueryInterface(Components.interfaces.nsIMailtoUrl);
+  var to = {}, cc = {}, bcc = {}, subject = {}, body = {}, html = {},
+      reference = {}, newsgroup = {}, composeformat = {};
+  clonedUrl.GetMessageContents(to, cc, bcc, subject, body, html, reference,
+                         newsgroup, composeformat);
+  do_check_eq(to.value, tests[0].to);
 };
 
 const tests = [
   {
     url: "mailto:one@example.com",
     to: "one@example.com",
     cc: "",
     bcc: "",