| Index: third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-registration-abort.https.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-registration-abort.https.html b/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-registration-abort.https.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..239d40803bf8811fd5661faa0f91b2f3491de260
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/background_fetch/background-fetch-registration-abort.https.html
|
| @@ -0,0 +1,54 @@
|
| +<!doctype html>
|
| +<meta charset="utf-8">
|
| +<title>Background Fetch API: BackgroundFetchRegistration.abort() tests</title>
|
| +<script src="/resources/testharness.js"></script>
|
| +<script src="/resources/testharnessreport.js"></script>
|
| +<script src="/serviceworker/resources/test-helpers.js"></script>
|
| +
|
| +<h1>BackgroundFetchRegistration.abort()</h1>
|
| +<p>This test validates the behaviour of the abort() method.</p>
|
| +
|
| +<!-- TODO(peter): Move this to the WPT directory when it's merged and we
|
| + can successfully create a new Background Fetch registration. -->
|
| +
|
| +<script>
|
| +'use strict';
|
| +
|
| +const workerUrl = 'resources/empty-worker.js';
|
| +const scope = 'resources/scope/' + location.pathname;
|
| +
|
| +promise_test(function(test) {
|
| + const tag = 'my-background-fetch';
|
| +
|
| + let registration = null;
|
| + let backgroundFetchRegistration = null;
|
| +
|
| + return service_worker_unregister_and_register(test, workerUrl, scope)
|
| + .then(r => {
|
| + registration = r;
|
| + return wait_for_state(test, r.installing, 'activated');
|
| + })
|
| + .then(() => registration.backgroundFetch.fetch(tag, ['resources/non-existing-file.png']))
|
| + .then(r => {
|
| + backgroundFetchRegistration = r;
|
| +
|
| + assert_true(backgroundFetchRegistration instanceof BackgroundFetchRegistration);
|
| + assert_inherits(backgroundFetchRegistration, 'abort');
|
| +
|
| + return backgroundFetchRegistration.abort();
|
| + })
|
| + .then(success => {
|
| + // The registration was valid, so aborting it should be successful.
|
| + assert_true(success);
|
| +
|
| + return backgroundFetchRegistration.abort();
|
| + })
|
| + .then(success => {
|
| + // The registration had already been aborted, so aborting it again should fail.
|
| + // TODO(peter): This is a change-detector test, and will deliberately
|
| + // start failing when the browser side has been hooked up.
|
| + assert_true(success);
|
| + });
|
| +
|
| +}, 'BackgroundFetchRegistration.abort() return a Promise indicating success.');
|
| +</script>
|
|
|