Test cross-origin scripts

The next paragraph should contain two full error descriptions, neither of which is “Script error.”


Local script 1:

var displayed_error = null, last_error_message = null;
setInterval(function () {
    if (last_error_message === displayed_error)
        return;
    displayed_error = last_error_message;
    var e = document.getElementById("out");
    e.appendChild(document.createTextNode(displayed_error));
    e.appendChild(document.createElement("br"));
}, 500);

window.cause_error && cause_error(); // This causes an error in the cross-origin script (`cause_error.cors_error` is undefined).

Local script 2:

setTimeout(function () { local_error(); }, 1000); // This causes an error in the local context (`local_error` is undefined).

Copy of test-cors-script.js (fetched crossorigin):

var last_error_message = "Initializing";

window.onerror = function (errmsg) {
    last_error_message = errmsg;
};

function cause_error() {
    cause_error.cors_error();
}