Coder Social home page Coder Social logo

Comments (2)

l-cornelius-dol avatar l-cornelius-dol commented on August 23, 2024

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.

l-cornelius-dol avatar l-cornelius-dol commented on August 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.