Skip to content

Moves DEFAULT_PREFENCES into JSON format. #7317

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

Merged
merged 1 commit into from
May 11, 2016

Conversation

yurydelendik
Copy link
Contributor

Makes it easier to address #7192 , e.g. PDFJSDev.json('file.json') will be inlining loaded object.

this._readFromStorage(DEFAULT_PREFERENCES).then(function(prefObj) {
return this.initializedPromise = defaultPreferences.then(
function (defaults) {
this.defaults = defaults;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the defaults are now exposed on Preferences, can we use Object.freeze(defaults) here to prevent outside tampering with the default values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can do that

@yurydelendik
Copy link
Contributor Author

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/cfa637fe8eff645/output.txt

@@ -82,8 +102,8 @@ var Preferences = {
*/
reset: function preferencesReset() {
return this.initializedPromise.then(function() {
this.prefs = Object.create(DEFAULT_PREFERENCES);
return this._writeToStorage(DEFAULT_PREFERENCES);
this.prefs = Object.create(this.defaults);
Copy link
Collaborator

@Snuffleupagus Snuffleupagus May 11, 2016

Choose a reason for hiding this comment

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

It seems that my previous comment causes issues here, since after a reset, attempting to set a new value fails.
I still think that it makes a certain amount of sense to freeze the defaults, so could we instead change this line to this.prefs = Object.assign({}, this.defaults);, to fix this issue?

@Snuffleupagus
Copy link
Collaborator

r=me, with the comment addressed.

@yurydelendik
Copy link
Contributor Author

Object.assign is not present in IE -- I'll just add object cloning function for that.

@yurydelendik yurydelendik merged commit b261203 into mozilla:master May 11, 2016
@yurydelendik yurydelendik deleted the move-defaultprefs branch May 11, 2016 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants