Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capturePage does not work if nw.Window.get is called for iframe window #5043

Closed
vsemozhetbyt opened this issue Jun 28, 2016 · 3 comments
Closed
Assignees

Comments

@vsemozhetbyt
Copy link
Contributor

NW.JS 0.15.4 on Windows 7.

package.json

{
  "name": "nw-test",
  "main": "index.html"
}

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset='UTF-8'>
    <title>NW Test</title>
    <script>
      const nwWin = nw.Window.get();
      const nwDoc = nwWin.window.document;

      nwWin.on('loaded', () => {
        nwWin.showDevTools();

        const nwBrowser = nwDoc.querySelector('#browser');

        nwWin.capturePage(imgBuffer => {
          console.log(imgBuffer);
        }, {format: 'png', datatype: 'buffer'});
      });
    </script>
  </head>
  <body>
    <iframe id='browser'></iframe>
  </body>
</html>

This code works properly, console output is Uint8Array[1511]. However if I just add this one line with nw.Window.get called for iframe window, there is no console ouput, no callback execution. capturePage fails silently without any error message.

<!DOCTYPE html>
<html>
  <head>
    <meta charset='UTF-8'>
    <title>NW Test</title>
    <script>
      const nwWin = nw.Window.get();
      const nwDoc = nwWin.window.document;

      nwWin.on('loaded', () => {
        nwWin.showDevTools();

        const nwBrowser = nwDoc.querySelector('#browser');
        const iWin = nw.Window.get(nwBrowser.contentWindow);

        nwWin.capturePage(imgBuffer => {
          console.log(imgBuffer);
        }, {format: 'png', datatype: 'buffer'});
      });
    </script>
  </head>
  <body>
    <iframe id='browser'></iframe>
  </body>
</html>
@vsemozhetbyt
Copy link
Contributor Author

May be this is the cause: #5044

@xzhan96 xzhan96 self-assigned this Mar 15, 2017
xzhan96 added a commit to xzhan96/nw.js that referenced this issue Mar 21, 2017
iframe's window should not have independent Window object

fixed nwjs#5043, nwjs#5044, nwjs#5755
rogerwang pushed a commit that referenced this issue Mar 22, 2017
iframe's window should not have independent Window object

fixed #5043, #5044, #5755
@xzhan96
Copy link
Contributor

xzhan96 commented Mar 22, 2017

@Christywl could you also do a test with the patch?

@Christywl
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants