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

Fallback to plain object for globalScope. #8761

Merged
merged 1 commit into from
Aug 8, 2017
Merged

Fallback to plain object for globalScope. #8761

merged 1 commit into from
Aug 8, 2017

Conversation

tbtlr
Copy link
Contributor

@tbtlr tbtlr commented Aug 8, 2017

When loading PDF.js in non-browser,non-node,strict-mode environments (e.g. loading within a jsm module), globalScope is set to undefined. Should fallback to a plain object instead.

@@ -24,7 +24,8 @@ if ((typeof PDFJSDev === 'undefined' ||
var globalScope =
(typeof window !== 'undefined' && window.Math === Math) ? window :
(typeof global !== 'undefined' && global.Math === Math) ? global :
(typeof self !== 'undefined' && self.Math === Math) ? self : this;
(typeof self !== 'undefined' && self.Math === Math) ? self :
(typeof this !== 'undefined' && this.Math === Math) ? {};
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Aug 8, 2017

Choose a reason for hiding this comment

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

This fails linting, see https://travis-ci.org/mozilla/pdf.js/builds/262068404, since this line seems to contain a SyntaxError. I'm assuming that what you actually want here is (typeof this !== 'undefined' && this.Math === Math) ? this : {}; instead :-)

Please note that you can easily run linting locally (using gulp lint) to catch these kind of issues, and please remember to squash the commits when fixing this.

@tbtlr
Copy link
Contributor Author

tbtlr commented Aug 8, 2017

Thats what happens if you use the GitHub web editor to make a change :). Fix follow soon.

@Snuffleupagus
Copy link
Collaborator

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Aug 8, 2017

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/397caa3069863d8/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 8, 2017

From: Bot.io (Windows)


Received

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

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

@pdfjsbot
Copy link

pdfjsbot commented Aug 8, 2017

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/397caa3069863d8/output.txt

Total script time: 16.45 mins

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

@pdfjsbot
Copy link

pdfjsbot commented Aug 8, 2017

From: Bot.io (Windows)


Success

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

Total script time: 28.92 mins

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

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

Thanks for the patch!

@Snuffleupagus Snuffleupagus merged commit 11ea212 into mozilla:master Aug 8, 2017
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Fallback to plain object for globalScope.
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.

3 participants