* Ensures that the experiments have been initialized and returns them. * @param {!Window} win * @return {!Object }
(win)
| 7484 | * @return {!Object<string, boolean>} |
| 7485 | */ |
| 7486 | function getExperiments(win) { |
| 7487 | if (!experimentMap) { |
| 7488 | experimentMap = {}; |
| 7489 | let combinedExperimentString = experimentsString; |
| 7490 | try { |
| 7491 | const query = parseQueryString(win.location.hash); |
| 7492 | const experimentStringFromHash = query['swg.experiments']; |
| 7493 | if (experimentStringFromHash) { |
| 7494 | combinedExperimentString += ',' + experimentStringFromHash; |
| 7495 | } |
| 7496 | } catch (e) { |
| 7497 | // Ignore: experiment parsing cannot block runtime. |
| 7498 | ErrorUtils.throwAsync(e); |
| 7499 | } |
| 7500 | |
| 7501 | // Format: |
| 7502 | // - experimentString = (experimentSpec,)* |
| 7503 | for (let experimentString of combinedExperimentString.split(',')) { |
| 7504 | experimentString = experimentString.trim(); |
| 7505 | if (!experimentString) { |
| 7506 | continue; |
| 7507 | } |
| 7508 | try { |
| 7509 | parseSetExperiment(win, experimentMap, experimentString); |
| 7510 | } catch (e) { |
| 7511 | // Ignore: experiment parsing cannot block runtime. |
| 7512 | ErrorUtils.throwAsync(e); |
| 7513 | } |
| 7514 | } |
| 7515 | } |
| 7516 | return experimentMap; |
| 7517 | } |
| 7518 | |
| 7519 | /** |
| 7520 | * @param {!Window} win |
no test coverage detected