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

[presentation-api] Update tests for onconnect, onclose and onterminate #5794

Merged

Conversation

tomoyukilabs
Copy link
Member

@tomoyukilabs tomoyukilabs commented May 5, 2017

This PR upgrades #4330 and fixes #4040 as well as several additional issues.

  • async_test and step_func are replaced with promise_test and EventWatcher.
  • Each file name is corrected and .https is added to the file name.
  • The onclose and onterminate tests check behavior in each connection state: connecting, connected, closed and terminated.
  • The onterminate test also checks behavior of another presentation connection in a nested browsing context.
  • The onterminate test now supposes that calling connection.terminate() must set state of presentation connections in connecting and connected state to terminated as defined in the current spec: Allow termination via connections in a connecting state. w3c/presentation-api#427

@w3c-bots
Copy link

w3c-bots commented May 5, 2017

View the complete job log.

Firefox (nightly channel)

Testing web-platform-tests at revision a211c01
Using browser at version BuildID 20170508100218; SourceStamp 1fda52a1f3b81cf1a821155998dca637bb64e3d9
Starting 10 test iterations
All results were stable

All results

4 tests ran
/presentation-api/controlling-ua/PresentationRequest_sandboxing_error.https.html
Subtest Results Messages
OK
Sandboxing: Creating a PresentationRequest from a nested context fails when allow-presentation is not set FAIL assert_equals: Presentation sandboxing did not work as expected. expected "SecurityError" but got "ReferenceError"
/presentation-api/controlling-ua/PresentationRequest_sandboxing_success.https.html
Subtest Results Messages
OK
Sandboxing: Creating a PresentationRequest from a nested context succeeds when allow-presentation is set FAIL assert_equals: Presentation sandboxing did not work as expected. expected "success" but got "ReferenceError"
/presentation-api/controlling-ua/getAvailability_sandboxing_success.https.html
Subtest Results Messages
OK
Sandboxing: Retrieving display availability from a nested context succeeds when allow-presentation is set FAIL assert_equals: Presentation sandboxing did not work as expected. expected "success" but got "Could not create PresentationRequest"
/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.https.html
Subtest Results Messages
OK
Sandboxing: Reconnecting a presentation from a nested context succeeds when allow-presentation is set FAIL assert_equals: Presentation sandboxing did not work as expected. expected "NotFoundError" but got "Could not create PresentationRequest"

@w3c-bots
Copy link

w3c-bots commented May 5, 2017

View the complete job log.

Chrome (unstable channel)

Testing web-platform-tests at revision a211c01
Using browser at version 60.0.3088.3 dev
Starting 10 test iterations
All results were stable

All results

4 tests ran
/presentation-api/controlling-ua/PresentationRequest_sandboxing_error.https.html
Subtest Results Messages
OK
Sandboxing: Creating a PresentationRequest from a nested context fails when allow-presentation is not set PASS
/presentation-api/controlling-ua/PresentationRequest_sandboxing_success.https.html
Subtest Results Messages
OK
Sandboxing: Creating a PresentationRequest from a nested context succeeds when allow-presentation is set PASS
/presentation-api/controlling-ua/getAvailability_sandboxing_success.https.html
Subtest Results Messages
OK
Sandboxing: Retrieving display availability from a nested context succeeds when allow-presentation is set PASS
/presentation-api/controlling-ua/reconnectToPresentation_sandboxing_success.https.html
Subtest Results Messages
OK
Sandboxing: Reconnecting a presentation from a nested context succeeds when allow-presentation is set PASS

Copy link
Contributor

@tidoust tidoust left a 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
Copy link
Contributor

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().

Copy link
Member Author

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().

Copy link
Contributor

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); }),
Copy link
Contributor

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([
Copy link
Contributor

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!

Copy link
Member Author

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'
@tomoyukilabs
Copy link
Member Author

I have fixed a couple of bugs in the "onclose" test. Also, I have updated the three tests so that they check both on(connect|close|terminate) and addEventListener (used in EventWatcher).

@tidoust tidoust merged commit a120a96 into web-platform-tests:master May 9, 2017
@tomoyukilabs tomoyukilabs deleted the update-connection-events branch May 10, 2017 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PresentationConnection_onxxx tests are incorrect
4 participants