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
--- 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 ` +