Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use AMP Version as RTV Versions #5474

Merged
merged 2 commits into from Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions ads/alp/handler.js
Expand Up @@ -178,8 +178,7 @@ export function warmupStatic(win) {
const linkRel = /*OK*/document.createElement('link');
linkRel.rel = 'preload';
linkRel.setAttribute('as', 'script');
linkRel.href =
`${urls.cdn}/rtv/01$internalRuntimeVersion$/v0.js`;
linkRel.href = `${urls.cdn}/v0.js`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwinmombay Do we inject the config yet? In any way we should.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cramforce is this code part of alp.js? if so then yes:

https://cdn.ampproject.org/alp.js

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

getHeadOrFallback(win.document).appendChild(linkRel);
}

Expand Down
3 changes: 1 addition & 2 deletions src/service-worker/shell.js
Expand Up @@ -21,6 +21,5 @@ import {calculateExtensionScriptUrl} from '../service/extensions-impl';
* file is kept intentionally small, so that checking if it has changed (and
* thus, if a new SW must be installed) will be very fast.
*/
const url = calculateExtensionScriptUrl(self.location, 'cache-service-worker',
'$internalRuntimeVersion$', true);
const url = calculateExtensionScriptUrl(self.location, 'cache-service-worker');
importScripts(url);
12 changes: 4 additions & 8 deletions src/service/extensions-impl.js
Expand Up @@ -35,7 +35,6 @@ import {urls} from '../config';
const TAG = 'extensions';
const UNKNOWN_EXTENSION = '_UNKNOWN_';


/**
* The structure that contains the declaration of a custom element.
*
Expand Down Expand Up @@ -513,7 +512,7 @@ export class Extensions {
const loc = this.win.location;
const useCompiledJs = shouldUseCompiledJs();
const scriptSrc = calculateExtensionScriptUrl(loc, extensionId,
getMode().version, getMode().localDev, getMode().test, useCompiledJs);
getMode().localDev, getMode().test, useCompiledJs);
scriptElement.src = scriptSrc;
return scriptElement;
}
Expand All @@ -540,24 +539,21 @@ export function calculateScriptBaseUrl(location, isLocalDev, isTest) {
* Calculate script url for amp-ad.
* @param {!Location} location The window's location
* @param {string} extensionId
* @param {string} version
* @param {boolean=} isLocalDev
* @param {boolean=} isTest
* @param {boolean=} isUsingCompiledJs
* @return {string}
*/
export function calculateExtensionScriptUrl(location, extensionId, version,
isLocalDev, isTest, isUsingCompiledJs) {
export function calculateExtensionScriptUrl(location, extensionId, isLocalDev,
isTest, isUsingCompiledJs) {
const base = calculateScriptBaseUrl(location, isLocalDev, isTest);
if (isLocalDev) {
if ((isTest && !isUsingCompiledJs) || isMax(location)) {
return `${base}/v0/${extensionId}-0.1.max.js`;
}
return `${base}/v0/${extensionId}-0.1.js`;
}
const folderPath = version == '$internalRuntimeVersion$' ?
'v0' : `rtv/${version}/v0`;
return `${base}/${folderPath}/${extensionId}-0.1.js`;
return `${base}/rtv/${getMode().version}/v0/${extensionId}-0.1.js`;
}


Expand Down
3 changes: 1 addition & 2 deletions test/functional/test-alp-handler.js
Expand Up @@ -302,8 +302,7 @@ describe('alp-handler', () => {
expect(win.document.head.appendChild.callCount).to.equal(1);
const link = win.document.head.appendChild.lastCall.args[0];
expect(link.rel).to.equal('preload');
expect(link.href).to.equal(
'https://cdn.ampproject.org/rtv/01$internalRuntimeVersion$/v0.js');
expect(link.href).to.equal('https://cdn.ampproject.org/v0.js');
});

it('should warmup dynamically', () => {
Expand Down
17 changes: 9 additions & 8 deletions test/functional/test-extensions.js
Expand Up @@ -479,7 +479,7 @@ describes.sandboxed('Extensions', {}, () => {
pathname: 'examples/ads.amp.html',
host: 'localhost:8000',
protocol: 'http:',
}, 'amp-ad', '123', true, true, true);
}, 'amp-ad', true, true, true);
expect(script).to.equal('http://localhost:8000/dist/v0/amp-ad-0.1.js');
});

Expand All @@ -488,7 +488,7 @@ describes.sandboxed('Extensions', {}, () => {
pathname: 'examples/ads.amp.html',
host: 'localhost:80',
protocol: 'https:',
}, 'amp-ad', '123', true, true, false);
}, 'amp-ad', true, true, false);
expect(script).to.equal('https://localhost:80/dist/v0/amp-ad-0.1.max.js');
});

Expand All @@ -497,7 +497,7 @@ describes.sandboxed('Extensions', {}, () => {
pathname: 'examples/ads.amp.html',
host: 'localhost:8000',
protocol: 'https:',
}, 'amp-ad', '123', true);
}, 'amp-ad', true);
expect(script).to.equal('https://cdn.ampproject.org/v0/amp-ad-0.1.js');
});

Expand All @@ -506,7 +506,7 @@ describes.sandboxed('Extensions', {}, () => {
pathname: 'examples/ads.amp.min.html',
host: 'localhost:8000',
protocol: 'http:',
}, 'amp-ad', '123', true);
}, 'amp-ad', true);
expect(script).to.equal('http://localhost:8000/dist/v0/amp-ad-0.1.js');
});

Expand All @@ -515,16 +515,17 @@ describes.sandboxed('Extensions', {}, () => {
pathname: 'examples/ads.amp.max.html',
host: 'localhost:8000',
protocol: 'http:',
}, 'amp-ad', '123', true);
}, 'amp-ad', true);
expect(script).to.equal('http://localhost:8000/dist/v0/amp-ad-0.1.max.js');
});

it('with remote mode', () => {
window.AMP_MODE = {version: '123'};
const script = calculateExtensionScriptUrl({
pathname: 'examples/ads.amp.min.html',
host: 'localhost:8000',
protocol: 'http:',
}, 'amp-ad', '123', false);
}, 'amp-ad', false);
expect(script).to.equal(
'https://cdn.ampproject.org/rtv/123/v0/amp-ad-0.1.js');
});
Expand All @@ -534,7 +535,7 @@ describes.sandboxed('Extensions', {}, () => {
pathname: '/max/output.jsbin.com/pegizoq/quiet',
host: 'localhost:80',
protocol: 'http:',
}, 'amp-ad', '123', true);
}, 'amp-ad', true);
expect(script).to.equal('http://localhost:80/dist/v0/amp-ad-0.1.max.js');
});

Expand All @@ -543,7 +544,7 @@ describes.sandboxed('Extensions', {}, () => {
pathname: '/min/output.jsbin.com/pegizoq/quiet',
host: 'localhost:80',
protocol: 'http:',
}, 'amp-ad', '123', true);
}, 'amp-ad', true);
expect(script).to.equal('http://localhost:80/dist/v0/amp-ad-0.1.js');
});
});
Expand Down