Bug 636336. Don't mess with whitespace in the src attribute of images, now that necko can deal with it itself. r=sicking

This commit is contained in:
Boris Zbarsky 2011-03-23 10:45:21 -04:00
parent 890788b82e
commit fe21f6185a
5 changed files with 46 additions and 37 deletions

View File

@ -369,11 +369,6 @@ nsHTMLImageElement::ParseAttribute(PRInt32 aNamespaceID,
if (aAttribute == nsGkAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (aAttribute == nsGkAtoms::src) {
static const char* kWhitespace = " \n\r\t\b";
aResult.SetTo(nsContentUtils::TrimCharsInSet(kWhitespace, aValue));
return PR_TRUE;
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
}

View File

@ -1419,15 +1419,10 @@ PRBool nsHTMLMediaElement::ParseAttribute(PRInt32 aNamespaceID,
};
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::src) {
static const char* kWhitespace = " \n\r\t\b";
aResult.SetTo(nsContentUtils::TrimCharsInSet(kWhitespace, aValue));
return PR_TRUE;
}
else if (aAttribute == nsGkAtoms::loopstart
|| aAttribute == nsGkAtoms::loopend
|| aAttribute == nsGkAtoms::start
|| aAttribute == nsGkAtoms::end) {
if (aAttribute == nsGkAtoms::loopstart
|| aAttribute == nsGkAtoms::loopend
|| aAttribute == nsGkAtoms::start
|| aAttribute == nsGkAtoms::end) {
return aResult.ParseFloatValue(aValue);
}
else if (ParseImageAttribute(aAttribute, aValue, aResult)) {

View File

@ -68,10 +68,6 @@ public:
// nsIDOMHTMLSourceElement
NS_DECL_NSIDOMHTMLSOURCEELEMENT
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
// Override BindToTree() so that we can trigger a load when we add a
@ -117,25 +113,6 @@ NS_IMPL_ELEMENT_CLONE(nsHTMLSourceElement)
NS_IMPL_URI_ATTR(nsHTMLSourceElement, Src, src)
NS_IMPL_STRING_ATTR(nsHTMLSourceElement, Type, type)
PRBool
nsHTMLSourceElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsGkAtoms::src) {
static const char* kWhitespace = " \n\r\t\b";
aResult.SetTo(nsContentUtils::TrimCharsInSet(kWhitespace, aValue));
return PR_TRUE;
}
}
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
nsresult
nsHTMLSourceElement::BindToTree(nsIDocument *aDocument,
nsIContent *aParent,

View File

@ -254,6 +254,7 @@ _TEST_FILES = \
test_bug619278.html \
test_bug622558.html \
test_bug622597.html \
test_bug636336.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=636336
-->
<head>
<title>Test for Bug 636336</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=636336">Mozilla Bug 636336</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 636336 **/
function testIt(tag) {
var elem = document.createElement(tag);
elem.setAttribute("src", " ");
is(elem.getAttribute("src"), " ",
tag + " src attribute setter should not strip whitespace");
elem.setAttribute("src", " test ");
is(elem.getAttribute("src"), " test ",
tag + " src attribute setter should not strip whitespace around non-whitespace");
is(elem.src, window.location.href.replace(/test_bug636336\.html$/, "test"),
tag + ".src should strip whitespace as needed");
}
testIt("img");
testIt("source");
testIt("audio");
testIt("video");
</script>
</pre>
</body>
</html>