diff --git a/3p/integration.js b/3p/integration.js index e05000c8ead5..571f68612b62 100644 --- a/3p/integration.js +++ b/3p/integration.js @@ -566,7 +566,7 @@ function init(win) { const config = getAmpConfig(); // Overriding to short-circuit src/mode#getMode() - win.AMP_MODE = config.mode; + win.__AMP_MODE = config.mode; setReportError(console.error.bind(console)); diff --git a/extensions/amp-a4a/0.1/test/test-amp-a4a.js b/extensions/amp-a4a/0.1/test/test-amp-a4a.js index 6844b3b4b1f9..d056b9cf237b 100644 --- a/extensions/amp-a4a/0.1/test/test-amp-a4a.js +++ b/extensions/amp-a4a/0.1/test/test-amp-a4a.js @@ -2579,7 +2579,7 @@ describe('amp-a4a', () => { }); it('should create an error if needed', () => { - window.AMP_MODE = {development: true}; + window.__AMP_MODE = {development: true}; a4a.promiseErrorHandler_('intentional'); expect(userErrorStub).to.be.calledOnce; expect(userErrorStub.args[0][1]).to.be.instanceOf(Error); @@ -2588,7 +2588,7 @@ describe('amp-a4a', () => { }); it('should configure ignoreStack when specified', () => { - window.AMP_MODE = {development: true}; + window.__AMP_MODE = {development: true}; a4a.promiseErrorHandler_('intentional', /* ignoreStack */ true); expect(userErrorStub).to.be.calledOnce; expect(userErrorStub.args[0][1]).to.be.instanceOf(Error); @@ -2598,7 +2598,7 @@ describe('amp-a4a', () => { it('should route error to user.error in dev mode', () => { const error = new Error('intentional'); - window.AMP_MODE = {development: true}; + window.__AMP_MODE = {development: true}; a4a.promiseErrorHandler_(error); expect(userErrorStub).to.be.calledOnce; expect(userErrorStub.args[0][1]).to.be.equal(error); @@ -2609,7 +2609,7 @@ describe('amp-a4a', () => { it('should route error to user.warn in prod mode', () => { const error = new Error('intentional'); - window.AMP_MODE = {development: false}; + window.__AMP_MODE = {development: false}; a4a.promiseErrorHandler_(error); expect(userWarnStub).to.be.calledOnce; expect(userWarnStub.args[0][1]).to.be.equal(error); @@ -2620,7 +2620,7 @@ describe('amp-a4a', () => { it('should send an expected error in prod mode with sampling', () => { const error = new Error('intentional'); sandbox.stub(Math, 'random').callsFake(() => 0.005); - window.AMP_MODE = {development: false}; + window.__AMP_MODE = {development: false}; a4a.promiseErrorHandler_(error); expect(devExpectedErrorStub).to.be.calledOnce; expect(devExpectedErrorStub.args[0][1]).to.be.equal(error); @@ -2631,7 +2631,7 @@ describe('amp-a4a', () => { it('should NOT send an expected error in prod mode with sampling', () => { const error = new Error('intentional'); sandbox.stub(Math, 'random').callsFake(() => 0.011); - window.AMP_MODE = {development: false}; + window.__AMP_MODE = {development: false}; a4a.promiseErrorHandler_(error); expect(devExpectedErrorStub).to.not.be.called; }); @@ -2932,7 +2932,7 @@ describes.realWin('AmpA4a-RTC', {amp: true}, env => { beforeEach(() => { sandbox = env.sandbox; // ensures window location == AMP cache passes - env.win.AMP_MODE.test = true; + env.win.__AMP_MODE.test = true; const doc = env.win.document; element = createElementWithAttributes(env.win.document, 'amp-ad', { 'width': '200', diff --git a/extensions/amp-a4a/0.1/test/test-amp-ad-template-helper.js b/extensions/amp-a4a/0.1/test/test-amp-ad-template-helper.js index afad52d41ed0..7fb8cd063cce 100644 --- a/extensions/amp-a4a/0.1/test/test-amp-ad-template-helper.js +++ b/extensions/amp-a4a/0.1/test/test-amp-ad-template-helper.js @@ -30,7 +30,7 @@ describes.fakeWin('AmpAdTemplateHelper', {amp: true}, env => { beforeEach(() => { win = env.win; - win.AMP_MODE = {localDev: false}; + win.__AMP_MODE = {localDev: false}; doc = win.document; fetchTextMock = sandbox.stub(Xhr.prototype, 'fetchText'); ampAdTemplateHelper = new AmpAdTemplateHelper(win); diff --git a/extensions/amp-a4a/0.1/test/test-real-time-config-manager.js b/extensions/amp-a4a/0.1/test/test-real-time-config-manager.js index fe999677fc71..bc1beb7a3d4d 100644 --- a/extensions/amp-a4a/0.1/test/test-real-time-config-manager.js +++ b/extensions/amp-a4a/0.1/test/test-real-time-config-manager.js @@ -44,7 +44,7 @@ describes.realWin('real-time-config-manager', {amp: true}, env => { sandbox = env.sandbox; // Ensures window location == AMP cache passes. - env.win.AMP_MODE.test = true; + env.win.__AMP_MODE.test = true; const doc = env.win.document; element = createElementWithAttributes(env.win.document, 'amp-ad', { diff --git a/extensions/amp-ad-network-adzerk-impl/0.1/test/test-amp-ad-network-adzerk-impl.js b/extensions/amp-ad-network-adzerk-impl/0.1/test/test-amp-ad-network-adzerk-impl.js index 976d6775e091..67b02021c665 100644 --- a/extensions/amp-ad-network-adzerk-impl/0.1/test/test-amp-ad-network-adzerk-impl.js +++ b/extensions/amp-ad-network-adzerk-impl/0.1/test/test-amp-ad-network-adzerk-impl.js @@ -35,7 +35,7 @@ describes.fakeWin('amp-ad-network-adzerk-impl', {amp: true}, env => { beforeEach(() => { win = env.win; - win.AMP_MODE = {localDev: false}; + win.__AMP_MODE = {localDev: false}; win.AMP.registerTemplate('amp-mustache', AmpMustache); doc = win.document; fetchTextMock = sandbox.stub(Xhr.prototype, 'fetchText'); diff --git a/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-fluid.js b/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-fluid.js index 97ac919d3c0d..c2e3ee8a5169 100644 --- a/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-fluid.js +++ b/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-fluid.js @@ -101,7 +101,7 @@ describes.realWin('DoubleClick Fast Fetch Fluid', realWinConfig, env => { beforeEach(() => { sandbox = env.sandbox; - env.win.AMP_MODE.test = true; + env.win.__AMP_MODE.test = true; const doc = env.win.document; // TODO(a4a-cam@): This is necessary in the short term, until A4A is // smarter about host document styling. The issue is that it needs to diff --git a/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-rtc.js b/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-rtc.js index 259e9025e871..3850a184fb8b 100644 --- a/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-rtc.js +++ b/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-rtc.js @@ -32,7 +32,7 @@ describes.realWin('DoubleClick Fast Fetch RTC', {amp: true}, env => { beforeEach(() => { sandbox = env.sandbox; - env.win.AMP_MODE.test = true; + env.win.__AMP_MODE.test = true; const doc = env.win.document; // TODO(a4a-cam@): This is necessary in the short term, until A4A is // smarter about host document styling. The issue is that it needs to diff --git a/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-safeframe.js b/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-safeframe.js index df440aeac905..9fedaa2845ac 100644 --- a/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-safeframe.js +++ b/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-safeframe.js @@ -58,7 +58,7 @@ describes.realWin('DoubleClick Fast Fetch - Safeframe', realWinConfig, env => { beforeEach(() => { sandbox = env.sandbox; - env.win.AMP_MODE.test = true; + env.win.__AMP_MODE.test = true; doc = env.win.document; setup(ampAdHeight, ampAdWidth, ampAdHeight, ampAdWidth); }); diff --git a/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-sra.js b/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-sra.js index 0730745622e1..dc3682ac3171 100644 --- a/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-sra.js +++ b/extensions/amp-ad-network-doubleclick-impl/0.1/test/test-doubleclick-sra.js @@ -71,7 +71,7 @@ describes.realWin('Doubleclick SRA', config, env => { doc = env.win.document; sandbox = env.sandbox; // ensures window location == AMP cache passes - env.win.AMP_MODE.test = true; + env.win.__AMP_MODE.test = true; }); function createAndAppendAdElement(opt_attributes, opt_type, opt_domElement) { diff --git a/extensions/amp-analytics/0.1/test/test-amp-analytics.js b/extensions/amp-analytics/0.1/test/test-amp-analytics.js index 23ea73b098ce..df3828200600 100644 --- a/extensions/amp-analytics/0.1/test/test-amp-analytics.js +++ b/extensions/amp-analytics/0.1/test/test-amp-analytics.js @@ -1785,7 +1785,7 @@ describes.realWin( } it('does send a hit when parentPostMessage is provided inabox', function() { - env.win.AMP_MODE.runtime = 'inabox'; + env.win.__AMP_MODE.runtime = 'inabox'; const analytics = getAnalyticsTag({ 'requests': {'foo': 'https://example.com/bar'}, 'triggers': [{'on': 'visible', 'parentPostMessage': 'foo'}], @@ -1813,7 +1813,7 @@ describes.realWin( }); it('not send when request and parentPostMessage are not provided', function() { - env.win.AMP_MODE.runtime = 'inabox'; + env.win.__AMP_MODE.runtime = 'inabox'; expectAsyncConsoleError(onAndRequestAttributesInaboxError); const analytics = getAnalyticsTag({ 'requests': {'foo': 'https://example.com/bar'}, @@ -1826,7 +1826,7 @@ describes.realWin( }); it('send when request and parentPostMessage are provided', function() { - env.win.AMP_MODE.runtime = 'inabox'; + env.win.__AMP_MODE.runtime = 'inabox'; const analytics = getAnalyticsTag({ 'requests': {'foo': 'https://example.com/bar'}, 'triggers': [ @@ -1868,7 +1868,7 @@ describes.realWin( }); it('is 0 for inabox', () => { - env.win.AMP_MODE.runtime = 'inabox'; + env.win.__AMP_MODE.runtime = 'inabox'; expect(getAnalyticsTag(getConfig()).getLayoutPriority()).to.equal( LayoutPriority.CONTENT ); diff --git a/extensions/amp-analytics/0.1/test/test-analytics-root.js b/extensions/amp-analytics/0.1/test/test-analytics-root.js index a97c8e80f4d3..f4b5f19ec369 100644 --- a/extensions/amp-analytics/0.1/test/test-analytics-root.js +++ b/extensions/amp-analytics/0.1/test/test-analytics-root.js @@ -119,7 +119,7 @@ describes.realWin('AmpdocAnalyticsRoot', {amp: 1}, env => { }); it('should provide the correct rect for ini-load for inabox', () => { - win.AMP_MODE = {runtime: 'inabox'}; + win.__AMP_MODE = {runtime: 'inabox'}; sandbox.stub(viewport, 'getLayoutRect').callsFake(element => { if (element == win.document.documentElement) { return {left: 10, top: 11, width: 100, height: 200}; diff --git a/extensions/amp-analytics/0.1/test/test-cookie-writer.js b/extensions/amp-analytics/0.1/test/test-cookie-writer.js index fa3b7fabe4b3..7f1293c87ccf 100644 --- a/extensions/amp-analytics/0.1/test/test-cookie-writer.js +++ b/extensions/amp-analytics/0.1/test/test-cookie-writer.js @@ -115,7 +115,7 @@ describes.realWin( }); it('Resolve when in inabox ad', () => { - env.win.AMP_MODE.runtime = 'inabox'; + env.win.__AMP_MODE.runtime = 'inabox'; const config = dict({ 'cookies': { 'testId': { diff --git a/extensions/amp-analytics/0.1/test/test-transport.js b/extensions/amp-analytics/0.1/test/test-transport.js index 6608a7ca6bfe..7ce53bd2d129 100644 --- a/extensions/amp-analytics/0.1/test/test-transport.js +++ b/extensions/amp-analytics/0.1/test/test-transport.js @@ -426,8 +426,8 @@ describes.realWin( }); it('initialize iframe transport when used with inabox', () => { - win.AMP_MODE = win.AMP_MODE || {}; - win.AMP_MODE.runtime = 'inabox'; + win.__AMP_MODE = win.__AMP_MODE || {}; + win.__AMP_MODE.runtime = 'inabox'; expect(getMode(win).runtime).to.equal('inabox'); const transport = new Transport(win, { diff --git a/extensions/amp-analytics/0.1/test/test-variables.js b/extensions/amp-analytics/0.1/test/test-variables.js index 8773b6feb228..7bec6b06d955 100644 --- a/extensions/amp-analytics/0.1/test/test-variables.js +++ b/extensions/amp-analytics/0.1/test/test-variables.js @@ -387,7 +387,7 @@ describes.fakeWin('amp-analytics.VariableService', {amp: true}, env => { it('COOKIE resolves to empty string when inabox', async () => { doc.cookie = 'test=123'; - env.win.AMP_MODE.runtime = 'inabox'; + env.win.__AMP_MODE.runtime = 'inabox'; await check('COOKIE(test)', ''); doc.cookie = ''; }); diff --git a/extensions/amp-analytics/0.1/test/test-visibility-manager.js b/extensions/amp-analytics/0.1/test/test-visibility-manager.js index 35f2e3df936f..7731a5bdcfd6 100644 --- a/extensions/amp-analytics/0.1/test/test-visibility-manager.js +++ b/extensions/amp-analytics/0.1/test/test-visibility-manager.js @@ -150,7 +150,7 @@ describes.fakeWin('VisibilityManagerForDoc', {amp: true}, env => { }); it('should resolve root layout box for in-a-box', () => { - win.AMP_MODE = {runtime: 'inabox'}; + win.__AMP_MODE = {runtime: 'inabox'}; root = new VisibilityManagerForDoc(ampdoc); const rootElement = win.document.documentElement; sandbox.stub(viewport, 'getLayoutRect').callsFake(element => { @@ -186,7 +186,7 @@ describes.fakeWin('VisibilityManagerForDoc', {amp: true}, env => { }); it('should switch visibility for in-a-box', () => { - win.AMP_MODE = {runtime: 'inabox'}; + win.__AMP_MODE = {runtime: 'inabox'}; root = new VisibilityManagerForDoc(ampdoc); // Check observer is correctly set. diff --git a/extensions/amp-bind/0.1/test/integration/test-bind-impl.js b/extensions/amp-bind/0.1/test/integration/test-bind-impl.js index a2507ab7e1d9..c02e869dee7c 100644 --- a/extensions/amp-bind/0.1/test/integration/test-bind-impl.js +++ b/extensions/amp-bind/0.1/test/integration/test-bind-impl.js @@ -510,7 +510,7 @@ describe }); it('should verify class bindings in dev mode', () => { - window.AMP_MODE = {development: true, test: true}; + window.__AMP_MODE = {development: true, test: true}; createElement(env, container, '[class]="\'foo\'" class="foo"'); createElement(env, container, '[class]="\'foo\'" class=" foo "'); createElement(env, container, '[class]="\'\'"'); @@ -523,7 +523,7 @@ describe }); it('should verify string attribute bindings in dev mode', () => { - window.AMP_MODE = {development: true, test: true}; + window.__AMP_MODE = {development: true, test: true}; // Only the initial value for [a] binding does not match. createElement( env, @@ -538,7 +538,7 @@ describe }); it('should verify boolean attribute bindings in dev mode', () => { - window.AMP_MODE = {development: true, test: true}; + window.__AMP_MODE = {development: true, test: true}; createElement(env, container, '[disabled]="true" disabled', 'button'); createElement(env, container, '[disabled]="false"', 'button'); createElement(env, container, '[disabled]="true"', 'button'); // Mismatch. diff --git a/extensions/amp-geo/0.1/test/test-amp-geo.js b/extensions/amp-geo/0.1/test/test-amp-geo.js index 2d4909398cb2..3bc323220812 100644 --- a/extensions/amp-geo/0.1/test/test-amp-geo.js +++ b/extensions/amp-geo/0.1/test/test-amp-geo.js @@ -82,7 +82,7 @@ describes.realWin( }); afterEach(() => { - delete win.AMP_MODE.geoOverride; + delete win.__AMP_MODE.geoOverride; }); function addConfigElement(opt_elementName, opt_type, opt_textContent) { @@ -171,7 +171,7 @@ describes.realWin( }); it('should allow hash to override geo in test', () => { - win.AMP_MODE.geoOverride = 'nz'; + win.__AMP_MODE.geoOverride = 'nz'; addConfigElement('script'); geo.buildCallback(); @@ -192,7 +192,7 @@ describes.realWin( }); it('should allow preset country groups', () => { - win.AMP_MODE.geoOverride = 'fr'; + win.__AMP_MODE.geoOverride = 'fr'; addConfigElement('script'); geo.buildCallback(); @@ -207,7 +207,7 @@ describes.realWin( }); it('should set amp-geo-no-group if no group matches', () => { - win.AMP_MODE.geoOverride = 'za'; + win.__AMP_MODE.geoOverride = 'za'; addConfigElement('script'); geo.buildCallback(); @@ -226,7 +226,7 @@ describes.realWin( }); it('should return configured and matched groups in `geo` service', () => { - win.AMP_MODE.geoOverride = 'nz'; + win.__AMP_MODE.geoOverride = 'nz'; addConfigElement('script'); geo.buildCallback(); @@ -240,7 +240,7 @@ describes.realWin( }); it('isInCountryGroup works with multiple group targets', () => { - win.AMP_MODE.geoOverride = 'nz'; + win.__AMP_MODE.geoOverride = 'nz'; addConfigElement('script'); geo.buildCallback(); @@ -259,7 +259,7 @@ describes.realWin( }); it('isInCountryGroup works with single group targets', () => { - win.AMP_MODE.geoOverride = 'nz'; + win.__AMP_MODE.geoOverride = 'nz'; addConfigElement('script'); geo.buildCallback(); @@ -276,7 +276,7 @@ describes.realWin( }); it('should allow uppercase hash to override geo in test', () => { - win.AMP_MODE.geoOverride = 'NZ'; + win.__AMP_MODE.geoOverride = 'NZ'; addConfigElement('script'); geo.buildCallback(); @@ -291,7 +291,7 @@ describes.realWin( }); it('should accept uppercase country codes in config', () => { - win.AMP_MODE.geoOverride = 'nz'; + win.__AMP_MODE.geoOverride = 'nz'; addConfigElement( 'script', 'application/json', @@ -329,7 +329,7 @@ describes.realWin( }); it('should allow hash to override pre-rendered geo in test', () => { - win.AMP_MODE.geoOverride = 'nz'; + win.__AMP_MODE.geoOverride = 'nz'; doc.body.classList.add('amp-iso-country-mx', 'amp-geo-group-nafta'); addConfigElement('script'); geo.buildCallback(); @@ -376,7 +376,7 @@ describes.realWin( it('geo should log an error if unpatched in production. ', () => { expectAsyncConsoleError(/GEONOTPATCHED/); - sandbox.stub(win.AMP_MODE, 'localDev').value(false); + sandbox.stub(win.__AMP_MODE, 'localDev').value(false); addConfigElement('script'); geo.buildCallback(); diff --git a/extensions/amp-lightbox-gallery/0.1/test/integration/test-amp-lightbox-gallery.js b/extensions/amp-lightbox-gallery/0.1/test/integration/test-amp-lightbox-gallery.js index 7402a86f643e..e6cc9df16590 100644 --- a/extensions/amp-lightbox-gallery/0.1/test/integration/test-amp-lightbox-gallery.js +++ b/extensions/amp-lightbox-gallery/0.1/test/integration/test-amp-lightbox-gallery.js @@ -46,7 +46,7 @@ describe.configure().skip('amp-lightbox-gallery', function() { beforeEach(() => { win = env.win; - win.AMP_MODE.localDev = true; + win.__AMP_MODE.localDev = true; triggerAnalyticsEventSpy = env.sandbox.spy( analytics, 'triggerAnalyticsEvent' @@ -210,7 +210,7 @@ describe.configure().skip('amp-lightbox-gallery', function() { beforeEach(() => { win = env.win; - win.AMP_MODE.localDev = true; + win.__AMP_MODE.localDev = true; triggerAnalyticsEventSpy = env.sandbox.spy( analytics, 'triggerAnalyticsEvent' diff --git a/src/mode.js b/src/mode.js index f8635fb6c9db..e5c07cf9f3cc 100644 --- a/src/mode.js +++ b/src/mode.js @@ -49,10 +49,10 @@ let rtvVersion = ''; */ export function getMode(opt_win) { const win = opt_win || self; - if (win.AMP_MODE) { - return win.AMP_MODE; + if (win.__AMP_MODE) { + return win.__AMP_MODE; } - return (win.AMP_MODE = getMode_(win)); + return (win.__AMP_MODE = getMode_(win)); } /** diff --git a/test/_init_tests.js b/test/_init_tests.js index 58feeaa44dd9..5460b2c48981 100644 --- a/test/_init_tests.js +++ b/test/_init_tests.js @@ -414,7 +414,7 @@ beforeEach(function() { function beforeTest() { activateChunkingForTesting(); - window.AMP_MODE = undefined; + window.__AMP_MODE = undefined; window.context = undefined; window.AMP_CONFIG = { canary: 'testSentinel', @@ -456,7 +456,7 @@ afterEach(function() { window.ENABLE_LOG = false; window.AMP_DEV_MODE = false; window.context = undefined; - window.AMP_MODE = undefined; + window.__AMP_MODE = undefined; delete window.document['__AMPDOC']; if (windowState.length != initialWindowState.length) { diff --git a/test/manual/loaders-new.amp.html b/test/manual/loaders-new.amp.html index e0113fe55e5b..a02b7cf2efbf 100644 --- a/test/manual/loaders-new.amp.html +++ b/test/manual/loaders-new.amp.html @@ -69,7 +69,7 @@