In my answer here the return of document.getElementsByTagName()
is incorrect.
As far as I can tell, this is caused by the way the window.onload() is being dealt with.
Minimal reproduction of issue:
<script>
var a=8
window.onload=function(){
console.log(document.getElementsByTagName('div').length)
}
</script>
Note to help debugging: if you add another script tag with contents this will give you a new phantom 'div'.