question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug (regression) : new-win-policy event not always thrown on popup opening in iframe

See original GitHub issue

Hi Roger, I’m using the iframe object for embedding a web site. It’s working pretty very well (thank you) but depending on how a popup is openin this web site, I can or can’t get (and catch) the new-win-policy event (This has been tested with version 0.11.3. Windows 32 bits).

What is working:

  • If you click on one link with key shift pressed.

What is not working:

  • You click on a link that is supposed to open a popup.

For instance, the code below works well if you open it from a local file but doesn’t it you use the web site it has been picked of. I don’t really understand why because if you consider the html tag anf the javascript code, the popup is open with a standard window.open call.

To reproduce the issue:

This is the hosted nw iframe I’m using (see url inside):

      <iframe name="myIframe" id="myIframe" src="http://www.airfrance.fr/FR/en/local/home/home/HomePageAction.do" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto" onLoad="isLoaded();" allowtransparency="false" nwdisable nwfaketop></iframe>

Obviously, I’m catching the new-win-policy on the window containing this frame.

I’ve put the screenshot with the image link you have to click on to open a new window.

And here is the extract of the link on the remote page and the associated javascript code :

<a class="cutout_lien" href="https://shopping.airfrance.com/boutique/fr/E-SHOPPING-GRAND-PUBLIC3/index.htm" onclick="javascript:af_open(this);return false;" rel="1[,]"><h2 class="cutout_titre">Nos coups de cœur<br>Air France Shopping</h2><img alt="Air France Shopping" src="http://www.airfrance.fr/common/image/visuels_detoures/shopping.png" height="115" width="230"></a>

function af_open(elem){
 var t = elem.title || elem.name || '';
 var a = elem.href || elem.alt;
 var p = elem.rel || false;
 var m = "0";
 var l = 800;
 var h = 600;
 if(a==document.location.href){return false;}
 if(p){
    //on recupere la largeur et la hauteur
    var r = p.match(/^\s?([0-2])\s?\[\s?([0-9]*)\s?,\s?([0-9]*)\s?\]/g);
    m = RegExp.$1.toString();
    l = RegExp.$2.toString();
    h = RegExp.$3.toString();
 }
 if(m.match(/2/)){
        if(l.length==0 && h.length==0) {
            GB_showResize(t,a);//Fonction GreyBox (popin auto resize)
        } else {
            GB_showCenter(t,a,l,h);//Fonction GreyBox (popin taille fixe)
        }
 } else if(m.match(/1/)){
            window.open(a,t);
 } else {
            document.location = a;
 }
 return false;
}

screenshot_af

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
bsparkscommented, Nov 14, 2017

I believe that this is happening when loading a chrome app. The chrome packaged apps do not seem to have a node context. Any idea on a fix or suggested work around?

1reaction
armoretcommented, Jan 5, 2015

Hello to all, I confirm it’s really a regression. I have tested the same code (see extract below) with an older version (0.9.2 win32) on the same web site and it was working well (in other words, the function was well called when opening a popup window clicking on one link).

I hope you will be able to fix it !

Thanks.

         // ------------------------  
        // Listen to the open event
        // ------------------------
        win.on('new-win-policy', function(frame, url, policy) {
            console.log('new-win-policy event on ' + frame);

            // To ignore:
            policy.ignore();

            // Open new child window, url is passed in a global variable
            console.log('Opening url in new window:' + url);
            global.url = url;
            var new_win = gui.Window.open('browser.html', {
                "show": true,
                "toolbar": false,
                "icon": "icon.png",
                "frame": true,
                "focus": true,
                "position": "center",
                "width": 1024,
                "height": 768,
                "min_width": 640,
                "min_height": 480
            });
        });

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text selection bug in Mobile Safari with iframes and ontouchstart
When using an iframe/object/embed HTML-tag for displaying HTML content in combination with javascript touch event bindings (touchstart/touchend etc.
Read more >
1536385 - Popup opened from sandboxed iframe that allows ...
My expectation is that the script executes, because the popup (created with target=_blank) is not sandboxed (due to sandbox="allow-popups allow-popups-to-escape ...
Read more >
32333 - onload event of an iframe fails to trigger when a form ...
But, there happens to be a new bug found. It wasn't the onload event causing the issues, it was the fact that the...
Read more >
A Deep Dive into Debugging Cypress, iframes, & Runtime ...
As software engineers, a large portion of our time is spent researching, reproducing, and fixing bugs. Being able to effectively discover, ...
Read more >
CHANGELOG.md · nw52 · mirrors / rogerwang / node-webkit
Call all Node.js modules directly from DOM/WebWorker and enable a new ... Update Chromium to 65.0.3325.181; Fix: new-win-policy not working ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found