OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 fs.rmdirSync(dirPath); | 52 fs.rmdirSync(dirPath); |
53 } | 53 } |
54 catch (error) | 54 catch (error) |
55 { | 55 { |
56 console.error(error); | 56 console.error(error); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 function startChromium(chromiumPath) | 60 function startChromium(chromiumPath) |
61 { | 61 { |
62 fs.chmodSync(chromiumPath, fs.constants.S_IRWXU); | 62 // fs.constants.S_IRWXU is undefined on Windows, so we use a numerical const. |
| 63 fs.chmodSync(chromiumPath, 0o700); |
63 | 64 |
64 let dataDir = fs.mkdtempSync(path.join(os.tmpdir(), "chromium-data")); | 65 let dataDir = fs.mkdtempSync(path.join(os.tmpdir(), "chromium-data")); |
65 let child = null; | 66 let child = null; |
66 return { | 67 return { |
67 kill: () => child && child.kill(), | 68 kill: () => child && child.kill(), |
68 done: new Promise((resolve, reject) => | 69 done: new Promise((resolve, reject) => |
69 { | 70 { |
70 child = childProcess.execFile(chromiumPath, [ | 71 child = childProcess.execFile(chromiumPath, [ |
71 "--headless", "--single-process", "--disable-gpu", "--no-sandbox", | 72 "--headless", "--single-process", "--disable-gpu", "--no-sandbox", |
72 "--allow-file-access-from-files", "--remote-debugging-port=9222", | 73 "--allow-file-access-from-files", "--remote-debugging-port=9222", |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 { | 209 { |
209 child.kill(); | 210 child.kill(); |
210 return result; | 211 return result; |
211 }).catch(error => | 212 }).catch(error => |
212 { | 213 { |
213 child.kill(); | 214 child.kill(); |
214 throw error; | 215 throw error; |
215 }); | 216 }); |
216 }); | 217 }); |
217 }; | 218 }; |
OLD | NEW |