E4X handles whitespace in text incorrectly

RESOLVED INVALID

Status

()

Core
JavaScript Engine
--
major
RESOLVED INVALID
13 years ago
13 years ago

People

(Reporter: conor, Unassigned)

Tracking

({testcase})

Trunk
PowerPC
Mac OS X
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

13 years ago
User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.9a1) Gecko/20050926 Firefox/1.6a1
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.9a1) Gecko/20050926 Firefox/1.6a1

10.1 of the ECMA spec says that toXMLString should strip leading
and trailing spaces from a text node iff prettyPrint is true. This test shows
that the Mozilla E4X always strips spaces from some text nodes irrespective of
the prettyPrint setting.

Reproducible: Always

Steps to Reproduce:
	var textAfterSpan = "<p><span> A sentence with a leading </span> and then one
with another leading space.</p>";
	var xmlText = new XML(textAfterSpan);
	XML.prettyPrinting = false;
	var spanText = xmlText.children()[0].toXMLString();
	var followingText = xmlText.children()[1].toXMLString();
	XML.prettyPrinting = true;
	var spanTextPretty = xmlText.children()[0].toXMLString();
	var followingTextPretty = xmlText.children()[1].toXMLString();

	// All ok: whitespace is preserved in spanText so it isn't the same as 
	// its "pretty" equivalent
	if(spanText == spanTextPretty)
		alert("Got bug: problem with whitespace in text inside embedded tags");

	// Bug: leading whitespace removed no matter what
	if(followingText == followingTextPretty)
		alert("Got bug: problem with whitespace in text following an embedded tag");
Assignee: nobody → general
Component: General → JavaScript Engine
Keywords: testcase
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → Trunk
You need to set XML.ignoreWhitespace = false; in addition to clearing
XML.prettyPrinting to see whitespace preserved from input to toXMLString output.

/be
Status: UNCONFIRMED → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.