| <!DOCTYPE html> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/common/utils.js"></script> |
| <script> |
| const RESOURCES_DIR = "/WebKit/beacon/resources/"; |
| |
| if (window.internals) |
| internals.settings.setFetchAPIKeepAliveEnabled(false); |
| |
| function waitForBeaconCompletion() |
| { |
| return new Promise(function(resolve, reject) { |
| if (!internals.inflightBeaconsCount) { |
| resolve(); |
| return; |
| } |
| setTimeout(function() { |
| waitForBeaconCompletion().then(resolve, reject); |
| }, 10); |
| }); |
| } |
| |
| function createPayload(payloadSize) |
| { |
| return new Blob(["*".repeat(payloadSize)]); |
| } |
| |
| promise_test(function() { |
| var id = self.token(); |
| var target = RESOURCES_DIR + "beacon-preflight.py?allowCors=1&cmd=put&id=" + id; |
| |
| assert_true(navigator.sendBeacon(target, createPayload(10)), "Send beacon"); |
| return waitForBeaconCompletion(); |
| }, "Send Beacon"); |
| </script> |