|
|
@ -1,7 +1,10 @@
|
|
|
|
define([], function () {
|
|
|
|
define([], function () {
|
|
|
|
var out = function () { };
|
|
|
|
if (window.__CRYPTPAD_TEST_OBJ_) { return window.__CRYPTPAD_TEST_OBJ_; }
|
|
|
|
|
|
|
|
var out = window.__CRYPTPAD_TEST_OBJ__ = function (f) { if (out.testing) { f(); } };
|
|
|
|
out.passed = out.failed = out;
|
|
|
|
out.passed = out.failed = out;
|
|
|
|
if (window.location.hash.indexOf("test=auto") > -1) {
|
|
|
|
var enableAuto = function () {
|
|
|
|
|
|
|
|
console.log("Enable auto testing 1 " + window.origin);
|
|
|
|
|
|
|
|
if (window.__CRYPTPAD_TEST__) { return; }
|
|
|
|
var cpt = window.__CRYPTPAD_TEST__ = {
|
|
|
|
var cpt = window.__CRYPTPAD_TEST__ = {
|
|
|
|
data: [],
|
|
|
|
data: [],
|
|
|
|
getData: function () {
|
|
|
|
getData: function () {
|
|
|
@ -51,8 +54,7 @@ define([], function () {
|
|
|
|
error: { message: e.message, stack: e.stack }
|
|
|
|
error: { message: e.message, stack: e.stack }
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
out = function (f) { f(); };
|
|
|
|
out.testing = 'auto';
|
|
|
|
out.testing = true;
|
|
|
|
|
|
|
|
out.passed = function () {
|
|
|
|
out.passed = function () {
|
|
|
|
cpt.data.push({
|
|
|
|
cpt.data.push({
|
|
|
|
type: 'report',
|
|
|
|
type: 'report',
|
|
|
@ -71,13 +73,13 @@ define([], function () {
|
|
|
|
|
|
|
|
|
|
|
|
out.registerInner = function (sframeChan) {
|
|
|
|
out.registerInner = function (sframeChan) {
|
|
|
|
sframeChan.whenReg('EV_TESTDATA', function () {
|
|
|
|
sframeChan.whenReg('EV_TESTDATA', function () {
|
|
|
|
cpt.data.forEach(function (x) { sframeChan.fire('EV_TESTDATA', x); });
|
|
|
|
cpt.data.forEach(function (x) { sframeChan.event('EV_TESTDATA', x); });
|
|
|
|
// override cpt.data.push() with a function which will send the content to the
|
|
|
|
// override cpt.data.push() with a function which will send the content to the
|
|
|
|
// outside where it will go on the outer window cpt.data array.
|
|
|
|
// outside where it will go on the outer window cpt.data array.
|
|
|
|
cpt = window.__CRYPTPAD_TEST__ = {
|
|
|
|
cpt = window.__CRYPTPAD_TEST__ = {
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
push: function (elem) {
|
|
|
|
push: function (elem) {
|
|
|
|
sframeChan.fire('EV_TESTDATA', elem);
|
|
|
|
sframeChan.event('EV_TESTDATA', elem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getData: function () {
|
|
|
|
getData: function () {
|
|
|
@ -89,10 +91,9 @@ define([], function () {
|
|
|
|
out.registerOuter = function (sframeChan) {
|
|
|
|
out.registerOuter = function (sframeChan) {
|
|
|
|
sframeChan.on('EV_TESTDATA', function (data) { cpt.data.push(data); });
|
|
|
|
sframeChan.on('EV_TESTDATA', function (data) { cpt.data.push(data); });
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
} else if (window.location.hash.indexOf("test=manual") > -1) {
|
|
|
|
var enableManual = function () {
|
|
|
|
out = function (f) { f(); };
|
|
|
|
out.testing = 'manual';
|
|
|
|
out.testing = true;
|
|
|
|
|
|
|
|
out.passed = function () {
|
|
|
|
out.passed = function () {
|
|
|
|
window.alert("Test passed");
|
|
|
|
window.alert("Test passed");
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -101,10 +102,27 @@ define([], function () {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
out.registerInner = function () { };
|
|
|
|
out.registerInner = function () { };
|
|
|
|
out.registerOuter = function () { };
|
|
|
|
out.registerOuter = function () { };
|
|
|
|
} else {
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out.options = {};
|
|
|
|
out.testing = false;
|
|
|
|
out.testing = false;
|
|
|
|
out.registerInner = function () { };
|
|
|
|
out.registerInner = function () { };
|
|
|
|
out.registerOuter = function () { };
|
|
|
|
out.registerOuter = function () { };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (window.location.hash.indexOf("test=auto") > -1) {
|
|
|
|
|
|
|
|
enableAuto();
|
|
|
|
|
|
|
|
} else if (window.location.hash.indexOf("test=manual") > -1) {
|
|
|
|
|
|
|
|
enableManual();
|
|
|
|
|
|
|
|
} else if (document.cookie.indexOf('test=') === 0) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
var x = JSON.parse(decodeURIComponent(document.cookie.replace('test=', '')));
|
|
|
|
|
|
|
|
if (x.test === 'auto') {
|
|
|
|
|
|
|
|
out.options = x.opts;
|
|
|
|
|
|
|
|
enableAuto('auto');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("Enable auto testing " + window.origin);
|
|
|
|
|
|
|
|
} catch (e) { }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return out;
|
|
|
|
return out;
|
|
|
|
});
|
|
|
|
});
|
|
|
|