Skip to content

Commit

Permalink
Only run scripts that needs privileges in Firefox. (#1558)
Browse files Browse the repository at this point in the history
* Only run scripts that needs privileges in Firefox.

#1557

* requires are never an array
  • Loading branch information
soulgalore committed Apr 26, 2021
1 parent 740989f commit 6b270ee
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lib/core/seleniumRunner.js
Expand Up @@ -599,10 +599,11 @@ class SeleniumRunner {
async runScriptInCategory(category, isAsync) {
const scriptNames = Object.keys(category);
const results = {};
let requires = [];
let requires;

for (let scriptName of scriptNames) {
let isAsyncOverride = false;
requires = {};
let script = category[scriptName];

if (typeof script != 'string') {
Expand All @@ -629,15 +630,21 @@ class SeleniumRunner {
requires = category[scriptName].requires;
isAsyncOverride = category[scriptName].isAsync;
}

const result = await this.runScriptFromCategory(
script,
isAsync || isAsyncOverride,
scriptName,
requires
);
if (!(result === null || result === undefined)) {
results[scriptName] = result;
if (
Object.keys(requires).length > 0 &&
this.options.browser !== 'firefox'
) {
// Require is only for running in Firefox
} else {
const result = await this.runScriptFromCategory(
script,
isAsync || isAsyncOverride,
scriptName,
requires
);
if (!(result === null || result === undefined)) {
results[scriptName] = result;
}
}
}
return results;
Expand Down

0 comments on commit 6b270ee

Please sign in to comment.