Skip to content
Merged
Changes from 3 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
32 changes: 30 additions & 2 deletions images/chromium-headful/client/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,15 @@
// Add a watcher so that when we are connected we can set the resolution from query params
@Watch('connected', { immediate: true })
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 (value) {
this.applyQueryResolution()
if (window.parent !== window) {
window.parent.postMessage({ type: 'KERNEL_CONNECTED', connected: true }, '*')
}
}
} catch (e) {
console.error('Failed to post message to parent', e)
Copy link

Choose a reason for hiding this comment

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

Missing disconnected notification to parent frame

Medium Severity

The onConnected watcher only posts a KERNEL_CONNECTED message when connected becomes true, but doesn't notify the parent frame when the connection is lost (connected becomes false). This is inconsistent with the onPlaying watcher, which correctly posts both KERNEL_PLAYING and KERNEL_PAUSED messages for both state transitions. The parent frame won't be informed when the kernel disconnects, which could leave it in an incorrect state.

Fix in Cursor Fix in Web

}
}

Expand Down Expand Up @@ -326,5 +333,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 }, '*')
Copy link
Contributor

Choose a reason for hiding this comment

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

For the postMessage calls, consider using a best-effort targetOrigin instead of '*' (falling back to '*' when referrer is missing). It reduces accidental message delivery if this ever ends up embedded in unexpected places.

Suggested change
window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, '*')
const parentOrigin = document.referrer ? new URL(document.referrer).origin : '*'
window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, parentOrigin)

} else {
window.parent.postMessage({ type: 'KERNEL_PAUSED', playing: false }, '*')
Copy link
Contributor

Choose a reason for hiding this comment

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

Same targetOrigin point for the paused case:

Suggested change
window.parent.postMessage({ type: 'KERNEL_PAUSED', playing: false }, '*')
const parentOrigin = document.referrer ? new URL(document.referrer).origin : '*'
window.parent.postMessage({ type: 'KERNEL_PAUSED', playing: false }, parentOrigin)

}
} catch (e) {
console.error('Failed to post message to parent', e)
}
}


}
</script>