-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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] Refine getAvailability() test #4257
[presentation-api] Refine getAvailability() test #4257
Conversation
Notifying @louaybassbouss, @tidoust, and @zqzhang. (Learn how reviewing works.) |
Thanks @tomoyukilabs, Reviewing this test made me read the
I would suggest to wait until these issues are resolved. Other comments on the pull request:
|
@tidoust Okay, I wait for resolution of the remaining two issues. Now former step 6. has been removed from the getting availability algorithm, the test does not have to ensure that any presentation display is available, and I can safely restore this test to an automated one.
Do you mean that the test itself does not have to prompt users to prepare an available presentation display (as "crystal clear on test conditions")? |
Yes, I was thinking that we could add a "Pre-requisites" section to the README of the Presentation API test suite, that warns the tester that there must be at least one presentation display available to the user agent under test before tests may run, or something along these lines. |
I've updated the tests, which would follow recent changes in the spec.
|
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.
See comment about Promise flow inline which, I think, needs fixing. That looks good otherwise and aligned with latest version of the spec, many thanks!
}, function(err) { | ||
// getAvailability rejects a new Promise with NotSupportedError if the browser can find displays only when starting a connection | ||
assert_equals(err.name, 'NotSupportedError', 'getAvailability() rejects a Promise with a NotSupportedError exception, if the browser can find presentation displays only when starting a connection.') | ||
}).then(function (newAvailability) { |
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 may be lost in promises, but given you catch a possible getAvailability
failure before this then
, isn't that "then" part also going to be run if a failure occurs? Catching the NotSupportedError
error should end the test.
I'm not sure what is the cleanest way to write this:
- You could catch
NotSupportedError
in a final.catch(function err) {}
block. That would look great, but would make the test succeed in the (unlikely) event when only the second call to getAvailability fails with aNotSupportedError
error. I'd be fine with that personally, the implementation would be seriously buggy if it only rejects the second call. - You could move that
.then
part toreturn newPromise.then(function (newAvailability) { ... };
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.
Okay, I've fixed it as follows:
- The
.then
part is moved toreturn newPromise.then(function (newAvailability) { ... };
. - The updated tests catch
NotSupportedError
thrown by eithergetAvailability
call.
// ----------------------- | ||
promise_test(function () { | ||
var request = createRequestObject(); | ||
// instance of PresentationRequest |
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'm fan of comments in the code, but I note all the "assert" comments already appear in the assert calls themselves, so I think you can simply drop them throughout. That's just a suggestion, of course :)
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.
Thanks. I totally agree with your comment :-)
This PR partially fixes #4181.
test()
andpromise_test()
are integrated into singlepromise_test()
.This change is