mirror of
				https://github.com/mozilla/gecko-dev.git
				synced 2025-11-04 10:18:41 +02:00 
			
		
		
		
	Automatic update from web-platform-testsRe-enable the Background Fetch WPT tests The flaky crashes should have been fixed now that the associated logic has been removed from the scheduler. https://chromium-review.googlesource.com/c/chromium/src/+/1165554 Bug: 869470, 869818 Change-Id: Ie077876289a28387e5f890e9a25abe5609857c14 Reviewed-on: https://chromium-review.googlesource.com/1170909 Commit-Queue: Peter Beverloo <peter@chromium.org> Reviewed-by: Rayan Kanso <rayankans@chromium.org> Reviewed-by: Mugdha Lakhani <nator@chromium.org> Cr-Commit-Position: refs/heads/master@{#583729} -- wpt-commits: f4cfe41feec71829ec58aa0bf8ef3b8bf489dc7f wpt-pr: 12533
		
			
				
	
	
		
			45 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
// META: script=/service-workers/service-worker/resources/test-helpers.sub.js
 | 
						|
// META: script=resources/utils.js
 | 
						|
'use strict';
 | 
						|
 | 
						|
// Covers functionality provided by BackgroundFetchManager.getIds(), which
 | 
						|
// exposes the keys of active background fetches.
 | 
						|
//
 | 
						|
// https://wicg.github.io/background-fetch/#background-fetch-manager-getIds
 | 
						|
 | 
						|
promise_test(async test => {
 | 
						|
  const script = 'service_workers/sw.js';
 | 
						|
  const scope = 'service_workers/' + location.pathname;
 | 
						|
 | 
						|
  const serviceWorkerRegistration =
 | 
						|
      await service_worker_unregister_and_register(test, script, scope);
 | 
						|
 | 
						|
  assert_equals(
 | 
						|
      serviceWorkerRegistration.active, null,
 | 
						|
      'There must not be an activated worker');
 | 
						|
 | 
						|
  const ids = await serviceWorkerRegistration.backgroundFetch.getIds();
 | 
						|
  assert_equals(ids.length, 0);
 | 
						|
 | 
						|
}, 'BackgroundFetchManager.getIds() does not require an activated worker');
 | 
						|
 | 
						|
backgroundFetchTest(async (test, backgroundFetch) => {
 | 
						|
  // There should not be any active background fetches at this point.
 | 
						|
  {
 | 
						|
    const ids = await backgroundFetch.getIds();
 | 
						|
    assert_equals(ids.length, 0);
 | 
						|
  }
 | 
						|
 | 
						|
  const registrationId = uniqueId();
 | 
						|
  const registration =
 | 
						|
      await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
 | 
						|
  assert_equals(registration.id, registrationId);
 | 
						|
 | 
						|
  // The |registrationId| should be active, and thus be included in getIds().
 | 
						|
  {
 | 
						|
    const ids = await backgroundFetch.getIds();
 | 
						|
    assert_equals(ids.length, 1);
 | 
						|
    assert_equals(ids[0], registrationId);
 | 
						|
  }
 | 
						|
 | 
						|
}, 'The BackgroundFetchManager exposes active fetches');
 |