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

Is there any reason why navigator.epubReadingSystem is writable? #452

Open
JayPanoz opened this issue Aug 25, 2018 · 2 comments
Open

Is there any reason why navigator.epubReadingSystem is writable? #452

JayPanoz opened this issue Aug 25, 2018 · 2 comments

Comments

@JayPanoz
Copy link

This issue is a Question

I just checked the cloud reader and it looks like epubReadingSystem can be entirely changed while it should be read-only, according to the EPUB3 spec.

Related issue(s) and/or pull request(s)

See also #41 I guess, as that may well be one significant reason why.

Expected Behaviour

epubReadingSystem and its properties can’t be modified or removed, properties can’t be added.

Observed behaviour

Instead, the cloud reader lets you do pretty much anything with it.

capture d ecran 2018-08-25 a 14 25 29

Steps to reproduce

  1. check iframe’s navigator.epubReadingSystem
  2. redefine prop e.g. navigator.epubReadingSystem.name = ""
  3. check iframe’s navigator.epubReadingSystem, name is now empty
  4. redefine object e.g. navigator.epubReadingSystem = {}
  5. check iframe’s navigator.epubReadingSystem, it is now {}

To my knowledge, and it’s been tested with another implem, redefining should fail silently (in non-strict mode, and throw a TypeError in strict mode) and checking should return the object and properties unmodified.

Product

  • Readium cloud reader app
    • latest development build uploaded at https://readium.firebaseapp.com OR a custom integration (list public deployment URL, if any)
    • All browsers
    • All platforms

That may well apply to other products, I stopped at the cloud reader.

Additional information

The following is reported to work but issue #41 may beg to differ:

  1. Object.freeze() the epubReadingSystemObject
  2. Object.defineProperty(navigator, "epubReadingSystem", {value: epubReadingSystemObject, writable: false})

Freeze should make the properties unwritable while defineProperty should make the object itself unwritable. That’s ES5 BTW.

But then, there could be other reasons, I just couldn’t find them with a quick search in issues.

@JayPanoz
Copy link
Author

Hmmmm after taking a deeper look at the commit reference in the issue, because the JSON serialization maybe?

@danielweck
Copy link
Member

You are correct, the object should be immutable.

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

No branches or pull requests

2 participants