edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* proposed postMessage rev
@ 2021-12-23  3:37 Kevin Carhart
  2022-01-02 18:28 ` Adam Thompson
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Carhart @ 2021-12-23  3:37 UTC (permalink / raw)
  To: edbrowse-dev

I think we chewed on a couple of changes to postMessage but they aren't in yet.  What do you think of the following?

The differences are
(1) we are supposed to consider port (as in, networks, 80, 443, not talking about MessageChannel stuff here) when passing or failing the origin test
(2) setting me.origin = my$win().location;
(3) Adding an else case to the origin test so that if the postMessage can't run, we can be alerted that it didn't

-------------



function  postMessage(message,target_origin, transfer) {
var locstring = this.location.protocol + "//" + this.location.hostname + ":" + this.location.port;
if (target_origin == locstring || target_origin == "*") {
var me = new Event;
me.name = "message";
me.type = "message";
me.origin = my$win().location;
me.data = message;
me.source = my$win();
if(transfer) {
me.ports = transfer;
// If these objects had a context, they are now owned by this context.
for(var i = 0; i < transfer.length; ++i)
if(transfer[i].eb$ctx) transfer[i].eb$ctx = eb$ctx;
}
this.onmessage$$queue.push(me);
alert3("posting message of length " + message.length + " to window context " + this.eb$ctx + " ?" +
(message.length >= 200 ? "long" : message)
+ "?");
} else {
// handle a failure here
alert3("postMessage failure: the message " + message + " could not be posted to " + this.eb$ctx + " due to the same-origin rule");
}
}


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

end of thread, other threads:[~2022-01-02 18:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-23  3:37 proposed postMessage rev Kevin Carhart
2022-01-02 18:28 ` Adam Thompson

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).