Backout 63643fbbde88 due to mochitest-other orange.
authorRyan VanderMeulen <ryanvm@gmail.com>
Sun, 23 Sep 2012 16:48:35 -0400
changeset 107968 0a2f1680ac8e90dc7a04abf0de08497e5864903d
parent 107967 f52262d00c0627fa35584615738906efba50dde1
child 107969 c671314ef40854e2597207abf60f806ddaa801b5
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
milestone18.0a1
backs out63643fbbde88afe83dc416d8be9c7baf1d47befd
Backout 63643fbbde88 due to mochitest-other orange.
dom/apps/src/Webapps.js
dom/tests/mochitest/webapps/test_install_errors.xul
--- a/dom/apps/src/Webapps.js
+++ b/dom/apps/src/Webapps.js
@@ -75,31 +75,19 @@ WebappsRegistry.prototype = {
     this.removeRequest(msg.requestID);
   },
 
   _getOrigin: function(aURL) {
     let uri = Services.io.newURI(aURL, null, null);
     return uri.prePath;
   },
 
-  _validateScheme: function(aURL) {
-    let scheme = Services.io.newURI(aURL, null, null).scheme;
-    if (scheme != "http" && scheme != "https") {
-      throw new Components.Exception(
-        "INVALID_URL_SCHEME: '" + scheme + "'; must be 'http' or 'https'",
-        Cr.NS_ERROR_FAILURE
-      );
-    }
-  },
-
   // mozIDOMApplicationRegistry implementation
 
   install: function(aURL, aParams) {
-    this._validateScheme(aURL);
-
     let installURL = this._window.location.href;
     let installOrigin = this._getOrigin(installURL);
     let request = this.createRequest();
     let requestID = this.getRequestId(request);
     let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
     xhr.open("GET", aURL, true);
     xhr.channel.loadFlags |= Ci.nsIRequest.VALIDATE_ALWAYS;
 
@@ -169,18 +157,16 @@ WebappsRegistry.prototype = {
     this._mgmt = null;
     cpmm.sendAsyncMessage("Webapps:UnregisterForMessages",
                           ["Webapps:Install:Return:OK"]);
   },
 
   // mozIDOMApplicationRegistry2 implementation
 
   installPackage: function(aPackageURL, aParams) {
-    this._validateScheme(aPackageURL);
-
     let request = this.createRequest();
     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 : [];
     cpmm.sendAsyncMessage("Webapps:InstallPackage", { url: aPackageURL,
--- a/dom/tests/mochitest/webapps/test_install_errors.xul
+++ b/dom/tests/mochitest/webapps/test_install_errors.xul
@@ -23,17 +23,16 @@ var steps = [
   parseError,
   invalidManifest,
   permissionDenied,
   invalidContent,
   installPackageNotImplemented,
   invalidLaunchPath,
   invalidEntryPoint,
   invalidLocaleEntryPoint,
-  fileURL,
 ];
 
 runAll(steps);
 
 function noArgs(next) {
   try { 
     navigator.mozApps.install();
   } catch (e) {
@@ -132,43 +131,10 @@ function invalidLocaleEntryPoint(next) {
 }
 
 function installPackageNotImplemented(next) {
   ok(!("installPackage" in navigator.mozApps),
      "installPackage not in navigator.mozApps");
   next();
 }
 
-function fileURL(next) {
-  try {
-    navigator.mozApps.install("file:///nonexistent");
-    ok(false,
-       "attempt to install nonexistent file: URL doesn't throw exception");
-  } catch(ex) {
-    is(ex.message, "INVALID_URL_SCHEME: 'file'; must be 'http' or 'https'",
-       "attempt to install nonexistent file: URL throws exception");
-  }
-
-  // Get the file:/// URL of an existent file, which we will use to test that
-  // attempting to install an existent file has exactly the same effect as
-  // attempting to install a nonexistent file.  We use the URL of the Services
-  // module in the test because we use the Services module to get the URL,
-  // so we know it exists.
-  var { Services: Services } =
-    Components.utils.import("resource://gre/modules/Services.jsm", {});
-  var file =
-    Services.io.newURI("resource://gre/modules/Services.jsm", null, null).
-    QueryInterface(Components.interfaces.nsIFileURL).file;
-  var url = Services.io.newFileURI(file).spec;
-
-  try {
-    navigator.mozApps.install(url);
-    ok(false, "attempt to install existent file: URL doesn't throw exception");
-  } catch(ex) {
-    is(ex.message, "INVALID_URL_SCHEME: 'file'; must be 'http' or 'https'",
-       "attempt to install existent file: URL throws exception");
-  }
-
-  next();
-}
-
 </script>
 </window>