返回 slidev
iframe-layout.spec.ts
根目录 / cypress / e2e / examples / iframe-layout.spec.ts
1 context('Iframe layout', () => {
2 // #2281: the iframe should lay out and rasterize at its real on-screen
3 // size, so embedded canvas-based pages are not bitmap-upscaled and blurred
4 it('rasterizes at the on-screen size when the slide is scaled up', () => {
5 cy.viewport(1960, 1104) // 2x the default 980x552 slide size
6 cy.visit('/18')
7 cy.get('#slide-content iframe').should(($frame) => {
8 const el = $frame[0]
9 const rect = el.getBoundingClientRect()
10 expect(rect.width, 'displayed width').to.be.closeTo(1960, 2)
11 expect(el.offsetWidth, 'layout width').to.be.closeTo(rect.width, 2)
12 })
13 })
14
15 it('keeps the design-size layout when the slide is scaled down', () => {
16 cy.viewport(490, 276) // 0.5x the default 980x552 slide size
17 cy.visit('/18')
18 cy.get('#slide-content iframe').should(($frame) => {
19 const el = $frame[0]
20 const rect = el.getBoundingClientRect()
21 expect(rect.width, 'displayed width').to.be.closeTo(490, 2)
22 expect(el.offsetWidth, 'layout width').to.equal(980)
23 })
24 })
25 })
26
26 lines TYPESCRIPT