Skip to content

Commit

Permalink
Extend webview rules to Android (ampproject#8626)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Voytenko authored Apr 6, 2017
1 parent ab09fe5 commit 3a5c603
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion css/amp.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ html.i-amphtml-singledoc > body {
* Note! For all other natural cases body's style is `body {overflow: visible}`
* to avoid visibility issues with iframes.
*/
html.i-amphtml-ios-webview > body {
html.i-amphtml-webview > body {
overflow-x: hidden !important;
overflow-y: visible !important;
}
Expand Down
5 changes: 2 additions & 3 deletions src/service/viewport-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,8 @@ export class Viewport {
if (isIframed(this.ampdoc.win)) {
this.globalDoc_.documentElement.classList.add('i-amphtml-iframed');
}
const platform = platformFor(this.ampdoc.win);
if (platform.isIos() && viewer.getParam('webview') === '1') {
this.globalDoc_.documentElement.classList.add('i-amphtml-ios-webview');
if (viewer.getParam('webview') === '1') {
this.globalDoc_.documentElement.classList.add('i-amphtml-webview');
}

// To avoid browser restore scroll position when traverse history
Expand Down
10 changes: 5 additions & 5 deletions test/functional/test-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,19 @@ describes.fakeWin('Viewport', {}, env => {

it('should set ios-webview class', () => {
new Viewport(ampdoc, binding, viewer);
expect(root).to.have.class('i-amphtml-ios-webview');
expect(root).to.have.class('i-amphtml-webview');
});

it('should not set ios-webview class when not on iOS', () => {
it('should set ios-webview class even when not on iOS', () => {
isIos = false;
new Viewport(ampdoc, binding, viewer);
expect(root).to.not.have.class('i-amphtml-ios-webview');
expect(root).to.have.class('i-amphtml-webview');
});

it('should not set ios-webview class w/o webview param', () => {
webviewParam = null;
new Viewport(ampdoc, binding, viewer);
expect(root).to.not.have.class('i-amphtml-ios-webview');
expect(root).to.not.have.class('i-amphtml-webview');
});
});
});
Expand Down Expand Up @@ -1182,7 +1182,7 @@ describes.realWin('ViewportBindingNatural', {ampCss: true}, env => {
});

it('should override body overflow for iOS webview', () => {
win.document.documentElement.classList.add('i-amphtml-ios-webview');
win.document.documentElement.classList.add('i-amphtml-webview');
binding = new ViewportBindingNatural_(ampdoc, viewer);
const bodyStyles = win.getComputedStyle(win.document.body);
expect(bodyStyles.position).to.equal('relative');
Expand Down

0 comments on commit 3a5c603

Please sign in to comment.