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

fix iframe placeholder html #5296

Merged
merged 6 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/driver/src/cy/snapshots.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ create = ($$, state) ->
</style>
<p>&lt;iframe&gt; placeholder for #{iframe.src}</p>
"""
$placeholder[0].src = "data:text/html;charset=utf-8,#{encodeURI(contents)}"
$placeholder[0].src = "data:text/html;base64,#{window.btoa(contents)}"

getStyles = (snapshot) ->
styleIds = snapshotsMap.get(snapshot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,17 @@ describe "driver/src/cy/snapshots", ->
it "replaces with placeholders that have src in content", ->
$("<iframe src='generic.html' />").appendTo(cy.$$("body"))

## NOTE: possibly switch to visual screenshot diffing in future
## since data: iframes are considered cross-origin and we cannot
## query into them and assert on contents
## e.g. cy.get('iframe').toMatchScreenshot()

## For now we parse the src attr and assert on base64 encoded content
{ body } = cy.createSnapshot(null, @$el)
expect(body.find("iframe").length).to.equal(1)
expect(body.find("iframe")[0].src).to.include("generic.html")
expect(body.find("iframe")[0].src).to.include(";base64")

expect(atob(body.find("iframe")[0].src.split(',')[1])).to.include("generic.html")

it "placeholders have same id", ->
$("<iframe id='foo-bar' />").appendTo(cy.$$("body"))
Expand Down