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

consider exposing a type attribute on Client #1005

Closed
wanderview opened this issue Nov 16, 2016 · 7 comments
Closed

consider exposing a type attribute on Client #1005

wanderview opened this issue Nov 16, 2016 · 7 comments

Comments

@wanderview
Copy link
Member

Currently Clients.matchAll() considers three different types of Client objects:

  1. Window
  2. DedicatedWorker
  3. SharedWorker

Currently its only possible to differentiate the Window client using instanceof WindowClient. Since the algorithm operates on the type, though, it would be nice to expose it for dedicated and shared workers as well.

So, something like:

interface Client
{
  readonly attribute DOMString type;
}

The value would match those used in Clients.matchAll().

As a side note, I find it annoying that "worker" is mapped to DedicatedWorker. I think it would have been nicer to use "dedicatedworker" and make "worker" map to all Worker types.

@annevk
Copy link
Member

annevk commented Nov 17, 2016

Why? Constructors are Worker and SharedWorker.

@wanderview
Copy link
Member Author

Why? Constructors are Worker and SharedWorker.

I guess I was thinking of how [Exposed] works in webidl.

Anyway, the naming of the type is a side issue to the main idea here.

@jungkees
Copy link
Collaborator

jungkees commented Nov 18, 2016

I think it's a good idea to expose type to Client interface. Returned clients can be one of "window", "worker", and "sharedworker" indeed. For the type of the attribute, we can use the enum, ClientType preventing the getter from returning "all". Would it make sense?

partial interface Client
{
  readonly attribute ClientType type;
}

For naming, I give my five cents to keeping consistency to the existing names.

@wanderview
Copy link
Member Author

Works for me. I'd like to hear from someone at google if they think its something they would implement, though.

@mkruisselbrink
Copy link
Collaborator

Not sure if I speak for Google, but it does sound like a sensible addition.

@jungkees
Copy link
Collaborator

I labeled it V1 as it'd be a simple addition that won't break the time line itself. But if anyone would argue we should add it only to the Nightly, I'd be fine with that.

jungkees added a commit that referenced this issue Dec 2, 2016
This adds a type attribute to Client interface. Before this, we could
only differentiate the WindowClient objects from Client objects. With
the type attribute, a client can be identified as one of window,
dedicated worker, and shared worker.

Fixes #1005.
@makotoshimazu
Copy link

FYI: Chromium has started to implement this at https://crrev.com/2845963002 .

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

No branches or pull requests

5 participants