@@ -1549,6 +1549,50 @@ describes.realWin(
15491549 } ) ;
15501550 } ) ;
15511551
1552+ describe ( 'amp-story rewriteStyles' , ( ) => {
1553+ beforeEach ( ( ) => {
1554+ toggleExperiment ( win , 'amp-story-responsive-units' , true ) ;
1555+ } ) ;
1556+
1557+ afterEach ( ( ) => {
1558+ toggleExperiment ( win , 'amp-story-responsive-units' , false ) ;
1559+ } ) ;
1560+
1561+ it ( 'should rewrite vw styles' , ( ) => {
1562+ createPages ( story . element , 1 , [ 'cover' ] ) ;
1563+ const styleEl = win . document . createElement ( 'style' ) ;
1564+ styleEl . setAttribute ( 'amp-custom' , '' ) ;
1565+ styleEl . textContent = 'foo {transform: translate3d(100vw, 0, 0);}' ;
1566+ win . document . head . appendChild ( styleEl ) ;
1567+
1568+ story . buildCallback ( ) ;
1569+
1570+ return story . layoutCallback ( ) . then ( ( ) => {
1571+ expect ( styleEl . textContent ) . to . equal (
1572+ 'foo {transform: ' +
1573+ 'translate3d(calc(100 * var(--story-page-vw)), 0, 0);}'
1574+ ) ;
1575+ } ) ;
1576+ } ) ;
1577+
1578+ it ( 'should rewrite negative vh styles' , ( ) => {
1579+ createPages ( story . element , 1 , [ 'cover' ] ) ;
1580+ const styleEl = win . document . createElement ( 'style' ) ;
1581+ styleEl . setAttribute ( 'amp-custom' , '' ) ;
1582+ styleEl . textContent = 'foo {transform: translate3d(-100vh, 0, 0);}' ;
1583+ win . document . head . appendChild ( styleEl ) ;
1584+
1585+ story . buildCallback ( ) ;
1586+
1587+ return story . layoutCallback ( ) . then ( ( ) => {
1588+ expect ( styleEl . textContent ) . to . equal (
1589+ 'foo {transform: ' +
1590+ 'translate3d(calc(-100 * var(--story-page-vh)), 0, 0);}'
1591+ ) ;
1592+ } ) ;
1593+ } ) ;
1594+ } ) ;
1595+
15521596 describe ( 'amp-story branching' , ( ) => {
15531597 beforeEach ( ( ) => {
15541598 toggleExperiment ( win , 'amp-story-branching' , true ) ;
0 commit comments