nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.36k stars 3.89k forks source link

Window 'loaded' Event Fires Multiples Times in PDF Window #5052

Open rdtsc opened 8 years ago

rdtsc commented 8 years ago

Summary

When spawning a new window via nw.Window.open and where the target is a PDF file, the Window.loaded event is fired multiple times for the newly created window.

Versions

{
  "name": "nw.js",
  "main": "index.html"
}
index.html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Window Event Test</title>
    <script>
    function spawnWindow(path) {
      nw.Window.open(path, {}, function(win) {
        win.on('loaded', function() {
          console.log(path + ' - loaded');
        });

        win.on('closed', function() {
          console.log(path + ' - closed');
        });
      });
    }
    </script>
  </head>
  <body>
    <button onclick="spawnWindow('https://google.com')">Open HTML</button>
    <button onclick="spawnWindow('https://stlab.adobe.com/wiki/images/d/d3/Test.pdf')">Open PDF</button>
  </body>
</html>
Actions

Notes

Reproducible with the same results on remote and local PDF targets. That is, on both:

Christywl commented 7 years ago

I can reproduce this issue with the above codes on Linux/Windows with nwjs-sdk-v0.21.3.