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

Resolving the promise after the change event is fired #147

Merged
merged 3 commits into from Feb 12, 2019

Conversation

Johanna-hub
Copy link
Contributor

@Johanna-hub Johanna-hub commented Feb 4, 2019

Closes #120

The following tasks have been completed:

Implementation commitment:


Preview | Diff

@marcoscaceres
Copy link
Member

Looks good. I think the gh-pages branch itself needs a tidy tho. I see tidy changes that should be on the gh-pages branch.

@marcoscaceres
Copy link
Member

@kenchris how do propose we handle this on the Chrome side? This is a breaking change. I think it’s worth doing, but we will need to convince folks (hi @mounirlamouri! 🤗)

@mounirlamouri
Copy link
Member

Is there a recommended pattern by the TAG or commonly used one from other specifications?

@kenchris
Copy link

kenchris commented Feb 5, 2019

Let me talk with @slightlyoff

@kenchris
Copy link

kenchris commented Feb 5, 2019

Please have a look at https://www.w3.org/2001/tag/doc/promises-guide

@marcoscaceres
Copy link
Member

@mounirlamouri wrote

Is there a recommended pattern by the TAG or commonly used one from other specifications?

I was actually thinking of filing a bug on the TAG as this particular situation is not exactly covered by either the API Design Guide or the Promises Guide.

Regardless, the "pending promise" effectively represents the screen having changed:

const pendingPromise = new Promise(r => {
  screen.orientation.addEventListener("change", ()=> r(), { once: true });
});

@kenchris
Copy link

kenchris commented Feb 5, 2019

I was actually thinking of filing a bug on the TAG as this particular situation is not exactly covered by either the API Design Guide or the Promises Guide.

Yes, I noticed the same. Please file

@marcoscaceres
Copy link
Member

@kenchris, the closest I get in the Promises Guide is this section:
https://www.w3.org/2001/tag/doc/promises-guide#one-time-events

The prototypical example of such an "event" is a loaded indicator: a resource such as an image, font, or even document, could provide a loaded property that is a promise that becomes fulfilled only when the resource has fully loaded (or becomes rejected if there’s an error loading the resource).

The above suggests that the event occurs, and, as a result the promise is resolved and rejected based on what the result is.

Then, authors can always queue up actions to be executed once the resource is ready by doing resource.loaded.then(onLoaded, onFailure).

The above follows...

This will work even if the resource was loaded already, queueing a microtask to execute onLoaded. This is in contrast to an event model, where if the author is not subscribed at the time the event fires, that information is lost.

... and so on...

Anyway, will file a bug :)

@marcoscaceres
Copy link
Member

Filed https://github.com/w3ctag/promises-guide/issues/57

@marcoscaceres
Copy link
Member

@mounirlamouri, the TAG has kindly updated their API Design doc providing advice around this - thanks @kenchris for making that happen!

Given the TAG's advice, would you be ok with changing the behavior? @Johanna-hub and I can update the implement on the Gecko side, and provide WPTests.

@marcoscaceres marcoscaceres self-requested a review February 7, 2019 13:30
Copy link
Member

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

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

LGTM

@Johanna-hub
Copy link
Contributor Author

We now have a test for this web-platform-tests/wpt#15267
@kenchris and anyone else interested, would be great if you could take a look and let us know any comments?

I have also filed a bug on bugzilla https://bugzilla.mozilla.org/show_bug.cgi?id=1525582

@mounirlamouri
Copy link
Member

LGTM. I don't know if and when I would update the implementation in Chromium. Though, @Johanna-hub if you want to send a patch, I would happily review :)

@marcoscaceres
Copy link
Member

@mounirlamouri, sure, we can probably do it. Being new the Blink code base, if you can quickly just point us to the right files, we can go from there.

@mounirlamouri
Copy link
Member

Actually, I realised that I had in my backlog removing all the Android Jelly Bean support from the screen orientation code. Will probably do both at the same time.

@marcoscaceres
Copy link
Member

@mounirlamouri, ok cool. We will make sure to have good web platform tests for you at least :)

@marcoscaceres
Copy link
Member

oh, before I forget, do you want us to file a bug for this specifically on the Chrome side? Or do you have a link to your refactor bug?

@mounirlamouri
Copy link
Member

I've updated the initial message with the bug number. I have a CL ready that seems to work. Should be in soon.

aarongable pushed a commit to chromium/chromium that referenced this pull request Feb 11, 2019
This is following a spec change:
w3c/screen-orientation#147

Bug: 930237
Change-Id: I75144357aa91d6fc24a7f7d935d321ae084f7c99
Reviewed-on: https://chromium-review.googlesource.com/c/1460427
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Reviewed-by: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630970}
@mounirlamouri
Copy link
Member

The change has landed in Blink. Hopefully it will stick. Subtle timing changes like this always worry me :)

@marcoscaceres
Copy link
Member

Ok, excellent. I’ll make sure the changes happen on the Mozilla side ASAP. Then our implementations can be in sync.

Copy link
Member

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

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

Ok, let's go with this. We need to fix this up to use task queues, however.

@marcoscaceres
Copy link
Member

Working on the Gecko patch.

@marcoscaceres marcoscaceres merged commit 1864271 into w3c:gh-pages Feb 12, 2019
@marcoscaceres
Copy link
Member

Ok, landed the changes in Gecko too. Fingers crossed it doesn't get backed out.

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

4 participants