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

Investigate if console in partial interfaces should be mutable #1

Closed
terinjokes opened this issue Sep 24, 2014 · 9 comments
Closed

Comments

@terinjokes
Copy link
Collaborator

Right now we're defining the console exposed to Window and WorkerGlobalScope as a type of Console. In today's browsers, you'll be able to assign anything you want to the console variable.

This issue should determine if we want or should disallow this, and what changes need to be made to the IDL and supporting text.

@domenic
Copy link
Member

domenic commented Jan 10, 2016

This basically needs implementer feedback I guess. We have two options IMO:

  • Be sensible, and make it readonly.
  • Go with existing behavior, and make its type any.

In both cases, the spec is currently missing definitions for the console getter/setter on window/workerglobalscope. So we should add one of those.

@domenic
Copy link
Member

domenic commented Feb 8, 2016

I'm going to try to ask the mailing list to get implementer feedback on this one.

@robertkowalski
Copy link
Member

cool, which mailing list exactly? would like to join the party :)

@domenic
Copy link
Member

domenic commented Feb 8, 2016

@domenic
Copy link
Member

domenic commented Feb 8, 2016

Some browser testing results:

  • All browsers let you get and set window.console with the returned value given back verbatim
  • Firefox has an accessor descriptor (get/set), Chrome, Safari, and Edge have a data descriptor (value)
  • Firefox, Chrome, and Edge are enumerable; Safari is not enumerable

@domenic
Copy link
Member

domenic commented Feb 8, 2016

@domenic
Copy link
Member

domenic commented Feb 9, 2016

In the thread we came to two important conclusions:

  1. This is blocked on figuring out Static console functions / binding #3. If we go that route, as in Static console functions / binding #3 (comment) specifically, it will change all the mechanisms involved.
  2. If we don't go that route, the easiest way to spec this is [Replaceable] readonly attribute Console console;, which does allow the replacement by automatically defining a setter that overrides the property.

I think we should work toward figuring out #3 as soon as possible.

@foolip
Copy link
Member

foolip commented Mar 7, 2016

I rediscovered today that the spec is missing [Replaceable] in the IDL, and found this issue.

The [Replaceable] IDL attribute was introduced in WebKit specifically for console: https://trac.webkit.org/changeset/27161

More recently WebKit moved this into JavaScriptCore and thus no longer defines it using IDL: https://trac.webkit.org/changeset/165199

Blink and Gecko do use [Replaceable], and as noted all browsers behave as if they do, allowing window.console to be assigned to any value.

I don't see why this should be blocked on #3, why not just add [Replaceable] and make sure that behavior is preserved in any future refactoring?

@domenic
Copy link
Member

domenic commented Mar 7, 2016

Yes, given that #3 is not progressing as fast as I hoped, it seems like we should indeed just add [Replaceable] asap. Pull request? :)

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

No branches or pull requests

4 participants