• rouslan's avatar
    Verify behavior of PaymentRequest constructor. · dca98e1e
    rouslan authored
    This patch adds web platform tests that verify behavior of
    PaymentRequest constructor. To match the spec, PaymentRequest
    constructor in this patch has been changed to:
    - Check for secure context before validating any parameters.
    - Check the amount value first before checking the rest of the fields in
      each line item.
    - Determine the selected shipping option even if requestShipping is
      false.
    - Validate shipping options even if requestShipping is false.
    - Validate shipping options before checking for duplicate shipping
      option IDs.
    - Allow empty line item labels (but discourage via a console warning).
    - Allow empty shipping option ID (but discourage via a console warning).
    - Allow empty list of modifiers.
    
    Because of changes in the WebIDL, certain conditions are not possible,
    so they are ensured via DCHECK() in this patch instead of if statements
    before this patch:
    - Total is always present.
    - Every line item has a label and amount.
    - Every amount has value and currency.
    - Every shipping option has an ID.
    - Shipping type is always valid.
    
    Invalid shipping type ("delivery", "shipping", or "pickup") is now
    impossible because the WebIDL specifies it as an enum. Therefore,
    there's no need for additional validation there.
    
    To help developers better decipher the behavior of the API, error
    messages have been improved in this patch. For example:
      "'-1/3' is not a valid amount for total."
    
    Spec:
    https://w3c.github.io/browser-payment-api/#constructor
    
    BUG=705252
    
    Review-Url: https://codereview.chromium.org/2851383002
    Cr-Commit-Position: refs/heads/master@{#469369}
    dca98e1e
payment-request-interface.html 23.9 KB