Skip to content

Commit

Permalink
standard error shown rather than actual error Fixes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
mpnkhan committed Jul 31, 2017
1 parent 10a6d35 commit b907ee9
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 51 deletions.
9 changes: 8 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ if (fs.existsSync(ssl_path)) {
fs.writeFile(tempFilename, source , function (err,data) {
if (err) throw err;
if(engine === 'htmlcs'){
var childArgs = ['--config=config/config.json', path.join(__dirname, 'src/HTMLCS_Run.js'), tempFilename, 'WCAG2AA', '1,2,3', output];
var childArgs = ['--config=config/config.json', path.join(__dirname, 'src/HTMLCS_Run.js'), tempFilename, 'WCAG2AA', errLevel, output];
}
if(engine === 'axe'){
var childArgs = ['--config=config/config.json', path.join(__dirname, 'src/axe_url.js'), tempFilename, output];
Expand All @@ -235,6 +235,13 @@ if (fs.existsSync(ssl_path)) {
res.write(stdout);
res.end();
log(stdout);
fs.unlink(tempFilename, (err) => {
if (err) {
console.log("failed to delete : "+ err);
} else {
console.log('successfully deleted ' + tempFilename);
}
});
})
})
})
106 changes: 56 additions & 50 deletions src/HTMLCS_Run.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,64 @@
// console.log(url, standard, errLevel, output, screenshot_url)
// phantom.exit();

window.setTimeout(function () {
// Override onConsoleMessage function for outputting.
page.onConsoleMessage = function (msg) {
if (msg === 'done') {
setTimeout(function(){
phantom.exit();
}, 0);
}
console.log(msg);
};
page.open(url, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit();
} else {
window.setTimeout(function () {
// Override onConsoleMessage function for outputting.
page.onConsoleMessage = function (msg) {
if (msg === 'done') {
setTimeout(function(){
phantom.exit();
}, 0);
}
console.log(msg);
};

page.onError = function (msg) {
console.log(msg);
phantom.exit();
};
page.onError = function (msg) {
console.log(msg);
phantom.exit();
};

page.injectJs('./src/htmlcs/build/HTMLCS.js');
page.injectJs('./src/htmlcs/build/HTMLCS.js');

// console.log('O U T P U T ' , output);
// console.log('errLevel' , errLevel);
// console.log('O U T P U T ' , output);
// console.log('errLevel' , errLevel);

if(output==='json'){
page.injectJs('runner_json.js');
} else{
page.injectJs('runner_html.js');
}
var data = {
standard : standard,
screenshot_url : screenshot_url,
errLevel: errLevel
};
if(output==='json'){
page.injectJs('runner_json.js');
} else{
page.injectJs('runner_html.js');
}
var data = {
standard : standard,
screenshot_url : screenshot_url,
errLevel: errLevel
};

switch (standard) {
case 'WCAG2A':
case 'WCAG2AA':
case 'WCAG2AAA':
case 'Section508':
page.evaluate(function(data) {
var screenshot_url = data.screenshot_url;
var standard = data.standard;
var errLevel = data.errLevel;

HTMLCS_RUNNER.run(standard, screenshot_url, errLevel);
}, data);
break;
default:
console.log('Unknown standard.');
// phantom.exit();
setTimeout(function(){
phantom.exit();
}, 0);
break;
}

}, 200); //E N D window.setTimeout
switch (standard) {
case 'WCAG2A':
case 'WCAG2AA':
case 'WCAG2AAA':
case 'Section508':
page.evaluate(function(data) {
var screenshot_url = data.screenshot_url;
var standard = data.standard;
var errLevel = data.errLevel;

HTMLCS_RUNNER.run(standard, screenshot_url, errLevel);
}, data);
break;
default:
console.log('Unknown standard.');
// phantom.exit();
setTimeout(function(){
phantom.exit();
}, 0);
break;
} //switch
}, 200); //E N D window.setTimeout
}//end if else
});//end

0 comments on commit b907ee9

Please sign in to comment.