Revision 4f06a45252465792447f80b6559b17c4c4e9712c authored by Daniel Vogelheim on 10 April 2018, 13:07:39 UTC, committed by Chromium WPT Sync on 10 April 2018, 13:07:39 UTC
Allow control of the deprecation via runtime enabled features, with a first step for logging a warning to the console, and the second step to block it outright. Intent: https://groups.google.com/a/chromium.org/d/msg/blink-dev/35t5cJQ3J_Q/FH45dl0vAwAJ Change-Id: I1be1001cbbef152458119b1516750bb4f1d1e4de Reviewed-on: https://chromium-review.googlesource.com/975611 Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org> Reviewed-by: Mike West <mkwst@chromium.org> Cr-Commit-Position: refs/heads/master@{#549495}
1 parent 069680c
beacon-error.window.js
// META: script=/common/utils.js
// META: script=beacon-common.sub.js
"use strict";
test(function() {
// Payload that should cause sendBeacon to return false because it exceeds the maximum payload size.
var exceedPayload = Array(maxPayloadSize + 1).fill('z').join("");
var success = navigator.sendBeacon("http://doesnotmatter", exceedPayload);
assert_false(success, "calling 'navigator.sendBeacon()' with payload size exceeding the maximum size must fail");
}, "Verify calling 'navigator.sendBeacon()' with a large payload returns 'false'.");
test(function() {
var invalidUrl = "http://invalid:url";
assert_throws(new TypeError(), function() { navigator.sendBeacon(invalidUrl, smallPayload); },
`calling 'navigator.sendBeacon()' with an invalid URL '${invalidUrl}' must throw a TypeError`);
}, "Verify calling 'navigator.sendBeacon()' with an invalid URL throws an exception.");
test(function() {
var invalidUrl = "nothttp://invalid.url";
assert_throws(new TypeError(), function() { navigator.sendBeacon(invalidUrl, smallPayload); },
`calling 'navigator.sendBeacon()' with a non-http(s) URL '${invalidUrl}' must throw a TypeError`);
}, "Verify calling 'navigator.sendBeacon()' with a URL that is not a http(s) scheme throws an exception.");
// We'll validate that we can send one beacon that uses our entire Quota and then fail to send one that is just one char.
promise_test(async () => {
function wait(ms) {
return new Promise(res => step_timeout(res, ms));
}
const url = '/fetch/api/resources/trickle.py?count=1&ms=0';
assert_true(navigator.sendBeacon(url, maxPayload),
"calling 'navigator.sendBeacon()' with our max payload size should succeed.");
// Now we'll send just one character.
assert_false(navigator.sendBeacon(url, '1'),
"calling 'navigator.sendBeacon()' with just one char should fail while our Quota is used up.");
for (let i = 0; i < 20; ++i) {
await wait(100);
if (navigator.sendBeacon(url, maxPayload)) {
return;
}
}
assert_unreached('The quota should recover after fetching.');
}, "Verify the behavior after the quota is exhausted.");
done();
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...