Commit 8d057125 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

Reland "Add tests for JIT installable payment handlers."

This is a reland of 33a1a4b02fd1c7d7c623513274c24692d6602d8d

Original change's description:
> Add tests for JIT installable payment handlers.
>
> Bug: 872305
> Change-Id: I992e534ab0ca48affc14464c23af41a495209c58
> Reviewed-on: https://chromium-review.googlesource.com/1168084
> Reviewed-by: Ganggui Tang <gogerald@chromium.org>

TBR=gogerald@chromium.org

Bug: 872305
Change-Id: Icdf80a7bb92b53b85c09648bf483f1671fcfa662
Reviewed-on: https://chromium-review.googlesource.com/1172542Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582597}
parent 3882b0e8
......@@ -19,14 +19,26 @@ TestDownloader::TestDownloader(
TestDownloader::~TestDownloader() {}
void TestDownloader::DownloadPaymentMethodManifest(
const GURL& url,
PaymentManifestDownloadCallback callback) {
PaymentManifestDownloader::DownloadPaymentMethodManifest(
FindTestServerURL(url), std::move(callback));
}
void TestDownloader::DownloadWebAppManifest(
const GURL& url,
PaymentManifestDownloadCallback callback) {
PaymentManifestDownloader::DownloadWebAppManifest(FindTestServerURL(url),
std::move(callback));
}
void TestDownloader::AddTestServerURL(const std::string& prefix,
const GURL& test_server_url) {
test_server_url_[prefix] = test_server_url;
}
void TestDownloader::DownloadPaymentMethodManifest(
const GURL& url,
PaymentManifestDownloadCallback callback) {
GURL TestDownloader::FindTestServerURL(const GURL& url) const {
GURL actual_url = url;
// Find the first key in |test_server_url_| that is a prefix of |url|. If
......@@ -42,8 +54,7 @@ void TestDownloader::DownloadPaymentMethodManifest(
}
}
PaymentManifestDownloader::DownloadPaymentMethodManifest(actual_url,
std::move(callback));
return actual_url;
}
} // namespace payments
......@@ -56,9 +56,13 @@ class TestDownloader : public PaymentManifestDownloader {
void DownloadPaymentMethodManifest(
const GURL& url,
PaymentManifestDownloadCallback callback) override;
void DownloadWebAppManifest(
const GURL& url,
PaymentManifestDownloadCallback callback) override;
// Modifies the downloader to replace all instances of |prefix| with
// |test_server_url| when downloading the payment method manifest.
// |test_server_url| when downloading payment method manifests and web app
// manifests.
//
// For example, if AddTestServerURL("https://", "https://127.0.0.1:7070") is
// called, then all calls to DownloadPaymentMethodManifest(some_url, callback)
......@@ -92,6 +96,8 @@ class TestDownloader : public PaymentManifestDownloader {
void AddTestServerURL(const std::string& prefix, const GURL& test_server_url);
private:
GURL FindTestServerURL(const GURL& url) const;
// The mapping from the URL prefix to the URL of the test server to be used.
// Example 1:
//
......
/*
* Copyright 2018 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
self.addEventListener('canmakepayment', (evt) => {
evt.respondWith(true);
});
self.addEventListener('paymentrequest', (evt) => {
evt.respondWith({
methodName: evt.methodData[0].supportedMethods,
details: {transactionId: '123'},
});
});
{
"name": "Pay with KylePay",
"short_name": "KylePay",
"icons": [{
"src": "icon.png",
"sizes": "48x48",
"type": "image/png"
}],
"serviceworker": {
"src": "app.js",
"use_cache": false,
"scope": "/webpay"
}
}
{
"default_applications": ["https://kylepay.com/app.json"]
}
HTTP/1.1 200 OK
Link: <payment-manifest.json>; rel="payment-method-manifest"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment