Backed out changeset 281b623d3b9f - accidentally landed on release branch. a=Standard8. SEA_COMM140_20120710_RELBRANCH
authorMike Conley <mconley@mozilla.com>
Wed, 11 Jul 2012 16:59:28 -0400
branchSEA_COMM140_20120710_RELBRANCH
changeset 11948 63c9b87273d2264502299d6779a2678b656527d3
parent 11947 281b623d3b9ff904e2eb3c0ec62f30073539aa57
push idunknown
push userunknown
push dateunknown
reviewersStandard8
backs out281b623d3b9ff904e2eb3c0ec62f30073539aa57
Backed out changeset 281b623d3b9f - accidentally landed on release branch. a=Standard8.
mail/components/cloudfile/nsYouSendIt.js
mail/test/mozmill/cloudfile/test-cloudfile-backend-yousendit.js
--- a/mail/components/cloudfile/nsYouSendIt.js
+++ b/mail/components/cloudfile/nsYouSendIt.js
@@ -1081,16 +1081,17 @@ nsYouSendItFileUploader.prototype = {
     }
   },
   /**
    * Once the file is uploaded, if we want to get a sharing URL back, we have
    * to send a "commit" request - which this function does.
    */
   _commitSend: function nsYSIFU__commitSend() {
     this.log.info("commit sending file " + this._urlInfo.fileId);
+    
     let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
                 .createInstance(Ci.nsIXMLHttpRequest);
     let args = "?name=" + this.file.leafName +
                "&fileId=" + this._urlInfo.fileId +
                "&parentId=" + this.youSendIt._folderId + "&";
 
     req.open("POST", gServerUrl + kFolderCommitUploadPath + args + kUrlTail, true);
 
@@ -1117,51 +1118,30 @@ nsYouSendItFileUploader.prototype = {
       }.bind(this);
 
       if (uploadInfo.errorStatus) {
         this.youSendIt._lastErrorText = uploadInfo.errorStatus.message;
         this.youSendIt._lastErrorStatus = uploadInfo.errorStatus.code;
         failed();
       }
       else if (uploadInfo.clickableDownloadUrl) {
-        // We need a kludge here because YSI is returning URLs without the scheme...
-        let url = this._ensureScheme(uploadInfo.clickableDownloadUrl);
-        this.youSendIt._urlsForFiles[this.file.path] = url;
+        this.youSendIt._urlsForFiles[this.file.path] = uploadInfo.clickableDownloadUrl;
         succeed();
       }
       else
         this._findDownloadUrl(uploadInfo.id, succeed, failed);
     }.bind(this);
 
     req.setRequestHeader("X-Auth-Token", this.youSendIt._cachedAuthToken + " ");
     req.setRequestHeader("X-Api-Key", kApiKey);
     req.setRequestHeader("Accept", "application/json");
     req.send();
   },
 
   /**
-   * If there's no scheme prefix for a URL, attaches an https:// prefix
-   * and returns the new result.
-   *
-   * @param aURL to ensure a scheme with
-   */
-  _ensureScheme: function nsYSIFU__ensureScheme(aURL) {
-    try {
-      let scheme = Services.io.extractScheme(aURL);
-      return aURL;
-    } catch(e) {
-      // If we got NS_ERROR_MALFORMED_URI back, there's no scheme here.
-      if (e.result == Cr.NS_ERROR_MALFORMED_URI)
-        return "https://" + aURL;
-      // Otherwise, we hit something different, and should throw.
-      throw e;
-    }
-  },
-
-  /**
    * Attempt to find download url for file.
    *
    * @param aFileId id of file
    * @param aSuccessCallback called if url is found
    * @param aFailureCallback called if url is not found
    */
   _findDownloadUrl: function nsYSIFU__findDownloadUrl(aFileId, aSuccessCallback, aFailureCallback) {
     let req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
@@ -1177,19 +1157,17 @@ nsYouSendItFileUploader.prototype = {
     req.onload = function() {
       let response = req.responseText;
       this.log.info("findDownloadUrl response = " + response);
       let fileInfo = JSON.parse(response);
 
       if (fileInfo.errorStatus)
         aFailureCallback();
       else {
-        // We need a kludge here because YSI is returning URLs without the scheme...
-        let url = this._ensureScheme(fileInfo.clickableDownloadUrl);
-        this.youSendIt._urlsForFiles[this.file.path] = url;
+        this.youSendIt._urlsForFiles[this.file.path] = fileInfo.clickableDownloadUrl;
         aSuccessCallback();
       }
     }.bind(this);
 
     req.setRequestHeader("X-Auth-Token", this.youSendIt._cachedAuthToken + " ");
     req.setRequestHeader("X-Api-Key", kApiKey);
     req.setRequestHeader("Accept", "application/json");
     req.send();
--- a/mail/test/mozmill/cloudfile/test-cloudfile-backend-yousendit.js
+++ b/mail/test/mozmill/cloudfile/test-cloudfile-backend-yousendit.js
@@ -281,43 +281,8 @@ function test_delete_refreshes_stale_tok
   let deleteObserver = new SimpleRequestObserver();
   provider.deleteFile(file, deleteObserver);
 
   // Now, since the token was stale, we should see us hit authentication
   // again.
   mc.waitFor(function() gServer.auth.count > 0,
              "Timed out waiting for authorization attempt");
 }
-
-/**
- * Test for bug 771132 - if YouSendIt returns malformed URLs, prefix with
- * https://.
- */
-function test_bug771132_fix_no_scheme() {
-  const kMalformedUrl = "www.example.com/download/abcd1234";
-  const kExpectedUrl = "https://" + kMalformedUrl;
-
-  const kTopics = [kUploadFile, kGetFileURL];
-
-  gServer.planForUploadFile("testFile1");
-  gServer.planForGetFileURL("testFile1", {url: kMalformedUrl});
-
-  let requestObserver = gObsManager.create("test_simple_case - Upload 1");
-  let file = getFile("./data/testFile1", __file__);
-  let provider = gServer.getPreparedBackend("someAccountKey");
-  provider.uploadFile(file, requestObserver);
-
-  mc.waitFor(function () requestObserver.success);
-
-  let urlForFile = provider.urlForFile(file);
-  assert_equals(kExpectedUrl, urlForFile);
-
-  // Now make sure that we don't accidentally prefix with https when there's
-  // already a scheme.
-  gServer.planForUploadFile("testFile1");
-  gServer.planForGetFileURL("testFile1", {url: kExpectedUrl});
-  requestObserver = gObsManager.create("test_simple_case - Upload 2");
-  provider.uploadFile(file, requestObserver);
-  mc.waitFor(function () requestObserver.success);
-
-  urlForFile = provider.urlForFile(file);
-  assert_equals(kExpectedUrl, urlForFile);
-}