Skip to content

Commit

Permalink
Bug 1705222 [wpt PR 28484] - Background Fetch: use permission context…
Browse files Browse the repository at this point in the history
… directly when initiating fetch., a=testonly

Automatic update from web-platform-tests
Background Fetch: use permission context directly when initiating fetch.

This reduces duplicated logic between BackgroundFetchDelegateImpl and
BackgroundFetchPermissionContext. It also forces the logic to align.
Specifically, the permission context returned ALLOW when automatic DLs
were allowed, but the implementation enforced ASK even if auto DLs
are allowed.

This temporarily regresses WebLayer because there's no
Background Fetch permission context there, but that will be addressed
soon.

Bug: 1189247, 1057770
Change-Id: I5441f00835c186826927d2ef38612c8e55eb049f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2800512
Commit-Queue: Evan Stade <[email protected]>
Reviewed-by: Nasko Oskov <[email protected]>
Reviewed-by: Mugdha Lakhani <[email protected]>
Cr-Commit-Position: refs/heads/master@{#872641}

--

wpt-commits: c7646854131fe696fa38ae8b5e3e611dc6f52d19
wpt-pr: 28484
  • Loading branch information
Evan Stade authored and moz-wptsync-bot committed Apr 23, 2021
1 parent 0b5264d commit 0137909
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions testing/web-platform/tests/background-fetch/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

let nextBackgroundFetchId = 0;

function loadScript(path) {
let script = document.createElement('script');
let promise = new Promise(resolve => script.onload = resolve);
script.src = path;
script.async = false;
document.head.appendChild(script);
return promise;
}

// Waits for a single message received from a registered Service Worker.
async function getMessageFromServiceWorker() {
return new Promise(resolve => {
Expand Down Expand Up @@ -39,6 +48,13 @@ async function registerAndActivateServiceWorker(test, name) {
// directory to register.
function backgroundFetchTest(func, description, workerName = 'sw.js') {
promise_test(async t => {
if (typeof test_driver === 'undefined') {
await loadScript('/resources/testdriver.js');
await loadScript('/resources/testdriver-vendor.js');
}

await test_driver.set_permission({name: 'background-fetch'}, 'granted');

const serviceWorkerRegistration =
await registerAndActivateServiceWorker(t, workerName);
serviceWorkerRegistration.active.postMessage(null);
Expand Down

0 comments on commit 0137909

Please sign in to comment.