Closed Bug 383890 Opened 17 years ago Closed 17 years ago

crash creating new dom attribute with prefix [@inDOMView::GetChildNodesFor]

Categories

(Other Applications :: DOM Inspector, defect)

x86
Windows XP
defect
Not set
critical

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Mook, Assigned: Mook)

References

()

Details

(Keywords: crash)

Crash Data

Attachments

(2 files, 2 obsolete files)

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a6pre) Gecko/20070609 IceWeasel/3.0a6pre Mook/Wine

MOZ_CO_DATE: 2007-06-09 12:23 -0700

Steps to reproduce:
1. Inspect a XML document, such as data:text/xml,<r/>
2. Select the document node
3. In the DOM Node view, right click and Insert an attribute
4. Node name: foo:bar
   Node value: baz
   Namespace URI: XHTML
5. Click OK

Now building a debug build to get useful info, but it looks like the first arg is null.
I'll bet this is a DOM crash.
Attached file stack at crash
in inDOMView::AttributeChanged, domAttr is null.

At el->GetAttributeNode(attrStr, getter_AddRefs(domAttr));
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/layout/inspector/src/inDOMView.cpp&rev=1.48&mark=720#715
attrStr is "bar", but as far as I can tell GetAttributeNode expects a qualified name ("foo:bar"), hence it returns null.  I guess it's ignoring aNameSpaceID completely?  Not sure on that...
Okay, I was wrong. :)

sdwilsh, do you want this one, or should I try taking it?
I'm really busy, so if you can take it, please do!
Attached patch patch (obsolete) — Splinter Review
I am totally unfamiliar with this area of code, so... I'm probably doing it wrong.

It seems to fix the crash (NS_ENSURE_ARG should make sure of that part), and it also seems to show sensible-looking things in the treeview that normally shows attributes.

The delete part is still broken, I think.

There's probably some way to do things without touching the namespace manager, but...
Attachment #267840 - Flags: review?(sdwilsh)
Severity: normal → critical
Keywords: crash
So after applying this patch and trying the steps to reproduce, I get the following two errors in the error console:

Error: this.mDoc has no properties
Source File: chrome://inspector/content/viewers/domNode/domNodeDialog.js
Line: 123
Error: this.subject.setAttributeNS is not a function
Source File: chrome://inspector/content/viewers/domNode/domNode.js
Line: 386
Comment on attachment 267840 [details] [diff] [review]
patch

general nit: line wrapping at 80 chars

>+    el->GetAttributeNodeNS(attrNS, attrStr, getter_AddRefs(domAttr));
>+    el->GetAttributeNode(attrStr, getter_AddRefs(domAttr));

nit: can you please cast the returned results of these to void to explicitly state that you don't care what they return please.  ex:
(void)el->GetAttributeNode(attrStr, getter_AddRefs(domAttr));

Good coding practices are nice!

r=me with these fixed.
Attachment #267840 - Flags: review?(sdwilsh) → review+
Added cast to void; requesting sr.
(Sorry Neil, it looks like I had been using the wrong address for review requests before...)
Attachment #267840 - Attachment is obsolete: true
Attachment #267903 - Flags: superreview?(neil)
Attachment #267903 - Flags: review+
Comment on attachment 267903 [details] [diff] [review]
fixed review comments (added cast to void)

>+  nsString attrNS;
>+  nsresult rv;
This is C++, not C; please declare these where you use them. sr=me with this fixed.
Attachment #267903 - Flags: superreview?(neil) → superreview+
carrying forward r/sr, ready for checkin.

Thanks everyone :)
Assignee: nobody → mook.moz+mozbz
Attachment #267903 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #268034 - Flags: superreview+
Attachment #268034 - Flags: review+
Whiteboard: [checkin needed]
Checking in layout/inspector/src/inDOMView.cpp;
new revision: 1.49; previous revision: 1.48
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Comment on attachment 268034 [details] [diff] [review]
addresses Neil's sr comments

>+    nsCOMPtr<nsINameSpaceManager> nsm =
>+      do_GetService(NS_NAMESPACEMANAGER_CONTRACTID);
>+    if (!nsm) {
I only hit this because I was running an old build, but it turns out we have nsContentUtils::NameSpaceManager() which always succeeds.
Crash Signature: [@inDOMView::GetChildNodesFor]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: