diff --git a/lib/index.js b/lib/index.js index 5967311..fdb550c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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); }); diff --git a/lib/inject.js b/lib/inject.js index 2d5af39..3f6f4d6 100644 --- a/lib/inject.js +++ b/lib/inject.js @@ -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();