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

Initial cut at the script module #70

Merged
merged 8 commits into from Jan 14, 2021
Merged

Initial cut at the script module #70

merged 8 commits into from Jan 14, 2021

Conversation

jgraham
Copy link
Member

@jgraham jgraham commented Nov 9, 2020

This adds a method to get a list of existing realms and an event when
a new realm is created. It is anticipated that the module will also be
used for further script-related commands such as script execution in
the future.

Realms are given an id and a type parameter according to the kind of
global they contain. The set of paramters is extensible to allow for
the possibility of further kinds in the future, but the anticipation
is they will be added to the specification, so it's a requirement that
unknown kinds are prefixed.

The getRealms method allows filtering by context to only get realms
related to the active document in that context (i.e. workers with that
document in the owner set or the window script for that
document). There isn't currently a way to get only nested workers or
similar; it's not really clear how useful this is.


Preview | Diff

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated
[=responsible document=]'s [=Document/browsing context=] to |related contexts|.

Otherwise if the [=Realm/global object=] specified by |settings| is a
{{WorkerGlobalScope}}, for each |owner| in the [=Realm/global object=]'s [=owner
Copy link
Member

Choose a reason for hiding this comment

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

OK, so the "for each" here is how we can end up with multiple members in related contexts, which can happen for shared workers.

However, a shared worker is only created once right, and some browsing context has to be the one that brought it about. Can there in fact be multiple owners at the time a realm is created?

In the case that a browsing context later joins the party with a shared worker, is an event needed to signal that, or do we pretent it was created again?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we could at least have multiple contexts associated with a worker if we are emitting events because we subscribed to the script.realmCreated event for some existing contexts and we're backfilling. The spec doesn't cover that yet but I think it will.

I don't know what CDP does with shared workers; could be interesting to investigate.

Copy link
Member

Choose a reason for hiding this comment

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

OK so let's not block this PR on investigating that, seems like a fine thing to look at while prototyping an implementation.

@jgraham jgraham force-pushed the script branch 2 times, most recently from ce41f66 to ad99209 Compare December 11, 2020 16:54
Base automatically changed from contexts to master December 11, 2020 17:06
jgraham and others added 4 commits December 17, 2020 14:02
This adds a method to get a list of existing realms and an event when
a new realm is created. It is anticipated that the module will also be
used for further script-related commands such as script execution in
the future.

Realms are given an id and a type parameter according to the kind of
global they contain. The set of paramters is extensible to allow for
the possibility of further kinds in the future, but the anticipation
is they will be added to the specification, so it's a requirement that
unknown kinds are prefixed.

The getRealms method allows filtering by context to only get realms
related to the active document in that context (i.e. workers with that
document in the owner set or the window script for that
document). There isn't currently a way to get only nested workers or
similar; it's not really clear how useful this is.
Co-authored-by: Brandon Walderman <bwalderman@outlook.com>
Co-authored-by: Philip Jägenstedt <philip@foolip.org>
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
Co-authored-by: Philip Jägenstedt <philip@foolip.org>
Copy link
Member

@foolip foolip left a comment

Choose a reason for hiding this comment

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

Still approved.

@jgraham jgraham requested a review from foolip January 14, 2021 13:44
@jgraham jgraham merged commit ba481c9 into master Jan 14, 2021
@jgraham jgraham deleted the script branch January 14, 2021 13:46
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

Successfully merging this pull request may close these issues.

None yet

3 participants