<commit_before>//- JavaScript source code -- usable in browser Web Worker context only

//- worker-test.js ~~
//  A test script to see what technologies are available to a Web Worker.
//                                                          ~~ SRW, 25 Sep 2010

var checker = function (name, obj) {
        if (obj !== undefined) {
            postMessage(name + " is available.");
        }
    };

checker("JSON", JSON);
checker("WebSocket", WebSocket);
checker("XMLHttpRequest", XMLHttpRequest);
checker("location", location);

//- vim:set syntax=javascript:<commit_msg>Interesting result: silent failure to redirect a page from Web Worker context by changing "location.href". No error is thrown by Chrome, and the value of "location.href" never changes. Is it frozen?<commit_after>//- JavaScript source code -- usable in browser Web Worker context only

//- worker-test.js ~~
//  A test script to see what technologies are available to a Web Worker.
//                                                          ~~ SRW, 25 Sep 2010

var checker = function (name, obj) {
        if (obj !== undefined) {
            postMessage(name + " is available.");
        }
    },

    get_raw = function (url) {
        var req = new XMLHttpRequest();
        req.open('GET', url, false);    //- synchronous
        req.send(null);
    },

    google = "http://www.google.com";

checker("JSON", JSON);
checker("WebSocket", WebSocket);
checker("XMLHttpRequest", XMLHttpRequest);
checker("location", location);

try {

    location.href = google;
    postMessage("Tried redirecting to " + google + ".");
    postMessage("Went to " + location.href + " without error.");
    postMessage(get_raw(google));

} catch (err) {

    postMessage(err);

}

//- vim:set syntax=javascript:
{'fraction_non_alphanumeric': 0.13050847457627118, 'fraction_numerical': 0.006779661016949152, 'mean_word_length': 2.425531914893617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2967441', 'n_tokens_mistral': 499, 'n_tokens_neox': 482, 'n_words': 159}