Closed Bug 277324 Opened 20 years ago Closed 19 years ago

Copy XML doesn't work on #document nodes

Categories

(Other Applications :: DOM Inspector, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9alpha

People

(Reporter: WeirdAl, Assigned: jason.barnabe)

Details

Attachments

(1 file, 1 obsolete file)

Steps to reproduce:
(1) Inspect this page in DOM Inspector
(2) Left-hand viewer, #document node selected
(3) Context menu, Copy XML
(4) Paste results into your favorite text editor

Expected results:
Text editor shows full source of web page.

Actual results:
Text editor shows nothing.
Attached patch patch v1 (obsolete) — Splinter Review
For some reason, inspector has its own XML serialization code. This patch removes that code and just uses nsIDOMSerializer. The only difference I can tell is in whitespace - the previous code used indents to show the hierarchy, the new code preserves the whitespace (at least in HTML).

nsIDOMSerializer handles document nodes just fine.
Assignee: ajvincent → jason_barnabe
Status: NEW → ASSIGNED
Attachment #216285 - Flags: superreview?(neil)
Attachment #216285 - Flags: review?(timeless)
I have a caveat about this.  IIRC, XMLSerializer is still an extension (built by default along with XMLHttpRequest and DOMParser).  So this might work for people who build it, but once you disable that in the build process, this code breaks.

I'd suggest using the new code you suggest first, in a try...catch block.  If that fails, fall back to some saner code similar to the current code.
(In reply to comment #2)
> I have a caveat about this.  IIRC, XMLSerializer is still an extension

Not anymore. (To disable it, you need an explicit --disable-xmlparser, and IMO if you do that you get what you deserve ;) )
Comment on attachment 216285 [details] [diff] [review]
patch v1

domi's an extension, and i want to be able to install it in older versions that don't have webservices.

i don't mind prefering some other thing, but i do object to requiring it.
Attachment #216285 - Flags: superreview?(neil)
Attachment #216285 - Flags: review?(timeless)
Attachment #216285 - Flags: review-
Attached patch patch v2Splinter Review
So this patch will use XMLSerializer if available, and the existing code if not. I've added a bit more to the existing code: if the passed in node is a document node, it does its thing on the document element. It still won't output doctypes or processing instructions or whatnot when XMLSerializer isn't available, but at least it does something.
Attachment #216285 - Attachment is obsolete: true
Attachment #221941 - Flags: review?(timeless)
Attachment #221941 - Flags: superreview?(neil)
Attachment #221941 - Flags: review?(timeless)
Attachment #221941 - Flags: review+
Attachment #221941 - Flags: superreview?(neil) → superreview+
Whiteboard: [checkin needed]
mozilla/extensions/inspector/resources/content/viewers/dom/dom.js 	1.39
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Target Milestone: --- → mozilla1.9alpha
Version: unspecified → Trunk
QA Contact: timeless → dom-inspector
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: