Skip to content

Commit

Permalink
chore: clean up iframe origin code (dequelabs#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdnoC committed May 5, 2021
1 parent 9d7eb41 commit 61447b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ private static void injectIntoFrames(final WebDriver driver,
driver.switchTo().frame(frame);

js.executeScript(script);
js.executeScript("axe.configure({ allowedOrigins: ['<unsafe_all_origins>'] });");

List<WebElement> localParents = new ArrayList<>();

Expand Down Expand Up @@ -191,7 +190,6 @@ private static void injectIntoFramesAsync(final WebDriver driver,
driver.switchTo().frame(frame);

js.executeAsyncScript(script);
js.executeScript("axe.configure({ allowedOrigins: ['<unsafe_all_origins>'] });");

List<WebElement> localParents = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class AxeBuilder {
"var context = typeof arguments[0] === 'string' ? JSON.parse(arguments[0]) : arguments[0];" +
"context = context || document;" +
"var options = JSON.parse(arguments[1]);" +
"axe.configure({ allowedOrigins: ['<unsafe_all_origins>'] });" +
"axe.run(context, options, function (err, results) {" +
" {" +
" if (err) {" +
Expand All @@ -95,6 +94,8 @@ public class AxeBuilder {
" }" +
"});";

public final String iframeAllowScript = "axe.configure({ allowedOrigins: ['<unsafe_all_origins>'] });";

public final String sandboxBusterScript =
"const callback = arguments[arguments.length - 1];" +
"const iframes = Array.from(" +
Expand Down Expand Up @@ -449,6 +450,12 @@ private Results analyzeRawContext(final WebDriver webDriver, final Object rawCon
throw new RuntimeException("Unable to inject axe script", e);
}
}
try {
WebDriverInjectorExtensions.inject(
webDriver, iframeAllowScript, disableIframeTesting);
} catch (Exception e) {
throw new RuntimeException("Error when enabling iframe communication", e);
}
webDriver.manage().timeouts()
.setScriptTimeout(timeout, TimeUnit.SECONDS);

Expand Down

0 comments on commit 61447b8

Please sign in to comment.