| Index: third_party/WebKit/LayoutTests/http/tests/budget/get-cost-in-service-worker.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/budget/get-cost-in-service-worker.html b/third_party/WebKit/LayoutTests/http/tests/budget/get-cost-in-service-worker.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6d855f445859cacb520d387203970f7d8a0124b8
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/budget/get-cost-in-service-worker.html
|
| @@ -0,0 +1,41 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| +<head>
|
| +<title>getCost succeeds from a Service Worker</title>
|
| +<script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharnessreport.js"></script>
|
| +<script src="../serviceworker/resources/test-helpers.js"></script>
|
| +<script src="../notifications/resources/test-helpers.js"></script>
|
| +<script src="/js-test-resources/mojo-helpers.js"></script>
|
| +<script src="budget-service-mock.js"></script>
|
| +</head>
|
| +<body>
|
| +<script>
|
| +async_test(function(test) {
|
| + var script = 'resources/instrumentation-service-worker.js';
|
| + var scope = 'resources/scope/' + location.pathname;
|
| + var port;
|
| +
|
| + budgetServiceMock.then(mock => {
|
| + getActiveServiceWorkerWithMessagePort(test, script, scope)
|
| + .then(function(workerInfo) {
|
| + port = workerInfo.port;
|
| + port.postMessage({command: 'getCost'});
|
| +
|
| + port.addEventListener('message', function(event) {
|
| + if (typeof event.data != 'object' || !event.data.command)
|
| + assert_unreached('Invalid message from the service worker');
|
| +
|
| + assert_equals(event.data.command, 'getCost');
|
| + assert_true(event.data.success,
|
| + 'getCost should succeed. Error message: ' + event.data.errorMessage);
|
| + assert_equals(event.data.cost, TEST_BUDGET_COST);
|
| + test.done();
|
| + });
|
| + })
|
| + .catch(unreached_rejection(test));
|
| + });
|
| +}, 'getCost should succeed from Service Worker');
|
| +</script>
|
| +</body>
|
| +</html>
|
|
|