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

✨ [Story Video] Connect CacheUrl service to amp-video and load sources #33466

Merged
merged 55 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b077192
Added canonical to videos example
mszylkowski Mar 17, 2021
f657181
Merge branch 'master' of github.com:ampproject/amphtml into ampvideo_…
mszylkowski Mar 22, 2021
4687f9c
Started video cache
mszylkowski Mar 22, 2021
e6d122e
Use cdn url from url-impl
mszylkowski Mar 22, 2021
41ae575
Remove unnecessary | null
mszylkowski Mar 22, 2021
e0cd517
Undo videos.html
mszylkowski Mar 22, 2021
f5e3f8a
Merge branch 'master' of github.com:ampproject/amphtml into ampvideo_…
mszylkowski Mar 22, 2021
ff63db3
Remove console.log
mszylkowski Mar 22, 2021
d85dac3
Using ternary operator for reduce
mszylkowski Mar 22, 2021
a1aef44
Account for cached docs
mszylkowski Mar 22, 2021
4db83f6
Update logic with toolbox
mszylkowski Mar 22, 2021
59890a2
Merge branch 'master' of github.com:ampproject/amphtml into ampvideo_…
mszylkowski Mar 23, 2021
3f853a2
Added service
mszylkowski Mar 23, 2021
dc7d799
Undo amp-video
mszylkowski Mar 23, 2021
54b70b7
Added cache url service
mszylkowski Mar 23, 2021
164c99c
Added owners
mszylkowski Mar 23, 2021
19f5e3a
Cache url to video
mszylkowski Mar 23, 2021
095c0eb
Simplified cache example
mszylkowski Mar 23, 2021
46a9c5d
Updated title
mszylkowski Mar 23, 2021
f3fc5d5
Changed name to amp-cache-url of folder
mszylkowski Mar 23, 2021
ba110c1
Merge branch 'master' of github.com:ampproject/amphtml into ampvideo_…
mszylkowski Mar 23, 2021
9137b8a
Update readme
mszylkowski Mar 23, 2021
98c7d03
Update comments
mszylkowski Mar 23, 2021
cd45a21
Remove example
mszylkowski Mar 23, 2021
638499d
Updated readme
mszylkowski Mar 23, 2021
8fcbd8f
Merge branch 'master' of github.com:ampproject/amphtml into ampvideo_…
mszylkowski Mar 24, 2021
0d666a2
Merge branch 'master' of github.com:ampproject/amphtml into ampvideo_…
mszylkowski Mar 24, 2021
8f26de6
Added code
mszylkowski Mar 24, 2021
197d7a7
Fixed tests
mszylkowski Mar 24, 2021
cbd69bd
Removed comment
mszylkowski Mar 24, 2021
2e8eea9
Added some more tests
mszylkowski Mar 25, 2021
6d06b7d
Fixed cdnurl
mszylkowski Mar 25, 2021
e4cbe52
Update names of docSupports
mszylkowski Mar 25, 2021
8f2a336
Fix cacheUrl not replacing
mszylkowski Mar 25, 2021
62b866f
updated cacheDomain param name
mszylkowski Mar 25, 2021
bec5233
Check not cached doc to add cache sources
mszylkowski Mar 25, 2021
be109e5
improved implementation from comments
mszylkowski Mar 29, 2021
76c740f
added tests
mszylkowski Mar 29, 2021
327afc5
Added gregable file on examples
mszylkowski Mar 31, 2021
62447cd
Merge branch 'master' of github.com:ampproject/amphtml into ampvideo_…
mszylkowski Mar 31, 2021
2f010c0
Added warning
mszylkowski Mar 31, 2021
dafc2dd
Uppercase user error
mszylkowski Mar 31, 2021
7b1405a
Updated opt in
mszylkowski Apr 8, 2021
e3a7568
Fix response.json is promise
mszylkowski Apr 12, 2021
678d3b3
Updated test
mszylkowski Apr 12, 2021
53ff56f
Merge branch 'main' of github.com:ampproject/amphtml into ampvideo_ca…
mszylkowski Apr 14, 2021
2c44190
Fixed toArray import
mszylkowski Apr 14, 2021
1674173
Merge branch 'main' of github.com:ampproject/amphtml into ampvideo_ca…
mszylkowski Apr 19, 2021
a5ff5ed
Fixed visibilityState
mszylkowski Apr 19, 2021
157da69
Use helper functions
mszylkowski Apr 19, 2021
96e3548
Added tests to amp-cache-url
mszylkowski Apr 19, 2021
28f4faf
Update extensions/amp-cache-url/0.1/test/test-amp-cache-url.js
mszylkowski Apr 19, 2021
e990de2
Using extensionScriptInNode with win
mszylkowski Apr 20, 2021
2c125bd
Updated tests to match comments
mszylkowski Apr 20, 2021
c39e9ec
Not export applySources
mszylkowski Apr 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added tests
  • Loading branch information
mszylkowski committed Mar 29, 2021
commit 76c740fdce77e3de981b1de6b6177e11ac42792e
33 changes: 33 additions & 0 deletions extensions/amp-video/0.1/test/test-video-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@ describes.realWin('amp-video cached-sources', {amp: true}, (env) => {
});
});

describe('url forming', () => {
it('should send the request to the correct address if the video has an absolute url', async () => {
const videoEl = createVideo([{'src': 'https://website.com/video.html'}]);
const xhrSpy = env.sandbox.spy(xhrService, 'fetch');

const ampVideo = new AmpVideo(videoEl);
await ampVideo.buildCallback();

expect(xhrSpy).to.have.been.calledWith(
'https://website-com.cdn.ampproject.org/mbv/s/website.com/video.html'
);
});

it('should send the request to the correct address if the video has a relative url', async () => {
const videoEl = createVideo([{'src': 'video.html'}]);
const xhrSpy = env.sandbox.spy(xhrService, 'fetch');

const ampVideo = new AmpVideo(videoEl);
await ampVideo.buildCallback();

expect(xhrSpy).to.have.been.calledWith(
'https://example-com.cdn.ampproject.org/mbv/s/example.com/video.html'
);
});
});

describe('end to end', () => {
it('should create the sources from the request with the correct attributes', async () => {
env.sandbox.stub(xhrService, 'fetch').resolves({
Expand All @@ -106,6 +132,13 @@ describes.realWin('amp-video cached-sources', {amp: true}, (env) => {

expect(videoEl.querySelector('source[data-bitrate]')).to.not.be.null;
});
it('should not create the sources if there is amp-orig-src attribute', async () => {
const videoEl = createVideo([{'src': 'video.mp4', 'amp-orig-src': ''}]);
const ampVideo = new AmpVideo(videoEl);
await ampVideo.buildCallback();

expect(videoEl.querySelector('source[data-bitrate]')).to.be.null;
});
});

function createVideo(children) {
Expand Down
4 changes: 2 additions & 2 deletions extensions/amp-video/0.1/video-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export function addCacheSources(videoEl, win) {
if (
!extensionScriptsInNode(win.document).some(
(extension) => extension.extensionId === 'amp-cache-url'
) &&
videoEl.querySelector('source[src]')
) ||
!videoEl.querySelector('source[src]')
) {
return Promise.resolve();
}
Expand Down