edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: "Kevin Carhart" <kevin_carhart@fastmail.fm>
To: edbrowse-dev@edbrowse.org
Subject: proposed postMessage rev
Date: Wed, 22 Dec 2021 19:37:53 -0800	[thread overview]
Message-ID: <a449f94a-5a49-49ad-804c-d0c8ab82dd1e@www.fastmail.com> (raw)

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");
}
}


             reply	other threads:[~2021-12-23  3:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23  3:37 Kevin Carhart [this message]
2022-01-02 18:28 ` Adam Thompson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a449f94a-5a49-49ad-804c-d0c8ab82dd1e@www.fastmail.com \
    --to=kevin_carhart@fastmail.fm \
    --cc=edbrowse-dev@edbrowse.org \
    --subject='Re: proposed postMessage rev' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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