Skip to content

Commit

Permalink
Add FLOC to default directives and set its rule to none.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Leo-Pernold committed Oct 25, 2024
1 parent 721deb5 commit 02112c0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Directive.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ abstract class Directive implements DirectiveContract
final public const ENCRYPTED_MEDIA = 'encrypted-media';
final public const EXECUTION_WHILE_NOT_RENDERED = 'execution-while-not-rendered';
final public const EXECUTION_WHILE_OUT_OF_VIEWPORT = 'execution-while-out-of-viewport';
final public const FLOC = 'interest-cohort';
final public const FULLSCREEN = 'fullscreen';
final public const GEOLOCATION = 'geolocation';
final public const GYROSCOPE = 'gyroscope';
Expand Down
27 changes: 27 additions & 0 deletions src/FeatureGroups/DefaultFeatureGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Mazedlx\FeaturePolicy\Directive;
use Mazedlx\FeaturePolicy\Exceptions\UnsupportedPermissionException;
use Mazedlx\FeaturePolicy\Value;

final class DefaultFeatureGroup implements FeatureGroupContract
{
Expand Down Expand Up @@ -604,6 +605,32 @@ public function note(): string
return 'To enable these, use the Chrome command line flag --enable-blink-features=ExperimentalProductivityFeatures.';
}
},
Directive::FLOC => (new class extends Directive {
public function name(): string
{
return Directive::FLOC;
}

public function specificationName(): string
{
return 'Federated Learning of Cohorts';
}

public function specificationUrl(): string
{
return 'https://github.com/WICG/floc';
}

public function browserSupport(): string
{
return 'Chrome 90';
}

public function browserSupportUrl(): string
{
return '';
}
})->addRule(Value::NONE),
Directive::FULLSCREEN => new class extends Directive {
public function name(): string
{
Expand Down
9 changes: 9 additions & 0 deletions tests/DirectiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@ public function xr_spatial_tracking_adds_the_correct_header_directive_instead_of
$directive = Directive::make(Directive::XR_SPATIAL_TRACKING);
$this->assertSame(Directive::XR_SPATIAL_TRACKING, $directive->name());
}

#[Test]
public function floc_is_disabled_by_default()
{
$directive = Directive::make(Directive::FLOC);
$this->assertNotEmpty($directive->rules());
$this->assertCount(1, $directive->rules());
$this->assertSame(Value::NONE, $directive->rules()[0]);
}
}

0 comments on commit 02112c0

Please sign in to comment.