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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 arguments: scriptArgs.map(arg => ({value: arg})) | 172 arguments: scriptArgs.map(arg => ({value: arg})) |
173 }); | 173 }); |
174 if (callResult.exceptionDetails) | 174 if (callResult.exceptionDetails) |
175 throwException(callResult.exceptionDetails, scriptName); | 175 throwException(callResult.exceptionDetails, scriptName); |
176 | 176 |
177 let promiseResult = await Runtime.awaitPromise({ | 177 let promiseResult = await Runtime.awaitPromise({ |
178 promiseObjectId: callResult.result.objectId | 178 promiseObjectId: callResult.result.objectId |
179 }); | 179 }); |
180 if (promiseResult.exceptionDetails) | 180 if (promiseResult.exceptionDetails) |
181 throwException(promiseResult.exceptionDetails, scriptName); | 181 throwException(promiseResult.exceptionDetails, scriptName); |
| 182 |
| 183 return Runtime.evaluate({ |
| 184 expression: "window.consoleLogs", |
| 185 returnByValue: true |
| 186 }) |
| 187 .then(result => |
| 188 { |
| 189 if (result.result.value.failures != 0) |
| 190 return Promise.reject("Test failure"); |
| 191 }); |
182 } | 192 } |
183 finally | 193 finally |
184 { | 194 { |
185 client.close(); | 195 client.close(); |
186 } | 196 } |
187 }); | 197 }); |
188 } | 198 } |
189 | 199 |
190 module.exports = function(script, scriptName, ...scriptArgs) | 200 module.exports = function(script, scriptName, ...scriptArgs) |
191 { | 201 { |
192 return ensureChromium(CHROMIUM_REVISION).then(chromiumPath => | 202 return ensureChromium(CHROMIUM_REVISION).then(chromiumPath => |
193 { | 203 { |
194 let child = startChromium(chromiumPath); | 204 let child = startChromium(chromiumPath); |
195 return Promise.race([ | 205 return Promise.race([ |
196 child.done, | 206 child.done, |
197 runScript(script, scriptName, scriptArgs) | 207 runScript(script, scriptName, scriptArgs) |
198 ]).then(result => | 208 ]).then(result => |
199 { | 209 { |
200 child.kill(); | 210 child.kill(); |
201 return result; | 211 return result; |
202 }).catch(error => | 212 }).catch(error => |
203 { | 213 { |
204 child.kill(); | 214 child.kill(); |
205 throw error; | 215 throw error; |
206 }); | 216 }); |
207 }); | 217 }); |
208 }; | 218 }; |
OLD | NEW |