Compare commits

..

3 Commits

Author SHA1 Message Date
34c6a089b5 fix(client,sdk): permit cross-domain message communication
All checks were successful
arcad/edge/pipeline/head This commit looks good
2023-04-06 20:54:01 +02:00
da73b842e1 fix(sdk,client): initialize crossframe observers after window load event
All checks were successful
arcad/edge/pipeline/head This commit looks good
2023-04-06 19:18:36 +02:00
55d7241d95 chore(sdk,client): remove restrictive assertion
All checks were successful
arcad/edge/pipeline/head This commit looks good
2023-04-06 18:18:12 +02:00
4 changed files with 32 additions and 18 deletions

View File

@ -39,7 +39,6 @@ describe('App Module', function() {
.then(url => {
console.log("getAppUrl result:", url);
chai.assert.isNotEmpty(url);
chai.assert.match(url, /^http:\/\/127\.0\.0\.1/)
})
});

View File

@ -4095,16 +4095,16 @@ var Edge = (() => {
constructor() {
super();
this.debug = false;
this._initResizeObserver();
this._initTitleMutationObserver();
this._handleWindowMessage = this._handleWindowMessage.bind(this);
this._initObservers = this._initObservers.bind(this);
window.addEventListener("load", this._initObservers);
window.addEventListener("message", this._handleWindowMessage);
}
post(message, target = window.parent) {
if (!target)
return;
this._log("sending crossframe message", message);
target.postMessage(message);
target.postMessage(message, "*");
}
_log(...args) {
if (!this.debug)
@ -4119,6 +4119,10 @@ var Edge = (() => {
});
this.dispatchEvent(event);
}
_initObservers() {
this._initResizeObserver();
this._initTitleMutationObserver();
}
_initTitleMutationObserver() {
const titleObserver = new MutationObserver((mutations) => {
const title2 = mutations[0].target.textContent;
@ -4132,24 +4136,27 @@ var Edge = (() => {
}
_initResizeObserver() {
const resizeObserver = new ResizeObserver(() => {
const body = document.body, html = document.documentElement;
const body2 = document.body, html = document.documentElement;
const height = Math.max(
body.scrollHeight,
body.offsetHeight,
body2.scrollHeight,
body2.offsetHeight,
html.clientHeight,
html.scrollHeight,
html.offsetHeight
);
const width = Math.max(
body.scrollWidth,
body.offsetWidth,
body2.scrollWidth,
body2.offsetWidth,
html.clientWidth,
html.scrollWidth,
html.offsetWidth
);
this.post({ type: "size_changed" /* SIZE_CHANGED */, data: { height, width } });
});
resizeObserver.observe(document.body);
const body = document.body;
if (!body)
return;
resizeObserver.observe(body);
}
};

File diff suppressed because one or more lines are too long

View File

@ -17,18 +17,17 @@ export class CrossFrameMessenger extends EventTarget {
super()
this.debug = false;
this._initResizeObserver();
this._initTitleMutationObserver();
this._handleWindowMessage = this._handleWindowMessage.bind(this);
this._initObservers = this._initObservers.bind(this);
window.addEventListener('load', this._initObservers);
window.addEventListener('message', this._handleWindowMessage)
}
post(message: CrossFrameMessage, target: Window = window.parent) {
if (!target) return;
this._log("sending crossframe message", message);
target.postMessage(message)
target.postMessage(message, '*');
}
_log(...args) {
@ -46,6 +45,11 @@ export class CrossFrameMessenger extends EventTarget {
this.dispatchEvent(event);
}
_initObservers() {
this._initResizeObserver();
this._initTitleMutationObserver();
}
_initTitleMutationObserver() {
const titleObserver = new MutationObserver((mutations) => {
const title = mutations[0].target.textContent;
@ -75,6 +79,10 @@ export class CrossFrameMessenger extends EventTarget {
this.post({ type: CrossFrameMessageType.SIZE_CHANGED, data: { height, width }});
});
resizeObserver.observe(document.body);
const body = document.body;
if (!body) return;
resizeObserver.observe(body);
}
}