simplify some tests on the checkup page

This commit is contained in:
ansuz 2021-05-26 19:05:19 +05:30
parent bff38776f5
commit 9c3dc7aa9c
2 changed files with 40 additions and 53 deletions

View File

@ -574,6 +574,19 @@ define([
}
};
var deferredPostMessage = function (content, _cb) {
var cb = Util.once(Util.mkAsync(_cb));
nThen(function (w) {
sandboxIframeReady.reg(w(function (err) {
if (!err) { return; }
w.abort();
cb(err);
}));
}).nThen(function () {
postMessage(content, cb);
});
};
window.addEventListener('message', function (event) {
try {
var msg = JSON.parse(event.data);
@ -638,14 +651,7 @@ define([
var url = '/sheet/inner.html';
var cb = Util.once(Util.mkAsync(_cb));
msg.appendChild(CSP_WARNING(url));
nThen(function (w) {
sandboxIframeReady.reg(w(function (err) {
if (!err) { return; }
w.abort();
cb(err);
}));
}).nThen(function () {
postMessage({
deferredPostMessage({
command: 'GET_HEADER',
content: {
url: url,
@ -656,19 +662,11 @@ define([
cb(hasOnlyOfficeHeaders(CSP_headers));
});
});
});
assert(function (cb, msg) {
var url = '/common/onlyoffice/v4/web-apps/apps/spreadsheeteditor/main/index.html';
msg.appendChild(CSP_WARNING(url));
nThen(function (w) {
sandboxIframeReady.reg(w(function (err) {
if (!err) { return; }
w.abort();
cb(err);
}));
}).nThen(function () {
postMessage({
deferredPostMessage({
command: 'GET_HEADER',
content: {
url: url,
@ -679,7 +677,6 @@ define([
cb(hasOnlyOfficeHeaders(CSP_headers));
});
});
});
assert(function (cb, msg) {
var url = '/sheet/inner.html';
@ -689,14 +686,7 @@ define([
code("'cross-origin-opener-policy'"),
' headers set.',
]));
nThen(function (w) {
sandboxIframeReady.reg(w(function (err) {
if (!err) { return; }
w.abort();
cb(err);
}));
}).nThen(function () {
postMessage({
deferredPostMessage({
command: 'GET_HEADER',
content: {
url: url,
@ -706,7 +696,6 @@ define([
cb(content === 'same-origin');
});
});
});
if (false) {
assert(function (cb, msg) {

View File

@ -1,12 +1,10 @@
define([
'jquery',
//'/bower_components/nthen/index.js',
//'/common/common-util.js',
'/bower_components/tweetnacl/nacl-fast.min.js',
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
'less!/checkup/app-checkup.less',
], function ($ /*, nThen, Util */) {
], function ($) {
var postMessage = function (content) {
window.parent.postMessage(JSON.stringify(content), '*');
};