|
|
|
@ -1,7 +1,10 @@ |
|
|
|
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; |
|
|
|
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__ = { |
|
|
|
data: [], |
|
|
|
getData: function () { |
|
|
|
@ -51,8 +54,7 @@ define([], function () { |
|
|
|
error: { message: e.message, stack: e.stack } |
|
|
|
}); |
|
|
|
}; |
|
|
|
out = function (f) { f(); }; |
|
|
|
out.testing = true; |
|
|
|
out.testing = 'auto'; |
|
|
|
out.passed = function () { |
|
|
|
cpt.data.push({ |
|
|
|
type: 'report', |
|
|
|
@ -71,13 +73,13 @@ define([], function () { |
|
|
|
|
|
|
|
out.registerInner = function (sframeChan) { |
|
|
|
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
|
|
|
|
// outside where it will go on the outer window cpt.data array.
|
|
|
|
cpt = window.__CRYPTPAD_TEST__ = { |
|
|
|
data: { |
|
|
|
push: function (elem) { |
|
|
|
sframeChan.fire('EV_TESTDATA', elem); |
|
|
|
sframeChan.event('EV_TESTDATA', elem); |
|
|
|
} |
|
|
|
}, |
|
|
|
getData: function () { |
|
|
|
@ -89,10 +91,9 @@ define([], function () { |
|
|
|
out.registerOuter = function (sframeChan) { |
|
|
|
sframeChan.on('EV_TESTDATA', function (data) { cpt.data.push(data); }); |
|
|
|
}; |
|
|
|
|
|
|
|
} else if (window.location.hash.indexOf("test=manual") > -1) { |
|
|
|
out = function (f) { f(); }; |
|
|
|
out.testing = true; |
|
|
|
}; |
|
|
|
var enableManual = function () { |
|
|
|
out.testing = 'manual'; |
|
|
|
out.passed = function () { |
|
|
|
window.alert("Test passed"); |
|
|
|
}; |
|
|
|
@ -101,10 +102,27 @@ define([], function () { |
|
|
|
}; |
|
|
|
out.registerInner = function () { }; |
|
|
|
out.registerOuter = function () { }; |
|
|
|
} else { |
|
|
|
out.testing = false; |
|
|
|
out.registerInner = function () { }; |
|
|
|
out.registerOuter = function () { }; |
|
|
|
}; |
|
|
|
|
|
|
|
out.options = {}; |
|
|
|
out.testing = false; |
|
|
|
out.registerInner = 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; |
|
|
|
}); |