createContextualFragment() throws NS_ERROR_NOT_AVAILABLE

RESOLVED FIXED in mozilla1.9beta4

Status

()

P3
major
RESOLVED FIXED
11 years ago
10 years ago

People

(Reporter: nassar, Assigned: smaug)

Tracking

({regression, testcase})

Trunk
mozilla1.9beta4
regression, testcase
Points:
---
Bug Flags:
blocking1.9 +

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(3 attachments)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Build Identifier: XULRunner CVS trunk 01/29/2008

Calls to nsIDOMRange::createContextualFragment() on a HTML document throw the following exception.

[Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMNSRange.createContextualFragment]"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: file:///e:/miro/tv/platform/windows-xul/dist/components/jsbridge.js :: anonymous :: line 519"  data: no]

Reproducible: Always

Steps to Reproduce:
    var elt = document.getElementById(id);  //id is a string defined earlier
    var r = document.createRange();
    r.selectNode(document.documentElement);
    var frag = r.createContextualFragment(xml); //xml is a string defined earlier

Actual Results:  
throws NS_ERROR_NOT_AVAILABLE

Expected Results:  
Return the fragment

This is happening for me when I upgrade Miro to XULRunner 1.9 from CVS trunk. The above link is from someone else experiencing the same problem.
(Reporter)

Updated

11 years ago
Version: unspecified → Trunk
A testcase uploaded using "Add an attachment" would be great.
(Assignee)

Updated

11 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Created attachment 300099 [details]
testcase

Something to do with .documentElement
mStartParent is null when selecting .documentElement.
Jonas, can you remember something related to this immediately?
Er, no, sorry. It is doc which I QI'd to nsIContent in nsContentUtils::CreateContextualFragment.
That of doesn't work.
s/which I/which is/
regression range 2006-10-19 - 2006-10-21.
-> Bug 357445
Blocks: 357445

Updated

11 years ago
Keywords: regression, testcase
Created attachment 300377 [details]
testcase2

So on 1.8 .startContainer is htmlelement, on 1.9 it is htmldocument.
What 1.9 does is afaik right. That is what Opera and Safari returns.

(Safari crashes with this testcase.)
Created attachment 300380 [details] [diff] [review]
allow contextfragments when container is document

I think we should do something like this.
Assignee: nobody → Olli.Pettay
Status: NEW → ASSIGNED
Attachment #300380 - Flags: review?(jonas)
Comment on attachment 300380 [details] [diff] [review]
allow contextfragments when container is document

Looks good
Attachment #300380 - Flags: superreview+
Attachment #300380 - Flags: review?(jonas)
Attachment #300380 - Flags: review+
(Assignee)

Updated

11 years ago
Attachment #300380 - Flags: approval1.9?
(Reporter)

Comment 10

11 years ago
The patch works for me

Comment 11

11 years ago
Did you want this for b3?
I was thinking after b3. Not so serious, or at least this feature isn't
apparently used very often. So just to get this fixed in FF3.
Flags: blocking1.9? → blocking1.9+
Priority: -- → P3

Updated

11 years ago
Attachment #300380 - Flags: approval1.9? → approval1.9+
(Assignee)

Updated

11 years ago
Keywords: checkin-needed
Checking in content/base/src/nsContentUtils.cpp;
/cvsroot/mozilla/content/base/src/nsContentUtils.cpp,v  <--  nsContentUtils.cpp
new revision: 1.272; previous revision: 1.271
done
Status: ASSIGNED → RESOLVED
Last Resolved: 11 years ago
Keywords: checkin-needed
OS: Windows XP → All
Hardware: PC → All
Resolution: --- → FIXED
*** 42217 ERROR FAIL | range.createContextualFragment() should throw when range node is DocType |  | /tests/parser/htmlparser/tests/mochitest/test_bug358797.html

Backed out.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: --- → mozilla1.9beta4
Bah, sorry.
I'll update either the testcase or patch when back on my dev.machine.
I think changing the testcase is ok, it should just check that 
browser doesn't crash when creating contextual fragment using doctype.
I changed the testcase.
Status: REOPENED → RESOLVED
Last Resolved: 11 years ago11 years ago
Resolution: --- → FIXED

Updated

10 years ago
Component: DOM: Core → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.