Bug 1447903: Part 8c - Update test_proxies to use bootstrapped extensions. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Wed, 21 Mar 2018 19:52:09 -0700
changeset 772375 67d08afbc5c0123cf6f708318b2dce54f21a3804
parent 772374 409352b6bc3b817e683f5be97c120d5d6c75fbc8
child 772376 5e50fd1ea7e0a23f4721b2b8cdedba95ac2c9876
push id103897
push usermaglione.k@gmail.com
push dateMon, 26 Mar 2018 01:31:53 +0000
reviewersaswan
bugs1447903
milestone61.0a1
Bug 1447903: Part 8c - Update test_proxies to use bootstrapped extensions. r?aswan MozReview-Commit-ID: 7k3gbJNlpDE
toolkit/mozapps/extensions/test/xpcshell/head_addons.js
toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -79,17 +79,16 @@ const LEGACY_NON_RESTARTLESS_TESTS = new
   "test_bug455906.js",
   "test_bug470377_1.js",
   "test_bug470377_2.js",
   "test_bug470377_3.js",
   "test_bug470377_4.js",
   "test_bug655254.js",
   "test_cacheflush.js",
   "test_checkcompatibility.js",
-  "test_proxies.js",
   "test_signed_verify.js",
   "test_strictcompatibility.js",
   "test_syncGUID.js",
   "test_upgrade.js",
 ]);
 
 if (LEGACY_NON_RESTARTLESS_TESTS.has(_TEST_FILE[0].replace(/.*\//, ""))) {
   Services.prefs.setBoolPref("extensions.legacy.non-restartless.enabled", true);
--- a/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
@@ -25,16 +25,17 @@ var ADDONS = [
   {
     id: "symlink2@tests.mozilla.org",
     type: "symlink"
   }
 ];
 
 var METADATA = {
   version: "2.0",
+  bootstrap: true,
   targetApplications: [{
     id: "xpcshell@tests.mozilla.org",
     minVersion: "2",
     maxVersion: "2"
   }]
 };
 
 const gHaveSymlinks = AppConstants.platform != "win";
@@ -44,27 +45,21 @@ function createSymlink(aSource, aDest) {
   if (aSource instanceof AM_Ci.nsIFile)
     aSource = aSource.path;
   if (aDest instanceof AM_Ci.nsIFile)
     aDest = aDest.path;
 
   return OS.File.unixSymLink(aSource, aDest);
 }
 
-function writeFile(aData, aFile) {
+function promiseWriteFile(aFile, aData) {
   if (!aFile.parent.exists())
     aFile.parent.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
 
-  var fos = AM_Cc["@mozilla.org/network/file-output-stream;1"].
-            createInstance(AM_Ci.nsIFileOutputStream);
-  fos.init(aFile,
-           FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE,
-           FileUtils.PERMS_FILE, 0);
-  fos.write(aData, aData.length);
-  fos.close();
+  return OS.File.writeAtomic(aFile.path, new TextEncoder().encode(aData));
 }
 
 function checkAddonsExist() {
   for (let addon of ADDONS) {
     let file = addon.directory.clone();
     file.append("install.rdf");
     Assert.ok(file.exists(), Components.stack.caller);
   }
@@ -98,17 +93,17 @@ async function run_proxy_tests() {
     addon.proxyFile = profileDir.clone();
     addon.proxyFile.append(addon.dirId || addon.id);
 
     METADATA.id = addon.id;
     METADATA.name = addon.id;
     writeInstallRDFToDir(METADATA, gTmpD);
 
     if (addon.type == "proxy") {
-      writeFile(addon.directory.path, addon.proxyFile);
+      await promiseWriteFile(addon.proxyFile, addon.directory.path);
     } else if (addon.type == "symlink") {
       await createSymlink(addon.directory, addon.proxyFile);
     }
   }
 
   startupManager();
 
   // Check that all add-ons original sources still exist after invalid