Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions images/chromium-headful/client/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,17 @@
}
}

get parentOrigin() {
try {
if (document.referrer) {
return new URL(document.referrer).origin
}
} catch (e) {
// fallback if referrer is not a valid URL
}
return '*'
}

@Watch('hideControls', { immediate: true })
onHideControls(enabled: boolean) {
if (enabled) {
Expand Down Expand Up @@ -262,6 +273,13 @@
onConnected(value: boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: the try/catch currently wraps applyQueryResolution() too, so the error message can be misleading (and it can swallow a real resolution bug).

Suggested change
onConnected(value: boolean) {
onConnected(value: boolean) {
if (!value) return
this.applyQueryResolution()
if (window.parent === window) return
try {
const parentOrigin = document.referrer ? new URL(document.referrer).origin : '*'
window.parent.postMessage({ type: 'KERNEL_CONNECTED', connected: true }, parentOrigin)
} catch (e) {
console.error('Failed to post message to parent', e)
}
}

if (value) {
this.applyQueryResolution()
try {
if (window.parent !== window) {
window.parent.postMessage({ type: 'KERNEL_CONNECTED', connected: true }, this.parentOrigin)
}
} catch (e) {
console.error('Failed to post message to parent', e)
}
}
}

Expand Down Expand Up @@ -326,5 +344,26 @@
get connected() {
return this.$accessor.connected
}

get playing() {
return this.$accessor.video.playing
}

@Watch('playing')
onPlaying(value: boolean) {
try {
if (window.parent === window) return

if (value) {
window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, this.parentOrigin)
} else {
window.parent.postMessage({ type: 'KERNEL_PAUSED', playing: false }, this.parentOrigin)
}
} catch (e) {
console.error('Failed to post message to parent', e)
}
}


}
</script>