Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
fix: inject raw source to work with limited CSPs
Browse files Browse the repository at this point in the history
Note: tests fail because results are inapplicable
  • Loading branch information
Marcy Sutton committed May 1, 2017
1 parent e8a3245 commit b6fa546
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ AxeBuilder.prototype.analyze = function(callback) {
.executeAsyncScript(function(context, options, config) {
/*global document, axe */
if (config !== null) {
axe.configure(config);
window.axe.configure(config);
}
axe.a11yCheck(context || document, options, arguments[arguments.length - 1]);
window.axe.a11yCheck(context || document, options, arguments[arguments.length - 1]);
}, context, options, config)
.then(callback);
});
Expand Down
11 changes: 2 additions & 9 deletions lib/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,8 @@ function findFramesAndInject(parent, script, driver) {
module.exports = function(driver, axeSource, config, callback) {
axeSource = axeSource || require('axe-core').source;

var branding = {branding:{application:"webdriverjs"}};
var configSrc = JSON.stringify(Object.assign(branding, config || {}));
var script = '(function () {' +
'if (typeof axe === "object" && axe.version) { return; }' +
'var s = document.createElement("script");' +
// stringify so that quotes are properly escaped
's.innerHTML = ' + JSON.stringify(axeSource + ';' + 'axe.configure('+ configSrc +');') + ';' +
'document.body.appendChild(s);' +
'}());';
var configSrc = config !== null ? JSON.stringify(config) + ';' : '';
var script = axeSource + configSrc + 'axe.configure({branding:{application:"webdriverjs"}});';

driver
.switchTo().defaultContent();
Expand Down

0 comments on commit b6fa546

Please sign in to comment.