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

Re-factor the default preferences generation to support build targets (PR 10548) #13117

Merged
merged 4 commits into from
Mar 20, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Mar 18, 2021

Originally the default preferences where simply placed in a JSON-file, checked into the repository, which over time became impractical, annoying, and error-prone to maintain; please see PR #10548.
While that improved the overall situation a fair bit, it however inherited one quite unfortunate property of the old JSON-based solution[1]: It's still not possible for different build targets to specify their own default preference values.

With some preferences, such as e.g. enableScripting, it's not inconceivable that you'd want to (at least) support build-specific default preference values. Currently that's not really possible, which is why this PR re-factors the default preferences generation to support this.

Much smaller/simpler diff with https://github.com/mozilla/pdf.js/pull/13117/files?w=1


[1] This fact isn't really clear from the AppOptions implementation, unless you're familiar with the gulpfile.js code, which could lead to some confusion for those new to this part of the code-base.

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/e36e2b95d6fa819/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/421440927affbaa/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/e36e2b95d6fa819/output.txt

Total script time: 3.53 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://3.101.106.178:8877/421440927affbaa/output.txt

Total script time: 5.79 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/a13b19cee79a272/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/a13b19cee79a272/output.txt

Total script time: 4.06 mins

Published

@Snuffleupagus Snuffleupagus force-pushed the defaultPreferences-builds branch 2 times, most recently from 3836b49 to df39def Compare March 20, 2021 09:44
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/c949aca1f82e1bb/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/7ab91f4dce459b5/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/c949aca1f82e1bb/output.txt

Total script time: 1.75 mins

  • Unit Tests: FAILED

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://3.101.106.178:8877/7ab91f4dce459b5/output.txt

Total script time: 3.75 mins

  • Unit Tests: FAILED

… (PR 10548)

Originally the default preferences where simply placed in a JSON-file, checked into the repository, which over time became impractical, annoying, and error-prone to maintain; please see PR 10548.
While that improved the overall situation a fair bit, it however inherited one quite unfortunate property of the old JSON-based solution[1]: It's still not possible for *different* build targets to specify their *own* default preference values.

With some preferences, such as e.g. `enableScripting`, it's not inconceivable that you'd want to (at least) support build-specific default preference values. Currently that's not really possible, which is why this PR re-factors the default preferences generation to support this.

---
[1] This fact isn't really clear from the `AppOptions` implementation, unless you're familiar with the `gulpfile.js` code, which could lead to some confusion for those new to this part of the code-base.
@Snuffleupagus
Copy link
Collaborator Author

/botio unittest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/3c638d7ece432b9/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/2ef1e4b033b25fc/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/3c638d7ece432b9/output.txt

Total script time: 3.69 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://3.101.106.178:8877/2ef1e4b033b25fc/output.txt

Total script time: 5.92 mins

  • Unit Tests: Passed

@Snuffleupagus
Copy link
Collaborator Author

/botio integrationtest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/53257c64e818ec4/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/872432163a88bb8/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/53257c64e818ec4/output.txt

Total script time: 3.09 mins

  • Integration Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://3.101.106.178:8877/872432163a88bb8/output.txt

Total script time: 4.76 mins

  • Integration Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/bd23d8a7a5826aa/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/bd23d8a7a5826aa/output.txt

Total script time: 4.22 mins

Published

…Preferences`, to a helper function

Currently there's a lot of duplication in the `buildLib` and `buildDefaultPreferences` functions, which seem quite unfortunate. Hence this patch extracts the common functionality in a new `buildLibHelper` function instead.
…etry" preference

With the changes made in the previous patch, we can now list "disableTelemetry" in the `AppOptions` only for the `CHROME`-builds and thus remove the special-casing in the `checkChromePreferencesFile` helper function.
…ns`-methods

Given how the compatibility-values are being handled, it's not actually possible to override a *truthy* default-value with a *falsy* compatibility-value.
This is a simple oversight on my part, and with modern ECMAScript features this is very easy to support.
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/39a915fc2925dd7/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/39a915fc2925dd7/output.txt

Total script time: 4.23 mins

Published

@timvandermeij timvandermeij merged commit c6b44d1 into mozilla:master Mar 20, 2021
@timvandermeij
Copy link
Contributor

Looks like a really good idea; thank you for doing this!

@Snuffleupagus Snuffleupagus deleted the defaultPreferences-builds branch March 20, 2021 21:14
@Snuffleupagus
Copy link
Collaborator Author

Looks like a really good idea; thank you for doing this!

As always, thank you for review/landing my patches :-)


This now leaves only the https://github.com/mozilla/pdf.js/blob/master/extensions/chromium/preferences_schema.json file as a slight annoyance, since it still requires manual updates whenever the AppOptions change; although I'm not sure if trying to (somehow) generate that one during building is worth the effort.

Looking at https://chrome.google.com/webstore/detail/pdf-viewer/oemmndcbldboiebfnladdacbdfmadadm/ I'm also starting to wonder if the Chromium extension is still being maintained, since the last update is listed as "13 september 2019" which is now a year and a half ago.

@timvandermeij
Copy link
Contributor

@Rob--W Do you have more information regarding the Chrome extension? It seems to very out of date; is it still maintained?

@Rob--W
Copy link
Member

Rob--W commented Mar 21, 2021

I still support it, but an update is indeed overdue. Due to the age and updates (appearance, experimental JS support), I need to do some testing and perhaps an update of defaults (e.g. enabling dark theme by default) to make sure that users still recognize the UI.

@Snuffleupagus
Copy link
Collaborator Author

Snuffleupagus commented Mar 21, 2021

experimental JS support

Just a FYI: Scripting will be enabled by default for all user starting with Firefox 88; please see https://bugzilla.mozilla.org/show_bug.cgi?id=1699219

e.g. enabling dark theme by default

That should now be easy to change for the Chromium extension, by updating

value: 0,
to something like

value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME") ? 2 : 0,

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