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

Behavior of the onfetch setter regarding no-fetch service workers #1004

Closed
catalinb opened this issue Nov 9, 2016 · 12 comments
Closed

Behavior of the onfetch setter regarding no-fetch service workers #1004

catalinb opened this issue Nov 9, 2016 · 12 comments

Comments

@catalinb
Copy link

catalinb commented Nov 9, 2016

With the changes discussed in #718 addEventListener should throw unless called during the script's initial evaluation. What should be the behavior of setting the onfetch event handler?

I'm guessing it should throw as well, but this was not included in the spec.

from https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes

When an event handler H of an element or object T implementing the EventTarget interface is first set to a non-null value, the user agent must append an event listener to the list of event listeners associated with T with type set to the event handler event type corresponding to H and callback set to the event handler processing algorithm defined below.

This can be changed to use addEventListener for adding the event listener.

@annevk
Copy link
Member

annevk commented Nov 10, 2016

This should be fixed together with whatwg/dom#371.

@annevk annevk added this to the Version 1 milestone Nov 10, 2016
@annevk annevk added the bug label Nov 10, 2016
@jungkees
Copy link
Collaborator

Thanks for spotting. I'll follow up on this after clarifying whatwg/dom#371.

@annevk
Copy link
Member

annevk commented Jan 10, 2017

What's the status here @jungkees? Would be good to sort this out.

@jungkees
Copy link
Collaborator

When an event handler H of an element or object T implementing the EventTarget interface is first set to a non-null value

Event handler IDL attributes, on setting, must set the corresponding event handler to their new value

Yeah, the idea is to add the following step to the above places:

"Throw when T is a ServiceWorkerGlobalScope object, type is an event type in the while list, and the SW's has ever been evaluated flag is set."

But this isn't decided yet. We should conclude what the better design would be in whatwg/dom#371.

annevk added a commit to whatwg/dom that referenced this issue Mar 13, 2018
This hook ensures that any special casing in addEventListener() is shared with event handler attributes.

Helps with w3c/ServiceWorker#1004.
annevk added a commit to whatwg/html that referenced this issue Mar 13, 2018
@annevk
Copy link
Member

annevk commented Mar 13, 2018

Since nobody else took this up I wrote the necessary patches for DOM and HTML.

annevk added a commit to whatwg/dom that referenced this issue Mar 14, 2018
This hook ensures that any special casing in addEventListener() is shared with event handlers. This commit also makes numerous editorial improvements that were long overdue around dictionary members.

The corresponding change to the HTML Standard, which defines event handlers, is tracked by whatwg/html#3561.

This helps with #365 and w3c/ServiceWorker#1004. (Tests will be added as part of #365 eventually.)
annevk added a commit to whatwg/html that referenced this issue Mar 14, 2018
This hook was provided whatwg/dom#596 and event handlers need to use it to fix whatwg/dom#365 and w3c/ServiceWorker#1004 properly. Tests will be added as part of resolving those issues.
@annevk
Copy link
Member

annevk commented Mar 14, 2018

OP is now addressed, but I think we should leave this open until someone has addressed the questions I raised in whatwg/dom#371 and there's tests covering exactly what we want to be doing here.

@jungkees
Copy link
Collaborator

@annevk, thanks for helping out with this issue. I leave a comment here as the PRs have already been merged.

Through the discussion in whatwg/dom#371, we decided to confine the event target to ServiceWorkerGlobalScope instead of all the objects within the global scope. So, https://github.com/whatwg/dom/pull/596/files#diff-a467e681501e456ce8c1ef31425e1b41R1046 should be "If evenTarget is a ServiceWorkerGlobalScope object, ..".

@annevk
Copy link
Member

annevk commented Mar 16, 2018

Well, that issue isn't fixed yet and that decision is being contested by bz in that issue. That's why that text hasn't been touched thus far.

@annevk
Copy link
Member

annevk commented Mar 16, 2018

Also, are there any tests?

@jungkees
Copy link
Collaborator

That bit was posed by the OP: whatwg/dom#371 (comment). Allowing the event target to be any object doesn't make sense, and the proposed change is in the direction of a solution.

I'll need to check out for tests.

@annevk
Copy link
Member

annevk commented Mar 16, 2018

I think throwing in general doesn't make sense, even for the global object. As bz points out, you could have custom events that you might want to register at a later time.

jungkees added a commit to jungkees/dom that referenced this issue Jun 6, 2018
This changes addEventListener() and removeEventListener() to not throw even
after the very first evalution of the service worker script. Instead, this
specifies user agents have to show a console warning that the asynchronously
added listener's event type will not affect service worker's behavior with the
functional event stored during the first evaluation.

This change referneces the funcional event concept defined in Service Workers
spec, and confines the EventTarge object of the specified behavior to
ServiceWorkerGlobalScope object instead of all the platform object in the global
object.

Related SW issue: w3c/ServiceWorker#1004.
Related SW PR: w3c/ServiceWorker#1322.
Fixes whatwg#371.
alice pushed a commit to alice/html that referenced this issue Jan 8, 2019
This hook was provided whatwg/dom#596 and event handlers need to use it to fix whatwg/dom#365 and w3c/ServiceWorker#1004 properly. Tests will be added as part of resolving those issues.
annevk pushed a commit to jungkees/dom that referenced this issue Nov 1, 2019
This changes addEventListener() and removeEventListener() to not throw even
after the very first evalution of the service worker script. Instead, this
specifies user agents have to show a console warning that the asynchronously
added listener's event type will not affect service worker's behavior with the
functional event stored during the first evaluation.

This change referneces the funcional event concept defined in Service Workers
spec, and confines the EventTarge object of the specified behavior to
ServiceWorkerGlobalScope object instead of all the platform object in the global
object.

Related SW issue: w3c/ServiceWorker#1004.
Related SW PR: w3c/ServiceWorker#1322.
Fixes whatwg#371.
annevk pushed a commit to whatwg/dom that referenced this issue Nov 4, 2019
This changes addEventListener() and removeEventListener() to not throw even after the very first evalution of the service worker script. Instead, this specifies user agents have to show a console warning.

Related: w3c/ServiceWorker#1004 and w3c/ServiceWorker#1322.

Tests: web-platform-tests/wpt#19496.

Fixes #371.
@jungkees
Copy link
Collaborator

jungkees commented Nov 4, 2019

@jungkees jungkees closed this as completed Nov 4, 2019
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

4 participants