simplify some tests on the checkup page

pull/1/head
ansuz 4 years ago
parent bff38776f5
commit 9c3dc7aa9c

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

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

Loading…
Cancel
Save