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

Don't detect nw.js as node.js #10228

Merged
merged 1 commit into from
Nov 7, 2018
Merged

Don't detect nw.js as node.js #10228

merged 1 commit into from
Nov 7, 2018

Conversation

morille
Copy link
Contributor

@morille morille commented Nov 6, 2018

nw.js is chrome plus nodejs.
It will succeed everywhere chrome succeeds, but fail in many cases where nodejs succeeds (see issue 9071).
So it's safer to consider it as a browser context rather than a nodejs context.

Fixes #9071.

@morille
Copy link
Contributor Author

morille commented Nov 6, 2018

Here is the nw.js documentation that explains process.versions['nw']
http://docs.nwjs.io/en/latest/References/Changes%20to%20Node/

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this is done, please squash the commits into one; refer to https://github.com/mozilla/pdf.js/wiki/Squashing-Commits for how to do that easily. Thank you!

return typeof process === 'object' && process + '' === '[object process]';
return typeof process === 'object' &&
process + '' === '[object process]' &&
!process.versions['nw'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change it to something like this for readability and explanation of why we exclude NW.js?

// Exclude NW.js since, even though it's based on Node.js,
// it works like a browser.
return typeof process === 'object' &&
       process + '' === '[object process]' &&
       !process.versions['nw'];

@morille
Copy link
Contributor Author

morille commented Nov 7, 2018

Done, thanks for the doc.

return typeof process === 'object' && process + '' === '[object process]';
// NW.js is a browser context, but copies some node objects.
// For more information see the 'Separate Context Mode' doc:
// http://docs.nwjs.io/en/latest/
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Nov 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not link directly to the relevant page instead, to save people from having to search around for the referenced content?
Please just change the entire comment to something like this instead (note that URLs in comments are exempt from the general line-length limit):

// NW.js is a browser context, but copies some Node.js objects; see
// http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#separate-context-mode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NW.js doc evolves so I prefered to not give a link that could be broken later, then harder to resolve than domain name + section name.

nw.js is chrome plus nodejs.
It will succeed everywhere chrome succeeds, but fail in many cases where nodejs succeeds (see issue 9071).
So it's safer to consider it as a browser context rather than a nodejs context.

Make travis happy again

CS

Readability + Explanation

The relevant portion of the NW.js documentation:
http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context

Added full link to relevant doc.
@morille
Copy link
Contributor Author

morille commented Nov 7, 2018

Done and squashed.

@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Nov 7, 2018

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/2e3f2b12ead2771/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 7, 2018

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/8cddad450a190a6/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 7, 2018

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/2e3f2b12ead2771/output.txt

Total script time: 19.13 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Nov 7, 2018

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/8cddad450a190a6/output.txt

Total script time: 24.77 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@timvandermeij timvandermeij merged commit 3e34255 into mozilla:master Nov 7, 2018
@timvandermeij
Copy link
Contributor

Let's do this. Thank you!

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

Successfully merging this pull request may close these issues.

4 participants