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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Fix Animation.animate breakage caused by missing import. #30264

Merged
merged 7 commits into from Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -187,7 +187,7 @@ module.exports = {
'no-lone-blocks': 2,
'no-native-reassign': 2,
'no-redeclare': 2,
'no-restricted-globals': [2, 'error', 'event'],
'no-restricted-globals': [2, 'error', 'event', 'Animation'],
'no-script-url': 2,
'no-self-compare': 2,
'no-sequences': 2,
Expand Down
1 change: 1 addition & 0 deletions src/service/fixed-layer.js
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import {Animation} from '../animation';
import {Pass} from '../pass';
import {Services} from '../services';
import {
Expand Down
55 changes: 55 additions & 0 deletions test/unit/test-fixed-layer.js
Expand Up @@ -15,6 +15,7 @@
*/

import {AmpDocSingle, installDocService} from '../../src/service/ampdoc-impl';
import {Animation} from '../../src/animation';
import {FakeMutationObserver, FakeWindow} from '../../testing/fake-dom';
import {FixedLayer} from '../../src/service/fixed-layer';
import {Services} from '../../src/services';
Expand Down Expand Up @@ -1832,3 +1833,57 @@ describes.sandboxed(
});
}
);

describes.sandboxed(
'FixedLayer bug due to calling browser native instead of AMP implementation',
{},
() => {
let win;
let ampdoc;
let viewer;
let vsyncApi;

beforeEach(() => {
win = new FakeWindow();
window.__AMP_MODE = {
localDev: true,
development: false,
minified: false,
test: false,
version: '$internalRuntimeVersion$',
};

const vsyncTasks = [];
vsyncApi = {
runPromise: (task) => {
vsyncTasks.push(task);
xiexr151e marked this conversation as resolved.
Show resolved Hide resolved
return Promise.resolve();
},
mutate: (mutator) => {
vsyncTasks.push({mutate: mutator});
},
};
});

it('should call Animation.animate in animateFixedElements', () => {
const animateSpy = window.sandbox.spy(Animation, 'animate');

ampdoc = new AmpDocSingle(win);
installPlatformService(win);
installTimerService(win);
installViewerServiceForDoc(ampdoc);
viewer = Services.viewerForDoc(ampdoc);
viewer.isEmbedded = () => true;

const fixedLayer = new FixedLayer(
xiexr151e marked this conversation as resolved.
Show resolved Hide resolved
ampdoc,
vsyncApi,
/* borderTop */ 0,
/* paddingTop */ 11,
/* transfer */ false
);
fixedLayer.animateFixedElements(123, 456, 789, 'ease-in', false);
expect(animateSpy).to.be.calledOnce;
});
}
);