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
[presentation-api] Update tests for onconnect, onclose and onterminate #5794
[presentation-api] Update tests for onconnect, onclose and onterminate #5794
Conversation
Firefox (nightly channel)Testing web-platform-tests at revision a211c01 All results4 tests ran/presentation-api/controlling-ua/PresentationRequest_sandboxing_error.https.html
/presentation-api/controlling-ua/PresentationRequest_sandboxing_success.https.html
/presentation-api/controlling-ua/getAvailability_sandboxing_success.https.html
/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.https.html
|
Chrome (unstable channel)Testing web-platform-tests at revision a211c01 All results4 tests ran/presentation-api/controlling-ua/PresentationRequest_sandboxing_error.https.html
/presentation-api/controlling-ua/PresentationRequest_sandboxing_success.https.html
/presentation-api/controlling-ua/getAvailability_sandboxing_success.https.html
/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.https.html
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a couple of errors to fix in the "onclose" test. Please see inline.
connection = c; | ||
return stash.init(); | ||
}).then(() => { | ||
// Step 1: close the presentation connection in "connecting" state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, what guarantees that the presentation connection is still in the "connecting" state here? The previous call to stash.init()
can take an arbitrary amount of time. You should probably run that call before calling request.start()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, that's right. I'll move stash.init()
somewhere else.
By the way, while I'm not sure whether it is correct or not, Chrome Canary throws an exception like "InvalidAccessError: PresentationRequest::start() requires user gesture."
when request.start()
is called within stash.init().then()
. This is the reason why I avoided calling stash.init()
before request.start()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I believe the behavior is somewhat up to implementations in practice, see end of third bullet point in definition of allowed to show a popup.
It's interesting that Promise.all
seems to solve the problem.
const terminateWatcher = new EventWatcher(t, connection, 'terminate'); | ||
connection.terminate(); | ||
return Promise.race([ | ||
new Promise(resolve => { t.step_timeout(resolve, 1000); }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that's not ideal, but I cannot think of a better way to check the absence of effects.
eventWatcher = new EventWatcher(t, connection, ['close', 'connect', 'terminate']); | ||
|
||
connection.close(); | ||
return Promise.all([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want Promise.race
here, the timeout will always occur otherwise!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I'll fix it.
- `stash.init()` is called before `request.start()` - inappropriate use of `Promise.all` is changed to `Promise.race'
I have fixed a couple of bugs in the "onclose" test. Also, I have updated the three tests so that they check both |
This PR upgrades #4330 and fixes #4040 as well as several additional issues.
async_test
andstep_func
are replaced withpromise_test
andEventWatcher
..https
is added to the file name.onclose
andonterminate
tests check behavior in each connection state:connecting
,connected
,closed
andterminated
.onterminate
test also checks behavior of another presentation connection in a nested browsing context.onterminate
test now supposes that callingconnection.terminate()
must set state of presentation connections inconnecting
andconnected
state toterminated
as defined in the current spec: Allow termination via connections in a connecting state. w3c/presentation-api#427