Comments (2)
Making progress on this... it seems Firefox temporarily places an about:blank
URL, which has the origin of the containing page, causing the attempt to ping the other window to fail if it happens too quickly, which it usually does. Unfortunately, there seems to be no reliable way to test which "window" is current in the frame. Might have to resort to try/catch silliness.
from jschannel.
OK, so the problem was indeed the intermediate iframe in Firefox (did not test on other browsers). What I had to do was a little ugly:
setTimeout(function buildChannel() { // frame (ifrwin) for channel not immediately available
let chlscp="...my scope...";
let chlorg=tskurl.match(/^[A-Za-z]{1,10}:\/\//) // cope with either absolute or relative URL
? tskurl.split("/").slice(0,3).join("/") // reduce absolute URL to protocol://domain:port
: window.location.origin; // just use this window's domain for relative
let ifrwin=ifrelm.contentWindow;
try { // will throw when real external URL becomes active, due to `""+ifrwin.location`
if(!ifrwin || !ifrwin.location || ""+ifrwin.location=="about:blank") { // about:blank needed for Firefox or will throw on bad origin
setTimeout(buildChannel,20); // frame not loaded, try again in a little bit
return;
}
}
console.log("Task collaboration channel is pending (scope="+chlscp+", origin="+chlorg+")");
obj.channel=Channel.build({
window : ifrwin,
...
Will close this, but it would be useful for the library to cope with this situation.
from jschannel.
Related Issues (20)
- jshannel origin is case-sensitive (while window.postMessage origin is not) HOT 3
- recursive data structure in params HOT 1
- HEAD is broken on IE8 HOT 5
- JSON.stringify and Prototype
- Array#indexOf breaks IE8 and below
- Can't connect to PDF.js pages
- Enhancement: should print out stacktrace of caught exceptions in debug mode.
- ready message has a race condition
- Add JSChannel to npm HOT 5
- Add support to Object tag
- IE11 raise a security error when using js-channel on different domain
- Support multiple origins
- publish to npm/bower ?
- CODE_OF_CONDUCT.md file missing
- make it smaller?
- Add a LICENSE file
- Timeout HOT 1
- Channel setup fails silently
- if scope is omitted, silent failures ensue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jschannel.