Back out acecf63268be (bug 829679) for the same mochitest-chrome orange it had the last time it landed
authorPhil Ringnalda <philringnalda@gmail.com>
Mon, 14 Jan 2013 20:16:10 -0800
changeset 128734 cf77e6413213d4ef2c5c083f65128d719ed18420
parent 128733 69017949e11832ce16472c401ddcf767577a8962
child 128735 c6f47473693423bb9c265b196af56544bd8ea4e7
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs829679
milestone21.0a1
backs outacecf63268be60d39b19e684ecf4cc10f8c433d0
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Back out acecf63268be (bug 829679) for the same mochitest-chrome orange it had the last time it landed CLOSED TREE
dom/apps/src/Webapps.js
--- a/dom/apps/src/Webapps.js
+++ b/dom/apps/src/Webapps.js
@@ -67,38 +67,24 @@ WebappsRegistry.prototype = {
     this.removeRequest(msg.requestID);
   },
 
   _getOrigin: function(aURL) {
     let uri = Services.io.newURI(aURL, null, null);
     return uri.prePath;
   },
 
-  _validateURL: function(aURL) {
-    let uri;
-    let res;
-    try {
-      uri = Services.io.newURI(aURL, null, null);
-      if (uri.schemeIs("http") || uri.schemeIs("https")) {
-        res = uri.spec;
-      }
-    } catch(e) {
+  _validateScheme: function(aURL) {
+    let scheme = Services.io.newURI(aURL, null, null).scheme;
+    if (scheme != "http" && scheme != "https") {
       throw new Components.Exception(
-        "INVALID_URL: '" + aURL, Cr.NS_ERROR_FAILURE
-      );
-    }
-
-    // The scheme is incorrect, throw an exception.
-    if (!res) {
-      throw new Components.Exception(
-        "INVALID_URL_SCHEME: '" + uri.scheme + "'; must be 'http' or 'https'",
+        "INVALID_URL_SCHEME: '" + scheme + "'; must be 'http' or 'https'",
         Cr.NS_ERROR_FAILURE
       );
     }
-    return uri.spec;
   },
 
   // Checks that we run as a foreground page, and fire an error on the
   // DOM Request if we aren't.
   _ensureForeground: function(aRequest) {
     let docShell = this._window.QueryInterface(Ci.nsIInterfaceRequestor)
                                .getInterface(Ci.nsIWebNavigation)
                                .QueryInterface(Ci.nsIDocShell);
@@ -114,39 +100,39 @@ WebappsRegistry.prototype = {
     Services.tm.currentThread.dispatch(runnable,
                                        Ci.nsIThread.DISPATCH_NORMAL);
     return false;
   },
 
   // mozIDOMApplicationRegistry implementation
 
   install: function(aURL, aParams) {
-    let uri = this._validateURL(aURL);
-
     let request = this.createRequest();
 
     if (!this._ensureForeground(request)) {
       return request;
     }
 
+    this._validateScheme(aURL);
+
     let installURL = this._window.location.href;
     let requestID = this.getRequestId(request);
     let receipts = (aParams && aParams.receipts &&
                     Array.isArray(aParams.receipts)) ? aParams.receipts
                                                      : [];
     let categories = (aParams && aParams.categories &&
                       Array.isArray(aParams.categories)) ? aParams.categories
                                                          : [];
 
     let principal = this._window.document.nodePrincipal;
     cpmm.sendAsyncMessage("Webapps:Install",
                           { app: {
                               installOrigin: this._getOrigin(installURL),
-                              origin: this._getOrigin(uri),
-                              manifestURL: uri,
+                              origin: this._getOrigin(aURL),
+                              manifestURL: aURL,
                               receipts: receipts,
                               categories: categories
                             },
                             from: installURL,
                             oid: this._id,
                             requestID: requestID,
                             appId: principal.appId,
                             isBrowser: principal.isInBrowserElement
@@ -193,39 +179,39 @@ WebappsRegistry.prototype = {
     this._mgmt = null;
     cpmm.sendAsyncMessage("Webapps:UnregisterForMessages",
                           ["Webapps:Install:Return:OK"]);
   },
 
   // mozIDOMApplicationRegistry2 implementation
 
   installPackage: function(aURL, aParams) {
-    let uri = this._validateURL(aURL);
-
     let request = this.createRequest();
 
     if (!this._ensureForeground(request)) {
       return request;
     }
 
+    this._validateScheme(aURL);
+
     let installURL = this._window.location.href;
     let requestID = this.getRequestId(request);
     let receipts = (aParams && aParams.receipts &&
                     Array.isArray(aParams.receipts)) ? aParams.receipts
                                                      : [];
     let categories = (aParams && aParams.categories &&
                       Array.isArray(aParams.categories)) ? aParams.categories
                                                          : [];
 
     let principal = this._window.document.nodePrincipal;
     cpmm.sendAsyncMessage("Webapps:InstallPackage",
                           { app: {
                               installOrigin: this._getOrigin(installURL),
-                              origin: this._getOrigin(uri),
-                              manifestURL: uri,
+                              origin: this._getOrigin(aURL),
+                              manifestURL: aURL,
                               receipts: receipts,
                               categories: categories
                             },
                             from: installURL,
                             oid: this._id,
                             requestID: requestID,
                             isPackage: true,
                             appId: principal.appId,