Bug 878950 - Add a test for HTMLImageElement and fix h/vspace reflection; r=mounir

This commit is contained in:
Ms2ger 2013-06-23 09:14:15 +02:00
parent 984de31759
commit 80712a2075
5 changed files with 109 additions and 38 deletions

View File

@ -106,6 +106,7 @@ HTMLImageElement::SetItemValueText(const nsAString& aValue)
// crossorigin is not "limited to only known values" per spec, so it's
// just a string attr purposes of the DOM crossOrigin property.
// TODO: It is now (bug 880997).
NS_IMPL_STRING_ATTR(HTMLImageElement, CrossOrigin, crossorigin)
bool

View File

@ -115,21 +115,21 @@ public:
uint32_t NaturalWidth();
uint32_t NaturalHeight();
bool Complete();
int32_t Hspace()
uint32_t Hspace()
{
return GetIntAttr(nsGkAtoms::hspace, 0);
return GetUnsignedIntAttr(nsGkAtoms::hspace, 0);
}
void SetHspace(int32_t aHspace, ErrorResult& aError)
void SetHspace(uint32_t aHspace, ErrorResult& aError)
{
SetHTMLIntAttr(nsGkAtoms::hspace, aHspace, aError);
SetUnsignedIntAttr(nsGkAtoms::hspace, aHspace, aError);
}
int32_t Vspace()
uint32_t Vspace()
{
return GetIntAttr(nsGkAtoms::vspace, 0);
return GetUnsignedIntAttr(nsGkAtoms::vspace, 0);
}
void SetVspace(int32_t aVspace, ErrorResult& aError)
void SetVspace(uint32_t aVspace, ErrorResult& aError)
{
SetHTMLIntAttr(nsGkAtoms::vspace, aVspace, aError);
SetUnsignedIntAttr(nsGkAtoms::vspace, aVspace, aError);
}
// The XPCOM versions of the following getters work for Web IDL bindings as well

View File

@ -212,7 +212,6 @@ MOCHITEST_FILES = \
test_bug659596.html \
test_bug659743.xml \
test_bug660663.html \
test_bug664299.html \
test_bug666200.html \
test_bug666666.html \
test_bug669012.html \
@ -360,6 +359,7 @@ MOCHITEST_FILES = \
test_iframe_sandbox_workers.html \
file_iframe_sandbox_g_if1.html \
file_iframe_sandbox_worker.js \
test_img_attributes_reflection.html \
test_named_options.html \
test_htmlcollection.html \
test_formelements.html \

View File

@ -1,29 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=664299
-->
<head>
<title>Test for Bug 664299</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="reflect.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=664299">Mozilla Bug 664299</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test to ensure we reflect <img crossorigin> correctly **/
reflectString({
element: new Image(),
attribute: "crossOrigin",
otherValues: [ "", "anonymous", "ANONYMOUS", " aNOnYmous ",
"use-credentials", "USE-CREDENTIALS", " UsE-CreDEntIALS ",
"foobar", "FOOBAR", " fOoBaR " ]});
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,99 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for HTMLImageElement attributes reflection</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="reflect.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for HTMLImageElement attributes reflection **/
reflectString({
element: document.createElement("img"),
attribute: "alt",
})
reflectURL({
element: document.createElement("img"),
attribute: "src",
})
todo("srcset" in document.createElement("img"), "Should implement srcset")
// TODO: Bug 880997 - Make crossOrigin a limited enumerated attribute.
reflectString({
element: document.createElement("img"),
attribute: "crossOrigin",
otherValues: [
"", "anonymous", "ANONYMOUS", " aNOnYmous ",
"use-credentials", "USE-CREDENTIALS", " UsE-CreDEntIALS ",
"foobar", "FOOBAR", " fOoBaR "
]
})
reflectString({
element: document.createElement("img"),
attribute: "useMap",
})
reflectBoolean({
element: document.createElement("img"),
attribute: "isMap",
})
ok("width" in document.createElement("img"), "img.width is present")
ok("height" in document.createElement("img"), "img.height is present")
ok("naturalWidth" in document.createElement("img"), "img.naturalWidth is present")
ok("naturalHeight" in document.createElement("img"), "img.naturalHeight is present")
ok("complete" in document.createElement("img"), "img.complete is present")
reflectString({
element: document.createElement("img"),
attribute: "name",
})
reflectString({
element: document.createElement("img"),
attribute: "align",
})
reflectUnsignedInt({
element: document.createElement("img"),
attribute: "hspace",
})
reflectUnsignedInt({
element: document.createElement("img"),
attribute: "vspace",
})
reflectURL({
element: document.createElement("img"),
attribute: "longDesc",
})
reflectString({
element: document.createElement("img"),
attribute: "border",
extendedAttributes: { TreatNullAs: "EmptyString" },
})
// TODO: Bug 881000 - Consider reflecting lowsrc as a URL.
reflectString({
element: document.createElement("img"),
attribute: "lowsrc",
})
ok("x" in document.createElement("img"), "img.x is present")
ok("y" in document.createElement("img"), "img.y is present")
</script>
</pre>
</body>
</html>