Features are files stored in the features/
directory that must include an init
function and optionally update
and load
methods as explained in the Features Lifecycle.
The ConfigFeature class is extended by each feature to implement remote config handling. It provides the following methods:
getFeatureSettingEnabled()
For simple boolean settings, returns true
if the setting is 'enabled'
getFeatureSetting()
Returns a specific setting from the feature settings
recomputeSiteObject()
Recomputes the site object for the feature, e.g. when the URL has changed
The ConfigFeature
class is also exportable and can be used by other scripts to build C-S-S like features that can handle remote configuration - currently used in autofill.js to handle site specific autofill rules.
Create a new content scope features file in src/features/
and register it in features.js.
Add the feature name to the features.js array.
Add breakage debug flags at appropriate places by calling ContentFeature.addDebugFlag()
. This will help identify anomalies in breakage reports.
There are three stages that the content scope code is hooked into the platform:
load
init
update
When developing features that modify web pages, add debug flags at appropriate times to help identify anomalies in breakage reports:
ContentFeature.addDebugFlag();
Key principles for feature development:
window
or other globals should be avoided (pages could define same names)All features that modify web pages should use Privacy Remote Configuration where feasible. This allows:
The ConfigFeature
class provides the infrastructure for this through getFeatureSettingEnabled()
and getFeatureSetting()
methods.