Last Comment Bug 598895 - Nodes imported into a the document of a newly-opened window fail to be displayed (no layout)
: Nodes imported into a the document of a newly-opened window fail to be displa...
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: DOM: Core & HTML (show other bugs)
: Trunk
: All All
: P1 normal (vote)
: ---
Assigned To: Boris Zbarsky [:bz]
:
Mentors:
http://people.w3.org/mike/bugs/es5-sp...
: 612196 (view as bug list)
Depends on: sync-about-blank 637644
Blocks:
  Show dependency treegraph
 
Reported: 2010-09-23 03:20 PDT by Michael[tm] Smith
Modified: 2011-05-31 11:28 PDT (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Pretty minimal testcase (213 bytes, text/html)
2010-09-24 23:08 PDT, Boris Zbarsky [:bz]
no flags Details

Description Michael[tm] Smith 2010-09-23 03:20:23 PDT
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);
Comment 1 Henri Sivonen (:hsivonen) 2010-09-23 03:30:25 PDT
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.
Comment 2 Boris Zbarsky [:bz] 2010-09-23 06:17:35 PDT
Is this a regression from 3.6?
Comment 3 Boris Zbarsky [:bz] 2010-09-24 23:07:18 PDT
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.
Comment 4 Boris Zbarsky [:bz] 2010-09-24 23:08:22 PDT
Created attachment 478507 [details]
Pretty minimal testcase
Comment 5 Henri Sivonen (:hsivonen) 2010-09-28 02:01:12 PDT
(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?
Comment 6 Boris Zbarsky [:bz] 2010-09-30 20:22:02 PDT
Sure.  And in the tab case I think that about:blank load is explicitly canceled...
Comment 7 Boris Zbarsky [:bz] 2010-09-30 20:23:57 PDT
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...
Comment 8 Boris Zbarsky [:bz] 2010-11-14 18:34:20 PST
*** Bug 612196 has been marked as a duplicate of this bug. ***
Comment 9 Biju 2010-11-14 18:58:46 PST
workaround 
  var win = window.open('about:blank');
  win.document.body.appendChild(win.document.createTextNode("test"));
works...
Comment 10 Boris Zbarsky [:bz] 2011-03-02 11:14:34 PST
> 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.
Comment 11 Boris Zbarsky [:bz] 2011-03-02 11:47:09 PST
Fixed by the patch in bug 637644.
Comment 12 Boris Zbarsky [:bz] 2011-03-02 17:35:19 PST
That bug was backed out.
Comment 13 :Ms2ger 2011-05-31 11:26:37 PDT
And fixed again?
Comment 14 Boris Zbarsky [:bz] 2011-05-31 11:28:11 PDT
Yes.

Note You need to log in before you can comment on or make changes to this bug.