From be40f7ad78fd7b538dc0a2ac8669ac9a9ff36531 Mon Sep 17 00:00:00 2001 From: Abdul Rashid Date: Tue, 13 Jan 2026 00:47:00 +0530 Subject: [PATCH 1/3] feat: add kernel iframe events and test page --- images/chromium-headful/client/src/app.vue | 35 +++++++- test.html | 93 ++++++++++++++++++++++ 2 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 test.html diff --git a/images/chromium-headful/client/src/app.vue b/images/chromium-headful/client/src/app.vue index f7d629c0..1a9b6bd8 100644 --- a/images/chromium-headful/client/src/app.vue +++ b/images/chromium-headful/client/src/app.vue @@ -260,8 +260,13 @@ // Add a watcher so that when we are connected we can set the resolution from query params @Watch('connected', { immediate: true }) onConnected(value: boolean) { - if (value) { - this.applyQueryResolution() + try { + if (value) { + this.applyQueryResolution() + window.parent.postMessage({ type: 'KERNEL_CONNECTED', connected: true }, '*') + } + } catch (e) { + console.error('Failed to post message to parent', e) } } @@ -326,5 +331,31 @@ get connected() { return this.$accessor.connected } + + get playing() { + return this.$accessor.video.playing + } + + @Watch('playing') + onPlaying(value: boolean) { + try { + if (value) { + window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, '*') + } else { + window.parent.postMessage({ type: 'KERNEL_PAUSED', playing: false }, '*') + } + } catch (e) { + console.error('Failed to post message to parent', e) + } + } + + @Watch('playable') + onPlayable(value: boolean) { + try { + window.parent.postMessage({ type: 'KERNEL_PLAYABLE', playable: value }, '*') + } catch (e) { + console.error('Failed to post message to parent', e) + } + } } diff --git a/test.html b/test.html new file mode 100644 index 00000000..dc4f8bb8 --- /dev/null +++ b/test.html @@ -0,0 +1,93 @@ + + + + + + + Kernel Message Listener + + + + +

Kernel Iframe Message Listener

+
+ + +
+
Waiting for messages...
+
+
+ + + + + \ No newline at end of file From 3127b65129e831241bcd178d282809422d630fad Mon Sep 17 00:00:00 2001 From: Abdul Rashid Date: Wed, 14 Jan 2026 17:33:36 +0530 Subject: [PATCH 2/3] chore: remove playable watcher and add postMessage guards --- images/chromium-headful/client/src/app.vue | 15 ++-- test.html | 93 ---------------------- 2 files changed, 6 insertions(+), 102 deletions(-) delete mode 100644 test.html diff --git a/images/chromium-headful/client/src/app.vue b/images/chromium-headful/client/src/app.vue index 1a9b6bd8..82140671 100644 --- a/images/chromium-headful/client/src/app.vue +++ b/images/chromium-headful/client/src/app.vue @@ -263,7 +263,9 @@ try { if (value) { this.applyQueryResolution() - window.parent.postMessage({ type: 'KERNEL_CONNECTED', connected: true }, '*') + if (window.parent !== window) { + window.parent.postMessage({ type: 'KERNEL_CONNECTED', connected: true }, '*') + } } } catch (e) { console.error('Failed to post message to parent', e) @@ -339,6 +341,8 @@ @Watch('playing') onPlaying(value: boolean) { try { + if (window.parent === window) return + if (value) { window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, '*') } else { @@ -349,13 +353,6 @@ } } - @Watch('playable') - onPlayable(value: boolean) { - try { - window.parent.postMessage({ type: 'KERNEL_PLAYABLE', playable: value }, '*') - } catch (e) { - console.error('Failed to post message to parent', e) - } - } + } diff --git a/test.html b/test.html deleted file mode 100644 index dc4f8bb8..00000000 --- a/test.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - Kernel Message Listener - - - - -

Kernel Iframe Message Listener

-
- - -
-
Waiting for messages...
-
-
- - - - - \ No newline at end of file From 147b97b2b520db80b736d68afb0c5fb4dfe3f2e7 Mon Sep 17 00:00:00 2001 From: Abdul Rashid Date: Wed, 14 Jan 2026 17:45:22 +0530 Subject: [PATCH 3/3] refactor: safe targetOrigin and error handling in postMessage --- images/chromium-headful/client/src/app.vue | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/images/chromium-headful/client/src/app.vue b/images/chromium-headful/client/src/app.vue index 82140671..ebf73ca8 100644 --- a/images/chromium-headful/client/src/app.vue +++ b/images/chromium-headful/client/src/app.vue @@ -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) { @@ -260,15 +271,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) { - try { - if (value) { - this.applyQueryResolution() + if (value) { + this.applyQueryResolution() + try { if (window.parent !== window) { - window.parent.postMessage({ type: 'KERNEL_CONNECTED', connected: true }, '*') + window.parent.postMessage({ type: 'KERNEL_CONNECTED', connected: true }, this.parentOrigin) } + } catch (e) { + console.error('Failed to post message to parent', e) } - } catch (e) { - console.error('Failed to post message to parent', e) } } @@ -344,9 +355,9 @@ if (window.parent === window) return if (value) { - window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, '*') + window.parent.postMessage({ type: 'KERNEL_PLAYING', playing: true }, this.parentOrigin) } else { - window.parent.postMessage({ type: 'KERNEL_PAUSED', playing: false }, '*') + window.parent.postMessage({ type: 'KERNEL_PAUSED', playing: false }, this.parentOrigin) } } catch (e) { console.error('Failed to post message to parent', e)