<!DOCTYPE html>

<iframe srcdoc="<html style='display: none'>Foo"></iframe>

<iframe id="doc"></iframe>

<script>
    // Test display:none on a non-HTMLElement that is the documentElement.
    var doc = document.getElementById('doc').contentDocument;
    var root = doc.implementation.createDocument().createElement('not-a-real-element');
    doc.replaceChild(root, doc.documentElement);
    root.appendChild(document.createElement('style')).textContent = 'not-a-real-element { display: none }';
    root.appendChild(document.createElement('p')).textContent = 'Should not be visible';
</script>
