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

Uses document.currentScript for pdf.worker.js path. #6595

Merged
merged 2 commits into from
Nov 6, 2015

Conversation

yurydelendik
Copy link
Contributor

Addresses #6593 concern by printing a warning in case when workerSrc is not set.

@@ -42,10 +42,8 @@ if (!PDFJS.workerSrc && typeof document !== 'undefined') {
// workerSrc is not set -- using last script url to define default location
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps it would be a good idea to also add a deprecated warning here for PRODUCTION mode, saying that the workerSrc should always be set to avoid issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This script runs on pdf.js inclusion, means user will not have ability to run his scripts before this one. Logic has to be more complicated to provide this warning and rather at worker construction.

@Snuffleupagus
Copy link
Collaborator

You might also want to update the docs, https://github.com/mozilla/pdf.js/blob/master/src/display/api.js#L75-L80, to say that the workerSrc should always be specified to prevent issues.

}
Object.defineProperty(document, 'currentScript', {
get: function () {
var scriptTagContainer = document.body ||
Copy link
Member

Choose a reason for hiding this comment

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

This method is flawed as it might not give a <script> tag (for async scripts). Try the following instead:

var scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];

@yurydelendik
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Nov 6, 2015

From: Bot.io (Linux)


Received

Command cmd_preview from @yurydelendik received. Current queue size: 0

Live output at: http://107.21.233.14:8877/d61f05d5bae62a6/output.txt

@Snuffleupagus
Copy link
Collaborator

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Nov 6, 2015

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/9dfbf45b11a3fcc/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 6, 2015

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/677491ca2b46715/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 6, 2015

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/677491ca2b46715/output.txt

Total script time: 18.81 mins

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

@pdfjsbot
Copy link

pdfjsbot commented Nov 6, 2015

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/9dfbf45b11a3fcc/output.txt

Total script time: 20.50 mins

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

Snuffleupagus added a commit that referenced this pull request Nov 6, 2015
Uses document.currentScript for pdf.worker.js path.
@Snuffleupagus Snuffleupagus merged commit 1e0bd07 into mozilla:master Nov 6, 2015
@Snuffleupagus
Copy link
Collaborator

Thanks for the patch!

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