zloirock / core-js

Standard Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

$.task.js - global.postMessage conflicting with external scripts

kigorw opened this issue · comments

We use Babel Promises in Chrome extension. Some sites listens this messages and some of them expect certain data types in e.data and use something like e.data.split() so when e.data is int user gets JavaScript error.
I would be cool to replace this mechanism with something more isolated.

You can propose more safe and enough fast task implementation? Maximum that I can do - set location.origin as origin parameter and convert data to string. In the future Promise implementation will use microtasks based on MutationObserver, but tasks based on postMessage should be used in some other places.

Possible use MessageChannel (currently used only for WebWorkers), but it can cause some problems, need test it.