diff --git a/extensions/amp-access/0.1/test/test-jwt.js b/extensions/amp-access/0.1/test/test-jwt.js index f69a40c97c41..e071273abfe5 100644 --- a/extensions/amp-access/0.1/test/test-jwt.js +++ b/extensions/amp-access/0.1/test/test-jwt.js @@ -184,7 +184,6 @@ describe('JwtHelper', () => { windowApi = { crypto: {subtle}, - services: {}, }; helper = new JwtHelper(windowApi); }); diff --git a/src/3p-frame.js b/src/3p-frame.js index 7ff95b36d684..5e8132ccb49e 100644 --- a/src/3p-frame.js +++ b/src/3p-frame.js @@ -236,7 +236,7 @@ export function setDefaultBootstrapBaseUrlForTesting(url) { * @param {*} win */ export function resetBootstrapBaseUrlForTesting(win) { - win.defaultBootstrapSubDomain = undefined; + win.__AMP_DEFAULT_BOOTSTRAP_SUBDOMAIN = undefined; // eslint-disable-line google-camelcase/google-camelcase } /** @@ -251,11 +251,12 @@ export function getDefaultBootstrapBaseUrl(parentWindow, opt_srcFileBasename) { return getDevelopmentBootstrapBaseUrl(parentWindow, srcFileBasename); } // Ensure same sub-domain is used despite potentially different file. - parentWindow.defaultBootstrapSubDomain = - parentWindow.defaultBootstrapSubDomain || getSubDomain(parentWindow); + parentWindow.__AMP_DEFAULT_BOOTSTRAP_SUBDOMAIN = // eslint-disable-line google-camelcase/google-camelcase + parentWindow.__AMP_DEFAULT_BOOTSTRAP_SUBDOMAIN || + getSubDomain(parentWindow); return ( 'https://' + - parentWindow.defaultBootstrapSubDomain + + parentWindow.__AMP_DEFAULT_BOOTSTRAP_SUBDOMAIN + `.${urls.thirdPartyFrameHost}/${internalRuntimeVersion()}/` + `${srcFileBasename}.html` ); diff --git a/src/experiments.js b/src/experiments.js index 3a609d4c189a..0dd946fb437f 100644 --- a/src/experiments.js +++ b/src/experiments.js @@ -305,7 +305,7 @@ function selectRandomItem(arr) { * * Check whether a given experiment is set using isExperimentOn(win, * experimentName) and, if it is on, look for which branch is selected in - * win.experimentBranches[experimentName]. + * win.__AMP_EXPERIMENT_BRANCHES[experimentName]. * * @param {!Window} win Window context on which to save experiment * selection state. @@ -315,7 +315,7 @@ function selectRandomItem(arr) { * branches. */ export function randomlySelectUnsetExperiments(win, experiments) { - win.experimentBranches = win.experimentBranches || {}; + win.__AMP_EXPERIMENT_BRANCHES = win.__AMP_EXPERIMENT_BRANCHES || {}; const selectedExperiments = {}; for (const experimentName in experiments) { // Skip experimentName if it is not a key of experiments object or if it @@ -323,9 +323,9 @@ export function randomlySelectUnsetExperiments(win, experiments) { if (!hasOwn(experiments, experimentName)) { continue; } - if (hasOwn(win.experimentBranches, experimentName)) { + if (hasOwn(win.__AMP_EXPERIMENT_BRANCHES, experimentName)) { selectedExperiments[experimentName] = - win.experimentBranches[experimentName]; + win.__AMP_EXPERIMENT_BRANCHES[experimentName]; continue; } @@ -333,7 +333,7 @@ export function randomlySelectUnsetExperiments(win, experiments) { !experiments[experimentName].isTrafficEligible || !experiments[experimentName].isTrafficEligible(win) ) { - win.experimentBranches[experimentName] = null; + win.__AMP_EXPERIMENT_BRANCHES[experimentName] = null; continue; } @@ -341,13 +341,15 @@ export function randomlySelectUnsetExperiments(win, experiments) { // experiment branch (e.g., via a test setup), then randomize the branch // choice. if ( - !win.experimentBranches[experimentName] && + !win.__AMP_EXPERIMENT_BRANCHES[experimentName] && isExperimentOn(win, /*OK*/ experimentName) ) { const {branches} = experiments[experimentName]; - win.experimentBranches[experimentName] = selectRandomItem(branches); + win.__AMP_EXPERIMENT_BRANCHES[experimentName] = selectRandomItem( + branches + ); selectedExperiments[experimentName] = - win.experimentBranches[experimentName]; + win.__AMP_EXPERIMENT_BRANCHES[experimentName]; } } return selectedExperiments; @@ -363,7 +365,9 @@ export function randomlySelectUnsetExperiments(win, experiments) { * null if experimentName has been tested but no branch was enabled). */ export function getExperimentBranch(win, experimentName) { - return win.experimentBranches ? win.experimentBranches[experimentName] : null; + return win.__AMP_EXPERIMENT_BRANCHES + ? win.__AMP_EXPERIMENT_BRANCHES[experimentName] + : null; } /** @@ -377,7 +381,7 @@ export function getExperimentBranch(win, experimentName) { * @visibleForTesting */ export function forceExperimentBranch(win, experimentName, branchId) { - win.experimentBranches = win.experimentBranches || {}; + win.__AMP_EXPERIMENT_BRANCHES = win.__AMP_EXPERIMENT_BRANCHES || {}; toggleExperiment(win, experimentName, !!branchId, true); - win.experimentBranches[experimentName] = branchId; + win.__AMP_EXPERIMENT_BRANCHES[experimentName] = branchId; } diff --git a/src/log.js b/src/log.js index a3cedcdacd07..d106e7e3c056 100644 --- a/src/log.js +++ b/src/log.js @@ -711,13 +711,13 @@ export function rethrowAsync(var_args) { * on Log and closure literally can't even. * @type {{user: ?Log, dev: ?Log, userForEmbed: ?Log}} */ -self.log = self.log || { +self.__AMP_LOG = self.__AMP_LOG || { user: null, dev: null, userForEmbed: null, }; -const logs = self.log; +const logs = self.__AMP_LOG; /** * Eventually holds a constructor for Log objects. Lazily initialized, so we diff --git a/test/unit/test-experiments.js b/test/unit/test-experiments.js index e9fab0ff3bf1..ea21231ba438 100644 --- a/test/unit/test-experiments.js +++ b/test/unit/test-experiments.js @@ -617,7 +617,7 @@ describe('experiment branch tests', () => { isExperimentOn(sandbox.win, 'testExperimentId'), 'experiment is on' ).to.be.false; - expect(sandbox.win.experimentBranches).to.be.empty; + expect(sandbox.win.__AMP_EXPERIMENT_BRANCHES).to.be.empty; }); it('handles experiment not diverted path', () => {