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

Extend environment concept #2004

Merged
merged 6 commits into from
Nov 9, 2016
Merged

Conversation

jungkees
Copy link
Contributor

@jungkees jungkees commented Nov 2, 2016

  • Add execution ready flag, which is set when the corresponding
    environment settings object is created and the potential main resource
    is fetched (in the case of an initial browsing context creation, the
    main resource fetch doesn't occur and not considered as a condition.)
    . This flag is mainly used in Service Worker's Client API (i.e. to
    get a value for client.reserved)
    - Define the origin algorithm that returns the creation URL's origin
    . The origin algorithms defined in the environment settings objects
    override the behavior.
    . The primary purpose of defining this algorithm is to allow a
    polymorphic dispatch depending on the type of objects (i.e. to
    simplify the steps in the call sites.)

Related issue: #1992

- Add execution ready flag, which is set when the corresponding
environment settings object is created and the potential main resource
is fetched (in the case of an initial browsing context creation, the
main resource fetch doesn't occur and not considered as a condition.)
 . This flag is mainly used in Service Worker's Client API (i.e. to
 get a value for client.reserved)
- Define the origin algorithm that returns the creation URL's origin
 . The origin algorithms defined in the environment settings objects
 override the behavior.
 . The primary purpose of defining this algorithm is to allow a
 polymorphic dispatch depending on the type of objects (i.e. to
 simplify the steps in the call sites.)

Related issue: whatwg#1992
@zcorpan
Copy link
Member

zcorpan commented Nov 2, 2016

Error: Multiple definitions for term "origin" Parent of first says: "An origin is one of the following:", parent of second says: "An environment has an algorithm defined as the origin that returns the environment's creation URL's origin."

Unfortunately wattsi doesn't know about the data-dfn-for attributes AFAIK. Can use data-x="concept-environment-origin" or so (in addition).

@@ -85800,6 +85806,14 @@ interface <dfn>NavigatorOnLine</dfn> {
data-x="dfn-control">controls</span> the <span>environment</span>.</p></dd>
</dl>

<p>An <span>environment</span> has an <dfn data-x="concept-environment-execution-ready-flag"
data-export="">execution ready flag</dfn>, which is initially unset.</p>
Copy link
Member

Choose a reason for hiding this comment

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

This should also have a data-dfn-for="environment".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah.. just missed this comment before pushing the data-x commit. Will add this.

@jungkees
Copy link
Contributor Author

jungkees commented Nov 3, 2016

Added client.reserved, which references the execution ready flag, in a SW's topic branch:
w3c/ServiceWorker@d88e979 Would like to merge to master when this PR is landed.

@jungkees
Copy link
Contributor Author

jungkees commented Nov 3, 2016

On reflection, for the origin, I think I can also do it in SW by defining an origin field on the service worker client. Not sure if other specs (e.g. Secure Context) will need a reference to the environment's origin in the future, though. If that's the case, having it in the environment will still be useful.

This removes the environment's origin algorithm definition. The
requirement is now covered by Service Workers spec with the service
worker client's origin algorithm: https://w3c.github.io/ServiceWorker/#service-worker-client-origin
@jungkees
Copy link
Contributor Author

jungkees commented Nov 4, 2016

I removed the environment's origin definition from this PR and spec the algorithm in SW instead: https://w3c.github.io/ServiceWorker/#service-worker-client-origin

So, this PR is now only for adding the execution ready flag.

If we need an origin algorithm on environment in the future, I'll make a separate PR for that.

@@ -85800,6 +85806,10 @@ interface <dfn>NavigatorOnLine</dfn> {
data-x="dfn-control">controls</span> the <span>environment</span>.</p></dd>
</dl>

<p>An <span>environment</span> has an <dfn data-x="concept-environment-execution-ready-flag"
Copy link
Member

Choose a reason for hiding this comment

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

This should be added to the previous <dl>, I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering whether I should get both the fields and the flag in the same <dl> considering we put it as "An environment has the following fields". So, I guess a flag is a field? I'm fine with adding it to the <dl> if so.

Copy link
Member

Choose a reason for hiding this comment

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

A field can be a flag, yeah :). Flag is a type, kind of like a boolean but just a bit more awkward to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. Addressed the comment.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

LGTM with nit but would appreciate @annevk's review as well.

<li><p><span>Set up a browsing context environment settings object</span> with
<var>realm execution context</var>.</p></li>
<li><p><span>Set up a browsing context environment settings object</span> with <var>realm
execution context</var>, and set <var>settingsObject</var> to the result.</p></li>
Copy link
Member

Choose a reason for hiding this comment

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

let settingsObject be the result; this is the first introduction of the settingsObject variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the comment. Thanks.

@annevk
Copy link
Member

annevk commented Nov 8, 2016

My main concern is that I don't have the full flow in my head. And we're adding this state for lifetime management of a global, but we don't fully understand the lifetime of globals yet.

@jungkees
Copy link
Contributor Author

jungkees commented Nov 8, 2016

Trying to clarify, client.reserved is the only attribute which uses this field. The purpose of .reserved is to distinguish the state before and after the moment when the UA's to be able to parse a fetched (or given default) document or execute a worker script. This hasn't been needed as we've never exposed any Client-like object before the creation of its global object and realm execution context and the main resource (for parsing/executing) is ready. Now we expose Client objects in that state (during navigations and worker creations), we should provide an API to check this state.

@annevk
Copy link
Member

annevk commented Nov 8, 2016

What is the SW issue for adding reserved? And why is that not a promise-state attribute? E.g., client.ready.then(...)?

@jungkees
Copy link
Contributor Author

jungkees commented Nov 8, 2016

What is the SW issue for adding reserved?

It started as client.used in w3c/ServiceWorker#870 (comment) The name came up during the f2f I recall.

why is that not a promise-state attribute? E.g., client.ready.then(...)?

Good point. Once a Client is gotten from client-getter methods, it's a snapshot. What I missed is the value shouldn't be changed once the Client object is created. So, it should be a Client's field which is set by the object creation algorithm.

/cc @jakearchibald

@jungkees
Copy link
Contributor Author

jungkees commented Nov 8, 2016

Also note that execution ready flag is used in clients.matchAll(options) to filter the clients by options.includeReserved = false. So, the flag is being used in two places actually: client.reserved and clients.matchAll(options).

@annevk
Copy link
Member

annevk commented Nov 8, 2016

Okay, so if reserved doesn't change and we read the execution ready flag when we asynchronously gather state to create Client objects I think this is all okay.

Would be good to have the issue in SW filed so we can mention that in the commit message here. Makes it easier for folks in the future to figure out how everything relates.

@jungkees
Copy link
Contributor Author

jungkees commented Nov 8, 2016

Okay. Will fix .reserved and file an issue for it.

@annevk
Copy link
Member

annevk commented Nov 8, 2016

Also, could you propose a commit message for this PR that includes all the relevant info? I or @domenic can then land it since I think the text we have here is fine.

@jungkees
Copy link
Contributor Author

jungkees commented Nov 8, 2016

Sure. Will do when ready with all the relevant info. What's the convention to propose the final commit message? Update the OP or just a new comment here?

@annevk
Copy link
Member

annevk commented Nov 8, 2016

A new comment using the triple backtick syntax.

@jungkees
Copy link
Contributor Author

jungkees commented Nov 9, 2016

I've addressed the client.reserved fix (w3c/ServiceWorker@d2c327c) and filed an issue for tracking the history (w3c/ServiceWorker#1003).

Here' the proposed commit message:

Add environment's execution ready flag

Service Worker's client.reserved attribute and clients.matchAll(/*
options.includeReserved */) method require getting the state of a
Client object whether its environment is in reserved state or not. This
commit adds the execution ready flag to the environment concept that
distinguishes the state between before and after the UA is ready to
parse a fetched (or given default) document or execute a worker script.
The execution ready flag is set when the global object and realm
execution context are created and the main resource (for
parsing/executing) is ready.

Fixes #1992
Related SW issue: https://github.com/w3c/ServiceWorker/issues/1003

@annevk annevk merged commit d358c78 into whatwg:master Nov 9, 2016
@jungkees jungkees deleted the extend-environment branch November 9, 2016 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants