Backed out changeset 66abf4f4ce8b (bug 1649616) for XPCshell failures in contextualidentity/tests/unit/test_corruptedFile.js
authorDorel Luca <dluca@mozilla.com>
Wed, 18 Nov 2020 19:35:17 +0200
changeset 557858 4537f81d738e5027cac34bba8e31d8bbe924f2be
parent 557857 0ad8ebb7f78bfc79da67d6dff80739bbe7dd2e1f
child 557859 860dc0a714ea8f641d2417798184817de43610d7
push id37962
push userapavel@mozilla.com
push dateWed, 18 Nov 2020 21:51:58 +0000
treeherdermozilla-central@9d797387f57c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1649616
milestone85.0a1
backs out66abf4f4ce8b5cfdb188575d7c1c3980cbc8f144
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
Backed out changeset 66abf4f4ce8b (bug 1649616) for XPCshell failures in contextualidentity/tests/unit/test_corruptedFile.js
toolkit/components/contextualidentity/ContextualIdentityService.jsm
--- a/toolkit/components/contextualidentity/ContextualIdentityService.jsm
+++ b/toolkit/components/contextualidentity/ContextualIdentityService.jsm
@@ -29,16 +29,17 @@ XPCOMUtils.defineLazyGetter(this, "gText
   return new TextEncoder();
 });
 
 ChromeUtils.defineModuleGetter(
   this,
   "AsyncShutdown",
   "resource://gre/modules/AsyncShutdown.jsm"
 );
+ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
 ChromeUtils.defineModuleGetter(
   this,
   "DeferredTask",
   "resource://gre/modules/DeferredTask.jsm"
 );
 ChromeUtils.defineModuleGetter(
   this,
   "FileUtils",
@@ -164,17 +165,17 @@ function _ContextualIdentityService(path
         await this.closeContainerTabs();
         this.notifyAllContainersCleared();
         this.resetDefault();
       }
     }
   },
 
   load() {
-    return IOUtils.read(this._path).then(
+    return OS.File.read(this._path).then(
       bytes => {
         // If synchronous loading happened in the meantime, exit now.
         if (this._dataReady) {
           return;
         }
 
         try {
           this.parseData(bytes);
@@ -211,17 +212,24 @@ function _ContextualIdentityService(path
     // Let's delete all the data of any userContextId. 1 is the first valid
     // userContextId value.
     this.deleteContainerData();
 
     this.saveSoon();
   },
 
   loadError(error) {
-    if (error != null && error.name != "NotFoundError") {
+    if (
+      error != null &&
+      !(error instanceof OS.File.Error && error.becauseNoSuchFile) &&
+      !(
+        error instanceof Components.Exception &&
+        error.result == Cr.NS_ERROR_FILE_NOT_FOUND
+      )
+    ) {
       // Let's report the error.
       Cu.reportError(error);
     }
 
     // If synchronous loading happened in the meantime, exit now.
     if (this._dataReady) {
       return;
     }
@@ -253,17 +261,17 @@ function _ContextualIdentityService(path
 
     let object = {
       version: LAST_CONTAINERS_JSON_VERSION,
       lastUserContextId: this._lastUserContextId,
       identities: this._identities,
     };
 
     let bytes = gTextEncoder.encode(JSON.stringify(object));
-    return IOUtils.writeAtomic(this._path, bytes, {
+    return OS.File.writeAtomic(this._path, bytes, {
       tmpPath: this._path + ".tmp",
     });
   },
 
   create(name, icon, color) {
     this.ensureDataReady();
 
     // Retrieve the next userContextId available.
@@ -640,13 +648,10 @@ function _ContextualIdentityService(path
     data.identities.push(webextStorageLocalIdentity);
 
     data.version = 4;
 
     return data;
   },
 };
 
-let path = PathUtils.join(
-  Services.dirsvc.get("ProfD", Ci.nsIFile).path,
-  "containers.json"
-);
+let path = OS.Path.join(OS.Constants.Path.profileDir, "containers.json");
 var ContextualIdentityService = new _ContextualIdentityService(path);