Bug 878950 - Add a test for HTMLImageElement and fix h/vspace reflection; r=mounir
authorMs2ger <ms2ger@gmail.com>
Sun, 23 Jun 2013 09:14:15 +0200
changeset 147637 e84d4694a55380af7f95b8659930e6aca6e15530
parent 147636 7111de8a8687ed9bc1a7c5e9deec324570bc19de
child 147638 0683fdc7baaa2cc4aa8f6f3c9287468c7a592d63
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs878950
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 878950 - Add a test for HTMLImageElement and fix h/vspace reflection; r=mounir
content/html/content/src/HTMLImageElement.cpp
content/html/content/src/HTMLImageElement.h
content/html/content/test/Makefile.in
content/html/content/test/test_bug664299.html
content/html/content/test/test_img_attributes_reflection.html
--- a/content/html/content/src/HTMLImageElement.cpp
+++ b/content/html/content/src/HTMLImageElement.cpp
@@ -101,16 +101,17 @@ HTMLImageElement::GetItemValueText(nsASt
 void
 HTMLImageElement::SetItemValueText(const nsAString& aValue)
 {
   SetSrc(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
 HTMLImageElement::Draggable() const
 {
   // images may be dragged unless the draggable attribute is false
   return !AttrValueIs(kNameSpaceID_None, nsGkAtoms::draggable,
                       nsGkAtoms::_false, eIgnoreCase);
--- a/content/html/content/src/HTMLImageElement.h
+++ b/content/html/content/src/HTMLImageElement.h
@@ -110,31 +110,31 @@ public:
   }
   void SetHeight(uint32_t aHeight, ErrorResult& aError)
   {
     SetUnsignedIntAttr(nsGkAtoms::height, aHeight, aError);
   }
   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
   void SetAlt(const nsAString& aAlt, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::alt, aAlt, aError);
   }
   void SetSrc(const nsAString& aSrc, ErrorResult& aError)
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -207,17 +207,16 @@ MOCHITEST_FILES = \
 		test_bug560112.html \
 		test_bug586786.html \
 		test_bug646157.html \
 		test_bug649134.html \
 		test_bug658746.html \
 		test_bug659596.html \
 		test_bug659743.xml \
 		test_bug660663.html \
-		test_bug664299.html \
 		test_bug666200.html \
 		test_bug666666.html \
 		test_bug669012.html \
 		test_bug674558.html \
 		test_bug583533.html \
 		test_restore_from_parser_fragment.html \
 		test_bug615595.html \
 		test_bug617528.html \
@@ -355,16 +354,17 @@ MOCHITEST_FILES = \
 		file_iframe_sandbox_window_navigation_fail.html \
 		test_iframe_sandbox_plugins.html \
 		file_iframe_sandbox_f_if1.html \
 		file_iframe_sandbox_f_if2.html \
 		file_iframe_sandbox_f_if2.html^headers^ \
 		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 \
 		test_rowscollection.html \
 		test_map_attributes_reflection.html \
 		test_meta_attributes_reflection.html \
 		test_mod_attributes_reflection.html \
 		test_mozaudiochannel.html \
deleted file mode 100644
--- a/content/html/content/test/test_bug664299.html
+++ /dev/null
@@ -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>
new file mode 100644
--- /dev/null
+++ b/content/html/content/test/test_img_attributes_reflection.html
@@ -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>