Skip to content

Commit

Permalink
Merge pull request #74 from GoogleChrome/openpopup-condition
Browse files Browse the repository at this point in the history
Prefer features without `location` condition
  • Loading branch information
oliverdunk authored Jun 6, 2024
2 parents 318431a + 5cdcf00 commit 3636fed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/lib/feature-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ test('extension features are preferred', (t) => {
{ channel: 'stable', min_manifest_version: 3, extension_types: ['extension'] }
);
});

test('non-location specific features are preferred', (t) => {
const featureQuery = new FeatureQuery({});

t.deepEqual(
featureQuery.mergeComplexFeature([
{ channel: 'stable', feature_flag: 'my_feature_flag' },
{ channel: 'stable', location: 'policy' }
]),
{ channel: 'stable', feature_flag: 'my_feature_flag' }
);
});
7 changes: 7 additions & 0 deletions tools/lib/feature-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ export class FeatureQuery {
return extensionFilter[0];
}

// If the availability differs based on install location, use the default
// (non policy / component extension) data.
const locationFilter = q.filter(({ location }) => !location);
if (locationFilter.length === 1) {
return locationFilter[0];
}

// Features that are unclear here will throw.
}

Expand Down

0 comments on commit 3636fed

Please sign in to comment.