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

spec behavior when ServiceWorkerContainer parent client is dead #777

Open
wanderview opened this issue Nov 4, 2015 · 11 comments
Open

spec behavior when ServiceWorkerContainer parent client is dead #777

wanderview opened this issue Nov 4, 2015 · 11 comments

Comments

@wanderview
Copy link
Member

This is kind of a corner case, but I don't think the spec really handles it currently:

  1. open a random webpage
  2. w = window.open("./")
  3. sw = w.navigator.serviceWorker
  4. close the new tab from step 1
  5. sw.register("whatever.js");

In this case we're calling .register() for a window that is already closed. I'm intending to reject with InvalidStateErr, but I guess it would be nice to spec it.

@wanderview
Copy link
Member Author

@wanderview
Copy link
Member Author

I guess to be more accurate, gecko is going to return a rejected promise, but we don't fire promise callbacks for closed windows. So the .catch() callback won't fire.

@wanderview
Copy link
Member Author

It appears chrome canary returns undefined instead of a promise object in this case.

@jungkees
Copy link
Collaborator

jungkees commented Nov 5, 2015

I think the question here is more in general what the behavior of accessing APIs hang off a destroyed object should be. Do we have any existing language that specifies this?

/cc @annevk @bzbarsky @domenic

@bzbarsky
Copy link

bzbarsky commented Nov 5, 2015

The object is not destroyed, kinda sorta. Existing spec language assumes that all things leak forever and the browser never cleans anything up. Clearly that's not reasonable, so in practice browsers by and large implement different things which are not interoperable. Sometimes browsers are not internally consistent (e.g. treating removing an iframe from the DOM tree one way in terms of what happens to the Window currently in it and navigating the iframe in a different way, and closing a toplevel tab in yet a third way).

Oh, and there may be some actual web compat constraints around this stuff for some APIs. I seem to recall that when Gecko tried turning off scripts altogether in a Window whose iframe has been removed from the DOM we ran into web compat issues.

None of that helps you with your current situation, of course...

@mkruisselbrink
Copy link
Collaborator

@jakearchibald
Copy link
Contributor

F2F:

  • Seems like browsers keep windows alive when there's a reference held within
  • This is a much bigger web compat problem, and needs to be solved at a lower level
  • Do we do fetches from a detached iframe? We don't SW control these, and should spec that
  • Are detached iframes controlled?
  • If you add/remove iframe
  • This is another good argument for the clientcontrolled event
  • Happy for methods to fail (throw/reject) if the window is detated, properties shouldn't throw, but may return undefined/null

@jakearchibald
Copy link
Contributor

  • Add non-normative note about this
  • Cover it with WPTs

@aliams
Copy link
Contributor

aliams commented Jul 28, 2016

Seems like browsers keep windows alive when there's a reference held within

In Edge, the reference is emptied (that is, the object has no properties nor functions) when the window is closed. This means that you are not able to access anything which makes it not possible for us to fail by throwing an error or returning a rejected promise.

@jakearchibald
Copy link
Contributor

Notes:

  • We might be able to make these APIs work without a browsing context, but we should ask implementors because I don't think devs care much either way
  • Feedback from MS is important here

@jungkees
Copy link
Collaborator

We move this to V2 to have more discussion and experiments.

@jungkees jungkees modified the milestones: Version 1, Version 2 Dec 11, 2017
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

6 participants