Bug 1382260 - Patch 1 - Fix file access test bug. r=Alex_Gaynor draft
authorHaik Aftandilian <haftandilian@mozilla.com>
Tue, 22 Aug 2017 10:11:01 -0700
changeset 650730 5fba75d65081e56df5a0d171c41689c489a3aace
parent 650624 213ddee21b186586bbd45efd7c5d04f043166d3c
child 650731 2be518462fbe584c5efa0cc98c03937d12707a15
child 651435 9aa778bc08bee206e7f3340eac32ca2f46a4f81b
push id75473
push userhaftandilian@mozilla.com
push dateTue, 22 Aug 2017 19:15:39 +0000
reviewersAlex_Gaynor
bugs1382260
milestone57.0a1
Bug 1382260 - Patch 1 - Fix file access test bug. r=Alex_Gaynor Fix the file access check by adding missing parentheses to isDirectory method call. Don't run the cookies file check on Linux because the test profile is read accessible due to being in /tmp. MozReview-Commit-ID: lps2hk8f5U
security/sandbox/test/browser_content_sandbox_fs.js
--- a/security/sandbox/test/browser_content_sandbox_fs.js
+++ b/security/sandbox/test/browser_content_sandbox_fs.js
@@ -448,32 +448,45 @@ async function testFileAccess() {
       minLevel: 0,
     });
   } else {
     ok(false, `${chromeDir.path} is valid dir`);
   }
 
   let cookiesFile = GetProfileEntry("cookies.sqlite");
   if (cookiesFile.exists() && !cookiesFile.isDirectory()) {
-    tests.push({
-      desc:     "cookies file",
-      ok:       false,
-      browser:  webBrowser,
-      file:     cookiesFile,
-      minLevel: minProfileReadSandboxLevel(),
-    });
+    // On Linux, the temporary profile used for tests is in the system
+    // temp dir which content has read access to, so this test fails.
+    if (!isLinux()) {
+      tests.push({
+        desc:     "cookies file",
+        ok:       false,
+        browser:  webBrowser,
+        file:     cookiesFile,
+        minLevel: minProfileReadSandboxLevel(),
+      });
+    }
+    if (fileContentProcessEnabled) {
+      tests.push({
+        desc:     "cookies file",
+        ok:       true,
+        browser:  fileBrowser,
+        file:     cookiesFile,
+        minLevel: 0,
+      });
+    }
   } else {
     ok(false, `${cookiesFile.path} is a valid file`);
   }
 
   // remove tests not enabled by the current sandbox level
   tests = tests.filter((test) => (test.minLevel <= level));
 
   for (let test of tests) {
-    let testFunc = test.file.isDirectory ? readDir : readFile;
+    let testFunc = test.file.isDirectory() ? readDir : readFile;
     let okString = test.ok ? "allowed" : "blocked";
     let processType = test.browser === webBrowser ? "web" : "file";
 
     let result = await ContentTask.spawn(test.browser, test.file.path,
         testFunc);
 
     ok(result.ok == test.ok,
         `reading ${test.desc} from a ${processType} process ` +