You are here

public function DisableFlocTest::testDisableFloc in Analytics 8

Tests adding the Permissions-Policy header.

File

tests/src/Functional/DisableFlocTest.php, line 30

Class

DisableFlocTest
Tests disabling FLoC via response header.

Namespace

Drupal\Tests\analytics\Functional

Code

public function testDisableFloc() {
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->responseHeaderEquals('Permissions-Policy', NULL);
  $account = $this
    ->createUser([
    'administer analytics',
  ]);
  $this
    ->drupalLogin($account);
  $this
    ->drupalPostForm('admin/config/services/analytics/settings', [
    'privacy[disable_floc]' => TRUE,
  ], 'Save configuration');

  // Log out the user to test that the page cache was invalidated.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->responseHeaderEquals('Permissions-Policy', 'interest-cohort=()');
}