<commit_before>"use strict";

var fs = require("fs");

// The temporary file used for communications.
var tmpfile = phantom.args[0];
// The page .html file to load.
var url = phantom.args[1];
// Extra, optionally overridable stuff.
var options = JSON.parse(phantom.args[2] || {});

// Messages are sent to the parent by appending them to the tempfile.
// NOTE, the tempfile appears to be shared between asynchronously running grunt tasks
var sendMessage = function (arg) {
    var args = Array.isArray(arg) ? arg : [].slice.call(arguments);
    var channel = args[0];
    args[0] = channel;
    fs.write(tmpfile, JSON.stringify(args) + "\n", "a");
};

// This allows grunt to abort if the PhantomJS version isn"t adequate.
sendMessage("private", "version", phantom.version);

// Create a new page.
var page = require("webpage").create();

// Relay console logging messages.
page.onConsoleMessage = function (message) {

    if (message === 'done') {
        sendMessage("wcaglint.done", options);
    } else {
        sendMessage("console", message);
    }
};

page.onError = function (msg, trace) {
    sendMessage("error", msg, trace);
};

page.onInitialized = function() {
    //sendMessage("console", 'Page Loading...');
};

page.onLoadFinished = function(status) {
  sendMessage("console", 'Page Loaded. Starting Tests');
  // Do other things here...

};

page.open(url, function (status) {

    page.injectJs('../tasks/HTML_CodeSniffer/dist/HTMLCS.min.js');
    page.injectJs('../tasks/HTML_CodeSniffer/PhantomJS/runner.js');

    // Now Run. Note that page.evaluate() function is sanboxed to
    // the loaded page's context. We can't pass any variable to it.

    switch (options.accessibilityLevel) {
        case 'WCAG2A':
            page.evaluate(function() {
                HTMLCS_RUNNER.run('WCAG2A');
            });
        break;
        case 'WCAG2AA':
            page.evaluate(function() {
                HTMLCS_RUNNER.run('WCAG2AA');
            });
        break;
        case 'WCAG2AAA':<commit_msg>Forgot to remove the runner.js file from the inject script<commit_after>"use strict";

var fs = require("fs");

// The temporary file used for communications.
var tmpfile = phantom.args[0];
// The page .html file to load.
var url = phantom.args[1];
// Extra, optionally overridable stuff.
var options = JSON.parse(phantom.args[2] || {});

// Messages are sent to the parent by appending them to the tempfile.
// NOTE, the tempfile appears to be shared between asynchronously running grunt tasks
var sendMessage = function (arg) {
    var args = Array.isArray(arg) ? arg : [].slice.call(arguments);
    var channel = args[0];
    args[0] = channel;
    fs.write(tmpfile, JSON.stringify(args) + "\n", "a");
};

// This allows grunt to abort if the PhantomJS version isn"t adequate.
sendMessage("private", "version", phantom.version);

// Create a new page.
var page = require("webpage").create();

// Relay console logging messages.
page.onConsoleMessage = function (message) {

    if (message === 'done') {
        sendMessage("wcaglint.done", options);
    } else {
        sendMessage("console", message);
    }
};

page.onError = function (msg, trace) {
    sendMessage("error", msg, trace);
};

page.onInitialized = function() {
    //sendMessage("console", 'Page Loading...');
};

page.onLoadFinished = function(status) {
  sendMessage("console", 'Page Loaded. Starting Tests');
  // Do other things here...

};

page.open(url, function (status) {

    page.injectJs('../tasks/HTML_CodeSniffer/dist/HTMLCS.min.js');

    // Now Run. Note that page.evaluate() function is sanboxed to
    // the loaded page's context. We can't pass any variable to it.

    switch (options.accessibilityLevel) {
        case 'WCAG2A':
            page.evaluate(function() {
                HTMLCS_RUNNER.run('WCAG2A');
            });
        break;
        case 'WCAG2AA':
            page.evaluate(function() {
                HTMLCS_RUNNER.run('WCAG2AA');
            });
        break;
        case 'WCAG2AAA':
{'fraction_non_alphanumeric': 0.14459627329192545, 'fraction_numerical': 0.004968944099378882, 'mean_word_length': 2.931640625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6095175', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1200, 'n_words': 347}