MCPcopy
hub / github.com/ampproject/amphtml / isExperimentOn_

Function isExperimentOn_

tools/experiments/experiments.js:259–273  ·  view source on GitHub ↗

* Returns whether the experiment is on or off. * @param {string} id * @return {boolean}

(id)

Source from the content-addressed store, hash-verified

257 * @return {boolean}
258 */
259function isExperimentOn_(id) {
260 const optInCookieValue = getCookie(window, '__Host-AMP_OPT_IN');
261 switch (id) {
262 case EXPERIMENTAL_CHANNEL_ID:
263 return optInCookieValue == AMP_OPT_IN_COOKIE.EXPERIMENTAL;
264 case BETA_CHANNEL_ID:
265 return optInCookieValue == AMP_OPT_IN_COOKIE.BETA;
266 case NIGHTLY_CHANNEL_ID:
267 return optInCookieValue == AMP_OPT_IN_COOKIE.NIGHTLY;
268 case RTV_CHANNEL_ID:
269 return RTV_PATTERN.test(optInCookieValue);
270 default:
271 return isExperimentOn(window, /*OK*/ id);
272 }
273}
274
275/**
276 * Opts in to / out of the pre-release channels or a specific RTV by setting the

Callers 3

buildFunction · 0.85
updateExperimentRowFunction · 0.85
toggleExperiment_Function · 0.85

Calls 3

getCookieFunction · 0.90
isExperimentOnFunction · 0.50
testMethod · 0.45

Tested by

no test coverage detected