Bug 960837 - Use the basic receipt check introduced in bug 757226 for installations. r=fabrice
authorMarco Castelluccio <mar.castelluccio@studenti.unina.it>
Thu, 23 Jan 2014 09:46:20 -0500
changeset 180868 25caedc66f90359f0fbf01cefa240cd3e69dd4a0
parent 180867 5238a0b63a599b4d1eae0110f67ff290c30004fe
child 180869 0b2f7df3aadacd284c5767508bc1d291fb1654e2
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs960837, 757226
milestone29.0a1
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
Bug 960837 - Use the basic receipt check introduced in bug 757226 for installations. r=fabrice
dom/apps/src/Webapps.jsm
dom/apps/tests/mochitest.ini
dom/apps/tests/test_install_receipts.html
dom/tests/mochitest/webapps/chrome.ini
dom/tests/mochitest/webapps/test_install_receipts.xul
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -2013,16 +2013,26 @@ this.DOMApplicationRegistry = {
 
     let sendError = function sendError(aError) {
       aData.error = aError;
       aMm.sendAsyncMessage("Webapps:Install:Return:KO", aData);
       Cu.reportError("Error installing app from: " + app.installOrigin +
                      ": " + aError);
     }.bind(this);
 
+    if (app.receipts.length > 0) {
+      for (let receipt of app.receipts) {
+        let error = this.isReceipt(receipt);
+        if (error) {
+          sendError(error);
+          return;
+        }
+      }
+    }
+
     // Hosted apps can't be trusted or certified, so just check that the
     // manifest doesn't ask for those.
     function checkAppStatus(aManifest) {
       let manifestStatus = aManifest.type || "web";
       return manifestStatus === "web";
     }
 
     let checkManifest = (function() {
@@ -2122,16 +2132,26 @@ this.DOMApplicationRegistry = {
 
     let sendError = function sendError(aError) {
       aData.error = aError;
       aMm.sendAsyncMessage("Webapps:Install:Return:KO", aData);
       Cu.reportError("Error installing packaged app from: " +
                      app.installOrigin + ": " + aError);
     }.bind(this);
 
+    if (app.receipts.length > 0) {
+      for (let receipt of app.receipts) {
+        let error = this.isReceipt(receipt);
+        if (error) {
+          sendError(error);
+          return;
+        }
+      }
+    }
+
     let checkUpdateManifest = (function() {
       let manifest = app.updateManifest;
 
       // Disallow reinstalls from the same manifest URL for now.
       let id = this._appIdForManifestURL(app.manifestURL);
       if (id !== null && this._isLaunchable(this.webapps[id])) {
         sendError("REINSTALL_FORBIDDEN");
         return false;
--- a/dom/apps/tests/mochitest.ini
+++ b/dom/apps/tests/mochitest.ini
@@ -11,8 +11,9 @@ support-files =
 
 [test_app_update.html]
 [test_bug_795164.html]
 [test_packaged_app_common.js]
 [test_packaged_app_install.html]
 [test_packaged_app_update.html]
 [test_uninstall_errors.html]
 [test_receipt_operations.html]
+[test_install_receipts.html]
new file mode 100644
--- /dev/null
+++ b/dom/apps/tests/test_install_receipts.html
@@ -0,0 +1,215 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id={960837}
+-->
+<head>
+  <title>Test for Bug {960837}</title>
+  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id={960837}">Mozilla Bug {960837}</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="application/javascript;version=1.7">
+
+var gManifestURL = "http://test/tests/dom/apps/tests/file_app.sjs?apptype=hosted&getmanifest=true";
+var gGenerator = runTest();
+
+function debug(aMsg) {
+  //dump("== Tests debug == " + aMsg + "\n");
+}
+
+function go() {
+  SpecialPowers.pushPermissions(
+    [{ "type": "webapps-manage", "allow": 1, "context": document }],
+    function() { gGenerator.next() });
+}
+
+function continueTest() {
+  try {
+    gGenerator.next();
+  } catch (e) {
+    dump("Got exception: " + e + "\n");
+  }
+}
+
+function finish() {
+  SimpleTest.finish();
+}
+
+function cbError(aError) {
+  ok(false, "Error callback invoked " + aError);
+  finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+  launchableValue = SpecialPowers.setAllAppsLaunchable(true);
+
+  SpecialPowers.autoConfirmAppInstall(continueTest);
+  yield undefined;
+
+  // Test install with three valid receipts
+  let valid_receipt1 = 'eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTYifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidXNlciI6IHsidHlwZSI6ICJkaXJlY3RlZC1pZGVudGlmaWVyIiwgInZhbHVlIjogIjRmYjM1MTUxLTJiOWItNGJhMi04MjgzLWM0OWQzODE2NDBiZCJ9LCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAiaXNzIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgiLCAiaWF0IjogMTMxMzYwMTg4LCAidHlwIjogInB1cmNoYXNlLXJlY2VpcHQiLCAibmJmIjogMTMxMzYwMTg1LCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0.eZpTEnCLUR3iP3rm9WyJOqx1k66mQaAxqcrvX11r5E0';
+
+  let valid_receipt2 = 'eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTcifSwgInJlaXNzd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AiaHR0cHM6Ly9tYXJrZXRwbGFjZS5maXJlZm94LmNvbSIsICJ2ZXJpZnkiOiAiaHR0cHM6Ly9yZWNlaXB0Y2hlY2subWFya2V0cGxhY2UuZmlyZWZveC5jb20vdmVyaWZ5LyIsICJkZXRhaWwiOiAiaHR0cHM6Ly9tYXJrZXRwbGFjZS5maXJlZm94LmNvbS9hcGkvdjEvcmVjZWlwdHMvcmVpc3N1ZS8iLCAicmVpc3N1ZSI6ICJodHRwczovL21hcmtldHBsYWNlLmZpcmVmb3guY29tL2FwaS92MS9yZWNlaXB0cy9yZWlzc3VlLyIsICJ1c2VyIjogeyJ0eXBlIjogImRpcmVjdGVkLWlkZW50aWZpZXIiLCAidmFsdWUiOiAiMTkzMzI2LTVjMTUzNmQ1LWUxMDQtNDAzYy04NDBlLTQ5YjMyMmQ5Yjg4NSJ9LCAiZXhwIjogMTQwMTgyNTEyOCwgImlhdCI6IDEzODYxMDAzMjgsICJ0eXAiOiAicHVyY2hhc2UtcmVjZWlwdCIsICJuYmYiOiAxMzg2MTAwMzI4fQ.r2DVUpouRDJYqZe61LJBcIwmeF2mI8FmbGMRlfNFcinKAIs8nMVVNX8xSWJ6jXXgZ62VfHJCLHapADX8rCg6NgxFV_FdP7j2H_2Ufo0E0TREifTN6V4v1dCnzDulNhZmO8G-nQJUVOAtNfNC95PY7tVa8WC7dYXnKZsD6NhIxxVEtBGuiiySpWArI-g3pcl41rXNHHpJbRfrOD4QgVNrsV83TWILYRr6PWr3aqOM2XT_x2SzEfhBNvdG8AJmR0MKQytvfcgz3Vt1hMak88nFrzTLiKkuuPAXpwB5q83LZIl4EYG3UAnte4-XWlLb-NJ78vgXa64myy-3fPr7EO6LaQ';
+
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ valid_receipt1, valid_receipt2, valid_receipt3 ]});
+  request.onerror = cbError;
+  request.onsuccess = continueTest;
+  yield undefined;
+
+  var app = request.result;
+  ok(app, "App is non-null");
+  ok(app.receipts.length == 3, "Three receipts");
+
+  request = navigator.mozApps.mgmt.uninstall(app);
+  request.onerror = cbError;
+  request.onsuccess = continueTest;
+  yield undefined;
+
+  // Test install with a receipt with less than 3 segments
+  let receipt_few_segments = 'eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTcifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidXNlciI6IHsidHlwZSI6ICJkaXJlY3RlZC1pZGVudGlmaWVyIiwgInZhbHVlIjogIjRmYjM1MTUxLTJiOWItNGJhMi04MjgzLWM0OWQzODE2NDBiZCJ9LCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAiaXNzIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgiLCAiaWF0IjogMTMxMzYwMTg4LCAidHlwIjogInB1cmNoYXNlLXJlY2VpcHQiLCAibmJmIjogMTMxMzYwMTg1LCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0';
+
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ receipt_few_segments ]});
+  request.onsuccess = function() {
+    ok(false, "Less than 3 segments");
+  }
+  request.onerror = function() {
+    ok(this.error.name == "INVALID_SEGMENTS_NUMBER",
+       "Less than 3 segments");
+    continueTest();
+  }
+  yield undefined;
+
+  // Test install with a receipt without the typ field
+  let receipt_without_typ = "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTgifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidXNlciI6IHsidHlwZSI6ICJkaXJlY3RlZC1pZGVudGlmaWVyIiwgInZhbHVlIjogIjRmYjM1MTUxLTJiOWItNGJhMi04MjgzLWM0OWQzODE2NDBiZCJ9LCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAiaXNzIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgiLCAiaWF0IjogMTMxMzYwMTg4LCAibmJmIjogMTMxMzYwMTg1LCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0.6NY9DCEwhv9gTo1d7G4SJubZp_wSkaAJWA9iIp0PAQg";
+
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ receipt_without_typ ]});
+  request.onsuccess = function() {
+    ok(false, "No type field");
+  }
+  request.onerror = function() {
+    ok(this.error.name == "RECEIPT_TYPE_REQUIRED",
+       "No type field");
+    continueTest();
+  }
+  yield undefined;
+
+  // Test install with a receipt without the product field
+  let receipt_without_product = "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJyZWlzc3VlIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVpc3N1ZS81MTY5MzE0MzU2IiwgInVzZXIiOiB7InR5cGUiOiAiZGlyZWN0ZWQtaWRlbnRpZmllciIsICJ2YWx1ZSI6ICI0ZmIzNTE1MS0yYjliLTRiYTItODI4My1jNDlkMzgxNjQwYmQifSwgInZlcmlmeSI6ICJodHRwOi8vbW9jaGkudGVzdDo4ODg4L3ZlcmlmeS81MTY5MzE0MzU2IiwgImlzcyI6ICJodHRwOi8vbW9jaGkudGVzdDo4ODg4IiwgImlhdCI6IDEzMTM2MDE4OCwgInR5cCI6ICJwdXJjaGFzZS1yZWNlaXB0IiwgIm5iZiI6IDEzMTM2MDE4NSwgImRldGFpbCI6ICJodHRwOi8vbW9jaGkudGVzdDo4ODg4L3JlY2VpcHQvNTE2OTMxNDM1NiJ9.TWB8VXM2MhsyHLX3kWdjpSyn5Mz3SfG0oRIn-5p_0ko";
+
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ receipt_without_product ]});
+  request.onsuccess = function() {
+    ok(false, "No product field");
+  }
+  request.onerror = function() {
+    ok(this.error.name == "RECEIPT_PRODUCT_REQUIRED",
+       "No product field");
+    continueTest();
+  }
+  yield undefined;
+
+  // Test install with a receipt without the user field
+  let receipt_without_user = "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTgifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAiaXNzIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgiLCAiaWF0IjogMTMxMzYwMTg4LCAidHlwIjogInB1cmNoYXNlLXJlY2VpcHQiLCAibmJmIjogMTMxMzYwMTg1LCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0.eYm4ncnKvYzn-OYam5L55RQ8ShK6UlMrjFQOwByHSew";
+
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ receipt_without_user ]});
+  request.onsuccess = function() {
+    ok(false, "No user field");
+  }
+  request.onerror = function() {
+    ok(this.error.name == "RECEIPT_USER_REQUIRED",
+       "No user field");
+    continueTest();
+  }
+  yield undefined;
+
+  // Test install with a receipt without the iss field
+  let receipt_without_iss = "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTgifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidXNlciI6IHsidHlwZSI6ICJkaXJlY3RlZC1pZGVudGlmaWVyIiwgInZhbHVlIjogIjRmYjM1MTUxLTJiOWItNGJhMi04MjgzLWM0OWQzODE2NDBiZCJ9LCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAiaWF0IjogMTMxMzYwMTg4LCAidHlwIjogInB1cmNoYXNlLXJlY2VpcHQiLCAibmJmIjogMTMxMzYwMTg1LCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0.kvumGJAu8HkJ_utucwHwiOA_jJcqRMXBRQVDZd4KfUw";
+
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ receipt_without_iss ]});
+  request.onsuccess = function() {
+    ok(false, "No iss field");
+  }
+  request.onerror = function() {
+    ok(this.error.name == "RECEIPT_ISS_REQUIRED",
+       "No iss field");
+    continueTest();
+  }
+  yield undefined;
+
+  // Test install with a receipt without the nbf field
+  let receipt_without_nbf = "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTgifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidXNlciI6IHsidHlwZSI6ICJkaXJlY3RlZC1pZGVudGlmaWVyIiwgInZhbHVlIjogIjRmYjM1MTUxLTJiOWItNGJhMi04MjgzLWM0OWQzODE2NDBiZCJ9LCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAiaXNzIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgiLCAiaWF0IjogMTMxMzYwMTg4LCAidHlwIjogInB1cmNoYXNlLXJlY2VpcHQiLCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0.TYp6RQDFmyxLrmwAbhwkWLWgqhILR5yGA9CWDKNRU9Q";
+
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ receipt_without_nbf ]});
+  request.onsuccess = function() {
+    ok(false, "No nbf field");
+  }
+  request.onerror = function() {
+    ok(this.error.name == "RECEIPT_NBF_REQUIRED",
+       "No nbf field");
+    continueTest();
+  }
+  yield undefined;
+
+  // Test install with a receipt without the iat field
+  let receipt_without_iat = "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTgifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidXNlciI6IHsidHlwZSI6ICJkaXJlY3RlZC1pZGVudGlmaWVyIiwgInZhbHVlIjogIjRmYjM1MTUxLTJiOWItNGJhMi04MjgzLWM0OWQzODE2NDBiZCJ9LCAiaXNzIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgiLCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAidHlwIjogInB1cmNoYXNlLXJlY2VpcHQiLCAibmJmIjogMTMxMzYwMTg1LCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0.EWxAzgfIM1VtwAscajDjqsRt_lysk_Wtj4_d4NbMg3U";
+
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ receipt_without_iat ]});
+  request.onsuccess = function() {
+    ok(false, "No iat field");
+  }
+  request.onerror = function() {
+    ok(this.error.name == "RECEIPT_IAT_REQUIRED",
+       "No iat field");
+    continueTest();
+  }
+  yield undefined;
+
+  // Test install with a receipt with a not expected type
+  let receipt_with_wrong_typ = "eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTgifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidXNlciI6IHsidHlwZSI6ICJkaXJlY3RlZC1pZGVudGlmaWVyIiwgInZhbHVlIjogIjRmYjM1MTUxLTJiOWItNGJhMi04MjgzLWM0OWQzODE2NDBiZCJ9LCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAiaXNzIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgiLCAiaWF0IjogMTMxMzYwMTg4LCAidHlwIjogImZha2UiLCAibmJmIjogMTMxMzYwMTg1LCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0.SGF5lCYvGQEoILyq_tVBD_gPYp00dOTvRlgyOs4twmQ";
+
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ receipt_with_wrong_typ ]});
+  request.onsuccess = function() {
+    ok(false, "Wrong type");
+  }
+  request.onerror = function() {
+    ok(this.error.name == "RECEIPT_TYPE_UNSUPPORTED",
+       "Wrong type");
+    continueTest();
+  }
+  yield undefined;
+
+  // Test install with a valid receipt and a not valid one
+  var request = navigator.mozApps.install(gManifestURL, { receipts: [ receipt_few_segments, valid_receipt1 ]});
+  request.onsuccess = function() {
+    ok(false, "Less than 3 segments");
+  }
+  request.onerror = function() {
+    ok(this.error.name == "INVALID_SEGMENTS_NUMBER",
+       "Less than 3 segments");
+    continueTest();
+  }
+  yield undefined;
+
+  // All done.
+  ok(true, "All done");
+  finish();
+}
+
+addLoadEvent(go);
+
+</script>
+</pre>
+</body>
+</html>
\ No newline at end of file
--- a/dom/tests/mochitest/webapps/chrome.ini
+++ b/dom/tests/mochitest/webapps/chrome.ini
@@ -6,12 +6,11 @@ support-files =
   apps/*
 
 [test_bug_765063.xul]
 [test_bug_771294.xul]
 [test_cross_origin.xul]
 [test_getNotInstalled.xul]
 [test_install_app.xul]
 [test_install_errors.xul]
-[test_install_receipts.xul]
 [test_install_utf8.xul]
 [test_launch_paths.xul]
 [test_list_api.xul]
deleted file mode 100644
--- a/dom/tests/mochitest/webapps/test_install_receipts.xul
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0"?>
-
-<!-- Any copyright is dedicated to the Public Domain.
-   - http://creativecommons.org/publicdomain/zero/1.0/ -->
-
-<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
-<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
-
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="Mozilla Bug 741549">
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
-  <script type="application/javascript" src="head.js"/>
-  <!-- test results are displayed in the html:body -->
-  <body xmlns="http://www.w3.org/1999/xhtml">
-  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=741549"
-     target="_blank">Mozilla Bug 741549</a>
-  </body>
-
-<script>
-
-SimpleTest.waitForExplicitFinish();
-
-var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
-
-var receipts = [
-  "a",
-  0,
-  true,
-  false,
-  null,
-  undefined,
-  { prop: 1 },
-  { nest: { ed: "hi" } },
-  NaN,
-  Infinity,
-];
-
-confirmNextInstall();
-navigator.mozApps.install(url, { receipts: receipts }).onsuccess =
-function onInstall() {
-  is(this.result.receipts[0], "a", "receipts[0]");
-  is(this.result.receipts[1], 0, "receipts[1]");
-  is(this.result.receipts[2], true, "receipts[2]");
-  is(this.result.receipts[3], false, "receipts[3]");
-  is(this.result.receipts[4], null, "receipts[4]");
-  is(this.result.receipts[5], undefined, "receipts[5]");
-  is(this.result.receipts[6].prop, 1, "receipts[6].prop");
-  is(this.result.receipts[7].nest.ed, "hi", "receipts[7].nest.ed");
-  todo_is(this.result.receipts[8], NaN, "receipts[8]");
-  todo_is(this.result.receipts[9], Infinity, "receipts[9]");
-
-  navigator.mozApps.mgmt.uninstall(this.result).onsuccess = function onUninstall() {
-    SimpleTest.finish();
-  }
-};
-
-</script>
-</window>