|
|
@ -1,39 +1,13 @@
|
|
|
|
define([], function () {
|
|
|
|
define([], function () {
|
|
|
|
var out = function () { };
|
|
|
|
var out = function () { };
|
|
|
|
out.passed = out;
|
|
|
|
out.passed = out.failed = out;
|
|
|
|
var mkReport = function (list, pass) {
|
|
|
|
|
|
|
|
var rpt = document.createElement('div');
|
|
|
|
|
|
|
|
rpt.textContent = JSON.stringify(list);
|
|
|
|
|
|
|
|
rpt.setAttribute('class', 'report ' + (pass ? 'success' : 'failure'));
|
|
|
|
|
|
|
|
rpt.setAttribute('style', 'display:none;');
|
|
|
|
|
|
|
|
document.body.appendChild(rpt);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if (window.location.hash.indexOf("?test=test") > -1) {
|
|
|
|
if (window.location.hash.indexOf("?test=test") > -1) {
|
|
|
|
window.onerror = function (msg, url, lineNo, columnNo, e) {
|
|
|
|
|
|
|
|
mkReport([
|
|
|
|
|
|
|
|
msg,
|
|
|
|
|
|
|
|
url,
|
|
|
|
|
|
|
|
lineNo,
|
|
|
|
|
|
|
|
columnNo,
|
|
|
|
|
|
|
|
e ? e.message : null,
|
|
|
|
|
|
|
|
e ? e.stack : null
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
require.onError = function (e) {
|
|
|
|
|
|
|
|
mkReport([
|
|
|
|
|
|
|
|
e ? e.message : null,
|
|
|
|
|
|
|
|
e ? e.stack : null
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
out = function (f) { f(); };
|
|
|
|
|
|
|
|
out.passed = function () { mkReport("Test Passed", true); };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cpt = window.__CRYPTPAD_TEST__ = {
|
|
|
|
var cpt = window.__CRYPTPAD_TEST__ = {
|
|
|
|
logs: [],
|
|
|
|
data: [],
|
|
|
|
getLogs: function () {
|
|
|
|
getData: function () {
|
|
|
|
var logs = JSON.stringify(cpt.logs);
|
|
|
|
var data = JSON.stringify(cpt.data);
|
|
|
|
cpt.logs = [];
|
|
|
|
cpt.data = [];
|
|
|
|
return logs;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -52,13 +26,47 @@ define([], function () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var out = [s];
|
|
|
|
var out = [s];
|
|
|
|
try { throw new Error(); } catch (e) { out.push(e.stack.split('\n')[3]); }
|
|
|
|
try { throw new Error(); } catch (e) { out.push(e.stack.split('\n')[3]); }
|
|
|
|
window.__CRYPTPAD_TEST__.logs.push(out);
|
|
|
|
cpt.data.push({ type: 'log', val: out.join('') });
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
window.console._error = window.console.error;
|
|
|
|
window.console._error = window.console.error;
|
|
|
|
window.console._log = window.console.log;
|
|
|
|
window.console._log = window.console.log;
|
|
|
|
window.console.error = function (e) { window.console._error(e); doLog(e); };
|
|
|
|
window.console.error = function (e) { window.console._error(e); doLog(e); };
|
|
|
|
window.console.log = function (l) { window.console._log(l); doLog(l); };
|
|
|
|
window.console.log = function (l) { window.console._log(l); doLog(l); };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.onerror = function (msg, url, lineNo, columnNo, e) {
|
|
|
|
|
|
|
|
cpt.data.push({
|
|
|
|
|
|
|
|
type: 'report',
|
|
|
|
|
|
|
|
val: 'failed',
|
|
|
|
|
|
|
|
error: {
|
|
|
|
|
|
|
|
message: e ? e.message : msg,
|
|
|
|
|
|
|
|
stack: e ? e.stack : (url + ":" + lineNo)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
require.onError = function (e) {
|
|
|
|
|
|
|
|
cpt.data.push({
|
|
|
|
|
|
|
|
type: 'report',
|
|
|
|
|
|
|
|
val: 'failed',
|
|
|
|
|
|
|
|
error: { message: e.message, stack: e.stack }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
out = function (f) { f(); };
|
|
|
|
|
|
|
|
out.passed = function () {
|
|
|
|
|
|
|
|
cpt.data.push({
|
|
|
|
|
|
|
|
type: 'report',
|
|
|
|
|
|
|
|
val: 'passed'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
out.failed = function (reason) {
|
|
|
|
|
|
|
|
var e;
|
|
|
|
|
|
|
|
try { throw new Error(reason); } catch (err) { e = err; }
|
|
|
|
|
|
|
|
cpt.data.push({
|
|
|
|
|
|
|
|
type: 'report',
|
|
|
|
|
|
|
|
val: 'failed',
|
|
|
|
|
|
|
|
error: { message: e.message, stack: e.stack }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
return out;
|
|
|
|
});
|
|
|
|
});
|