Nodes imported into a the document of a newly-opened window fail to be displayed (no layout)

RESOLVED FIXED

Status

()

Core
DOM: Core & HTML
P1
normal
RESOLVED FIXED
7 years ago
6 years ago

People

(Reporter: Michael[tm] Smith, Assigned: bz)

Tracking

(Depends on: 1 bug)

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
User-Agent:       Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.0b7pre) Gecko/20100922 Firefox/4.0b7pre
Build Identifier: 4.0b7pre

See "Steps to Reproduce". I use script to open a new window using window.open(), then I try to copy a node from the current document and import into the new window and write it there. Using Firebug, I can examine that new window and see that it does in fact have a DOM and that the contents of that DOM are what I expect (that is, the node got imported as expected). However, nothing is displayed in the window. It is as if Gecko is doing now layout/rendering at all of that DOM.

Reproducible: Always

Steps to Reproduce:
1. go to http://people.w3.org/mike/bugs/es5-spec/#x7.1
2. hover anywhere over the "7.1 Unicode Format-Control Characters" text
3. click the Ⓔ
… pop-up displays a "Table 1 — Format-Control Character Usage" table
4. click the up-arrow at the top right (next to the "x")
… a new tab opens, showing an empty page
5. open Firebug on that page and observe that despite not
   displaying anything, there is content in the DOM…

Here is how I am attempting to create the document:

    var win = window.open();
    ...
    var annoBody = win.document.importNode(document.getElementById("annotation"),true);
    win.document.body.appendChild(annoBody);
    win.document.close();

The full script is here:

  http://people.w3.org/mike/bugs/es5-spec/anno.js
Actual Results:  
Nothing is displayed in newly created window despite the fact that it has DOM content.

Expected Results:  
Expected result is that the DOM content should get layed out and rendered.

Workaround (or actually, this is probably the right/better way I should have been doing it from the beginning)

Thanks to some suggestions from Henri Sivonen on IRC, I find that instead of the above, I can do the following:

    var win = window.open();
    ...
    win.document.write("<!doctype html>");
    win.document.close();
    var annoBody = win.document.importNode(document.getElementById("annotation"),true);
    win.document.body.appendChild(annoBody);
I'm guessing that in the case that didn't work, the nodes got inserted into a docshell-created about:blank DOM that never had StartLayout() properly called for it.

Marking as loosely depending on bug 543435 which is about rewriting this general area.
Status: UNCONFIRMED → NEW
Depends on: 543435
Ever confirmed: true
OS: Mac OS X → All
Hardware: x86 → All
Version: unspecified → Trunk
Summary: document write to new window through import fails to be displayed (no layout) → Nodes imported into a the document of a newly-opened windod fail to be displayed (no layout)
Is this a regression from 3.6?
The answer to comment 2 is "no".  More interestingly, this bug only happens when opening the new window in a tab.  If opening in an actual window, no problem.
Created attachment 478507 [details]
Pretty minimal testcase
Summary: Nodes imported into a the document of a newly-opened windod fail to be displayed (no layout) → Nodes imported into a the document of a newly-opened window fail to be displayed (no layout)
(In reply to comment #3)
> More interestingly, this bug only happens
> when opening the new window in a tab.  If opening in an actual window, no
> problem.

Isn't this because in the window case, a nested event loop spins until about:blank has been loaded from a stream, so the script doesn't see a docshell-created about:blank?
Sure.  And in the tab case I think that about:blank load is explicitly canceled...
So perhaps when we see that failed load and have an initial document... something.  We don't really want to be calling StartLayout on all CreateAboutBlankContentViewer-created documents, I think...
Duplicate of this bug: 612196

Comment 9

7 years ago
workaround 
  var win = window.open('about:blank');
  win.document.body.appendChild(win.document.createTextNode("test"));
works...
Blocks: 637644
No longer blocks: 637644
Depends on: 637644
> We don't really want to be calling StartLayout on all
> CreateAboutBlankContentViewer-created documents

I have no idea why I said that.  The patch in bug 637644 does just that and fixes this bug.
Fixed by the patch in bug 637644.
Assignee: nobody → bzbarsky
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Flags: in-testsuite+
Priority: -- → P1
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0
That bug was backed out.
Status: RESOLVED → REOPENED
Flags: in-testsuite+
Resolution: FIXED → ---
Target Milestone: mozilla2.0 → ---
And fixed again?
Yes.
Status: REOPENED → RESOLVED
Last Resolved: 7 years ago6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.