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

PaymentRequest: fixes allowpaymentrequest test errors #6418

Merged
merged 3 commits into from
Jul 7, 2017

Conversation

AmazingJaze
Copy link
Contributor

@AmazingJaze AmazingJaze commented Jun 28, 2017

Fixes test errors causing test files to fail in Edge and Chrome.

  1. The error in removing-allowpaymentrequest.https.sub.html is that the test expects the PaymentRequest Constructor to fail before allowpaymentrequest has been turned off.
  2. The error in setting-allowpaymentrequest.https.sub.html is that the test expects the PaymentRequest Constructor to succeed before allowpaymentrequest has ever been turned on.

Edit: Also fixes an error in setting-allowpaymentrequest-timing.https.sub.html
3) From the comments in the test it appears that the test expects to turn on the allowpaymentrequest asynchronously before the iframe can receive the postmessage. However, the error in the test is that it expects a security error to be thrown after the allowpaymentrequest attribute has been turned on.

//CC @marcoscaceres

1) The error in removing-allowpaymentrequest.https.sub.html is that the test expects the PaymentRequest Constructor to fail before allowpaymentrequest has been turned off.
2) The error in setting-allowpaymentrequest.https.sub.html is that the test expects the PaymentRequest Constructor to succeed before allowpaymentrequest has ever been turned on.
This test currently fails in Chrome and Edge. From the comments in the test it appears that the test expects to turn on the allowpaymentrequest asynchronously before the iframe can receive the postmessage.
However, the error in the test is that it expects a security error to be thrown after the allowpaymentrequest attribute has been turned on.
@ghost
Copy link

ghost commented Jun 28, 2017

View the complete job log.

Firefox (nightly)

Testing web-platform-tests at revision 2b23009
Using browser at version BuildID 20170612100241; SourceStamp 27cad9749cddf68e11fdd4e5d73dad84a8f8cf23
Starting 10 test iterations

@ghost
Copy link

ghost commented Jun 28, 2017

View the complete job log.

Sauce (safari)

Testing web-platform-tests at revision 2b23009
Using browser at version 10.0
Starting 10 test iterations

@ghost
Copy link

ghost commented Jun 28, 2017

View the complete job log.

Chrome (unstable)

Testing web-platform-tests at revision 2b23009
Using browser at version 61.0.3141.7 dev
Starting 10 test iterations

@ghost
Copy link

ghost commented Jun 28, 2017

View the complete job log.

Sauce (MicrosoftEdge)

Testing web-platform-tests at revision 2b23009
Using browser at version 14.14393
Starting 10 test iterations

Copy link
Contributor

@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.

Blocking on clarification.

@@ -13,7 +13,7 @@
const path = location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1);
iframe.src = "https://{{domains[www1]}}:{{ports[https][0]}}" + path + "echo-PaymentRequest.html";
iframe.onload = t.step_func(() => {
if (i === 0) {
if (i === 1) {
Copy link
Contributor

@marcoscaceres marcoscaceres Jun 28, 2017

Choose a reason for hiding this comment

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

I'm confused. When onload is called, the expectation is still that i should be 0. Otherwise iframe.allowPaymentRequest = false; is never set? I think the same applies for the rest?

@zcorpan, you wrote these tests, right? Can you confirm?

Copy link
Contributor

@marcoscaceres marcoscaceres Jun 28, 2017

Choose a reason for hiding this comment

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

(fixed typo, s/exception/expectation... grrr... autocorrect)

Copy link
Contributor Author

@AmazingJaze AmazingJaze Jun 28, 2017

Choose a reason for hiding this comment

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

@marcoscaceres I certainly understand that the flow of this test is easy to mistake.
My northstar assumption is that this test file is trying to verify that removing the allowpaymentrequest attribute from iframe causes the PaymentRequest constructor inside of the iframe to start throwing SecurityExceptions

Keep in mind that the iframe src is echo-PaymentRequest.html and this test relies on the script defined in that file as well.

Execution starting from the parent Window:

  1. Initially iframe.allowPaymentRequest = true;
  2. First time the iframe loads, script in iframe receives postmessage and calls the PaymentRequest constructor. Because allowpaymentrequest is still enabled, Iframe should postmessage to parent window indicating success.
  3. parentWindow receives message from iframe and does the following:
  • increments counter i++ to 1,
  • (parent window should expect iframe to report success because we haven't turned off allowpaymentrequest yet) Parent window validates success result. (without my change the test fails here because it would instead be expecting a SecurityError at this point)
  • parent window removes allowpaymentrequest from the iframe
  • parent window triggers iframe onload to fire again via navigation.
    ^This resets the entire communication loop, replaying the iframe onload & parent window onmessage handlers a second time.
    ^Once again iframe will try to construct another paymentrequest, only this time a SecurityError should be raised. This time when receiving the iframe's response, the parent window onmessage handler will increment counter i++ to 2, leading the rest of the function to then correctly expect a Security Error result from the Iframe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edited the above for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcoscaceres @zcorpan, let me know if any further clarification is needed

Copy link
Contributor

@marcoscaceres marcoscaceres Jul 5, 2017

Choose a reason for hiding this comment

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

@AmazingJaze thanks for the clarification.

@zcorpan (and @sideshowbarker, assuming you reviewed this), we should avoid tests like this - it's too easy to screw them up for both the reviewer and the person writing them.

Copy link
Member

Choose a reason for hiding this comment

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

I disagree we should avoid tests like this. This needs to be interoperably implemented to not open up security problems...

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I was not clear, I meant more with the style in which the tests was written. Its was difficult to decipher what is going on.

@marcoscaceres
Copy link
Contributor

Rerunning the tests. Hopefully they pass now....

@marcoscaceres marcoscaceres merged commit 9a6a1f4 into web-platform-tests:master Jul 7, 2017
@zcorpan
Copy link
Member

zcorpan commented Aug 16, 2017

Hmm. I believe the test was correct before this change. https://w3c-test.org/payment-request/allowpaymentrequest/removing-allowpaymentrequest.https.sub.html now fails in Chrome Canary with experimental web platform features enabled.

Result Test Name Message
Fail PaymentRequest removing allowpaymentrequest after load and then navigating assert_equals: before navigation expected "Success" but got "Exception"

https://w3c-test.org/payment-request/allowpaymentrequest/setting-allowpaymentrequest-timing.https.sub.html also fails

Result Test Name Message
Fail PaymentRequest setting allowpaymentrequest after document creation, before response assert_equals: expected "Success" but got "Exception"

Note that the state of whether paymentrequest is allowed is set when the browsing context is created, and again when it is navigated, but it is not updated directly in response to changing the attribute. I know this is quite confusing, but the design is intentional, and it is important that it is tested correctly that the state is set exactly as specified. See whatwg/html#2195

The test can do a better job at documenting what it's doing, of course.

cc @rsolomakhin

zcorpan added a commit that referenced this pull request Aug 16, 2017
zcorpan added a commit that referenced this pull request Sep 6, 2017
zcorpan added a commit that referenced this pull request Sep 10, 2017
#6905)

* Revert "PaymentRequest: fixes allowpaymentrequest test errors (#6418)"

This reverts commit 9a6a1f4.

* Document what removing-allowpaymentrequest.https.sub.html is doing

* Explain expected result in setting-allowpaymentrequest-timing.https.sub.html
rachelandrew pushed a commit to rachelandrew/web-platform-tests that referenced this pull request Nov 8, 2017
…atform-tests#6418)" (web-platform-tests#6905)

* Revert "PaymentRequest: fixes allowpaymentrequest test errors (web-platform-tests#6418)"

This reverts commit 9a6a1f4.

* Document what removing-allowpaymentrequest.https.sub.html is doing

* Explain expected result in setting-allowpaymentrequest-timing.https.sub.html
jakearchibald pushed a commit to jakearchibald/web-platform-tests that referenced this pull request Nov 16, 2017
…atform-tests#6418)" (web-platform-tests#6905)

* Revert "PaymentRequest: fixes allowpaymentrequest test errors (web-platform-tests#6418)"

This reverts commit 9a6a1f4.

* Document what removing-allowpaymentrequest.https.sub.html is doing

* Explain expected result in setting-allowpaymentrequest-timing.https.sub.html
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.

4 participants