Skip to content

Commit

Permalink
Fallback to screen.availHeight for iframe bug (#579)
Browse files Browse the repository at this point in the history
What changed?
----------------

This commit uses the `screen.availHeight` property as a fallback 
to how we currently set the iframe's height. See [screen docs]. 

[Screen docs]: https://developer.mozilla.org/en-US/docs/Web/API/Screen

Why?
-------

As part of the Wallaby feature test I've needed to read an email, 
but I could only get iframe element using 
`Wallaby.Query.css("iframe", visible: false)` because the height 
of the element is 0.

I've tried this in multiple versions of Chrome and chromedriver. 
Also, I've only been able to experience this in headless Chrome 
in macOS. I wasn't having this issue with Wallaby option 
headless: false nor on a CI instance running Ubuntu.

Related to #350 and 
#351
  • Loading branch information
almirsarajcic authored Feb 15, 2021
1 parent 9e8b274 commit b526e0d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/bamboo/plug/sent_email_viewer/index.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@
<script>
function adjustFrameHeight(iframe) {
var contentWindow = iframe.contentWindow;
iframe.style.height = (contentWindow.outerHeight) + "px";
var height = (contentWindow.outerHeight)
? contentWindow.outerHeight
: contentWindow.screen.availHeight;
iframe.style.height = height + "px";
}
</script>
<iframe onload="adjustFrameHeight(this)" src="<%= "#{@base_path}/#{Bamboo.SentEmail.get_id(@selected_email)}/html" %>"></iframe>
Expand Down

0 comments on commit b526e0d

Please sign in to comment.