edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [edbrowse-dev] [PATCH] postMessage
@ 2020-09-17 23:42 Kevin Carhart
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Carhart @ 2020-09-17 23:42 UTC (permalink / raw)
  To: Edbrowse-dev; +Cc: kevin

[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]

From 47af154701fc0f143f3bd924cb308f65be284aba Mon Sep 17 00:00:00 2001
From: Kevin Carhart <kevin@carhart.net>
Date: Thu, 17 Sep 2020 05:16:01 -0700
Subject: [PATCH] implement window.postMessage

---
 src/startwindow.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/startwindow.js b/src/startwindow.js
index 196e626..5d27536 100644
--- a/src/startwindow.js
+++ b/src/startwindow.js
@@ -1136,6 +1136,25 @@ if(this.height === 0 || this.width === 0) return "data:,";
 return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAADElEQVQImWNgoBMAAABpAAFEI8ARAAAAAElFTkSuQmCC";
 }
 
+mw0.postMessage = function (message,target_origin)
+{
+if (this.location.protocol + "//" + this.location.hostname == target_origin || target_origin == "*")
+{
+if (typeof this.onmessage == "function")
+{
+// whose responsibility is it to add the event handler?   The web developer's?
+// Because we (the browser implementers) don't have any way of knowing what in particular
+// they want the handler to actually do with the message.  Right?
+var me = new Event;
+me.name = "message";
+me.type = "message";
+me.data = message
+this.onmessage(me);
+}
+}
+}
+
+
 /*********************************************************************
 AudioContext, for playing music etc.
 This one we could implement, but I'm not sure if we should.
@@ -3626,6 +3645,7 @@ Timer = mw0.Timer;
 Audio = mw0.Audio;
 Canvas = mw0.Canvas;
 AudioContext = mw0.AudioContext;
+postMessage = mw0.postMessage;
 Document = mw0.Document;
 CSSStyleSheet = mw0.CSSStyleSheet;
 CSSStyleDeclaration = mw0.CSSStyleDeclaration;
-- 
1.8.3.2



^ permalink raw reply	[flat|nested] 2+ messages in thread
* [edbrowse-dev] [PATCH] postMessage
@ 2020-09-17 12:25 Kevin Carhart
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Carhart @ 2020-09-17 12:25 UTC (permalink / raw)
  To: Edbrowse-dev; +Cc: kevin

[-- Attachment #1: Type: text/plain, Size: 1706 bytes --]

From 47af154701fc0f143f3bd924cb308f65be284aba Mon Sep 17 00:00:00 2001
From: Kevin Carhart <kevin@carhart.net>
Date: Thu, 17 Sep 2020 05:16:01 -0700
Subject: [PATCH] implement window.postMessage

---
 src/startwindow.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/startwindow.js b/src/startwindow.js
index 196e626..5d27536 100644
--- a/src/startwindow.js
+++ b/src/startwindow.js
@@ -1136,6 +1136,25 @@ if(this.height === 0 || this.width === 0) return "data:,";
 return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAADElEQVQImWNgoBMAAABpAAFEI8ARAAAAAElFTkSuQmCC";
 }
 
+mw0.postMessage = function (message,target_origin)
+{
+if (this.location.protocol + "//" + this.location.hostname == target_origin || target_origin == "*")
+{
+if (this.onmessage || this.onmessage$$array)
+{
+// whose responsibility is it to add the event handler?   The web developer's?
+// Because we (the browser implementers) don't have any way of knowing what in particular
+// they want the handler to actually do with the message.  Right?
+var me = new Event;
+me.name = "message";
+me.type = "message";
+me.data = message
+this.onmessage(me);
+}
+}
+}
+
+
 /*********************************************************************
 AudioContext, for playing music etc.
 This one we could implement, but I'm not sure if we should.
@@ -3626,6 +3645,7 @@ Timer = mw0.Timer;
 Audio = mw0.Audio;
 Canvas = mw0.Canvas;
 AudioContext = mw0.AudioContext;
+window.postMessage = postMessage = mw0.postMessage;
 Document = mw0.Document;
 CSSStyleSheet = mw0.CSSStyleSheet;
 CSSStyleDeclaration = mw0.CSSStyleDeclaration;
-- 
1.8.3.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-17 23:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 23:42 [edbrowse-dev] [PATCH] postMessage Kevin Carhart
  -- strict thread matches above, loose matches on Subject: below --
2020-09-17 12:25 Kevin Carhart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).