зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1270499 - Setting reflected unsigned long to out-of-range value should set to default; r=bz
This changes to match the spec, which also aligns the behavior of get and set (get already maps out-of-range values to the default value). There is currently no interoperable behavior here, but this aligns us with IE -- tested in 11, hopefully true for Edge too. On the way, I also fixed the fact that video's height and width were being treated as signed.
This commit is contained in:
Родитель
ccf82a74c7
Коммит
9aba692542
|
@ -1358,12 +1358,14 @@ HTMLCanvasElement::SetAttrFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRenderer
|
|||
gfx::IntSize asyncCanvasSize = aRenderer->GetSize();
|
||||
|
||||
ErrorResult rv;
|
||||
element->SetUnsignedIntAttr(nsGkAtoms::width, asyncCanvasSize.width, rv);
|
||||
element->SetUnsignedIntAttr(nsGkAtoms::width, asyncCanvasSize.width,
|
||||
DEFAULT_CANVAS_WIDTH, rv);
|
||||
if (rv.Failed()) {
|
||||
NS_WARNING("Failed to set width attribute to a canvas element asynchronously.");
|
||||
}
|
||||
|
||||
element->SetUnsignedIntAttr(nsGkAtoms::height, asyncCanvasSize.height, rv);
|
||||
element->SetUnsignedIntAttr(nsGkAtoms::height, asyncCanvasSize.height,
|
||||
DEFAULT_CANVAS_HEIGHT, rv);
|
||||
if (rv.Failed()) {
|
||||
NS_WARNING("Failed to set height attribute to a canvas element asynchronously.");
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
SetUnsignedIntAttr(nsGkAtoms::height, aHeight, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::height, aHeight, DEFAULT_CANVAS_HEIGHT, aRv);
|
||||
}
|
||||
uint32_t Width()
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
SetUnsignedIntAttr(nsGkAtoms::width, aWidth, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::width, aWidth, DEFAULT_CANVAS_WIDTH, aRv);
|
||||
}
|
||||
|
||||
virtual already_AddRefed<nsISupports>
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
}
|
||||
void SetWidth(uint32_t aWidth, ErrorResult& aError)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::width, aWidth, aError);
|
||||
SetUnsignedIntAttr(nsGkAtoms::width, aWidth, 0, aError);
|
||||
}
|
||||
uint32_t Height()
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
}
|
||||
void SetHeight(uint32_t aHeight, ErrorResult& aError)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::height, aHeight, aError);
|
||||
SetUnsignedIntAttr(nsGkAtoms::height, aHeight, 0, aError);
|
||||
}
|
||||
uint32_t NaturalWidth();
|
||||
uint32_t NaturalHeight();
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
}
|
||||
void SetHspace(uint32_t aHspace, ErrorResult& aError)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::hspace, aHspace, aError);
|
||||
SetUnsignedIntAttr(nsGkAtoms::hspace, aHspace, 0, aError);
|
||||
}
|
||||
uint32_t Vspace()
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
}
|
||||
void SetVspace(uint32_t aVspace, ErrorResult& aError)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::vspace, aVspace, aError);
|
||||
SetUnsignedIntAttr(nsGkAtoms::vspace, aVspace, 0, aError);
|
||||
}
|
||||
|
||||
// The XPCOM versions of the following getters work for Web IDL bindings as well
|
||||
|
|
|
@ -484,7 +484,7 @@ public:
|
|||
|
||||
void SetHeight(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::height, aValue, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::height, aValue, 0, aRv);
|
||||
}
|
||||
|
||||
bool Indeterminate() const
|
||||
|
@ -588,7 +588,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
SetUnsignedIntAttr(nsGkAtoms::size, aValue, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::size, aValue, DEFAULT_COLS, aRv);
|
||||
}
|
||||
|
||||
// XPCOM GetSrc() is OK
|
||||
|
@ -641,7 +641,7 @@ public:
|
|||
|
||||
void SetWidth(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::width, aValue, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::width, aValue, 0, aRv);
|
||||
}
|
||||
|
||||
void StepUp(int32_t aN, ErrorResult& aRv)
|
||||
|
|
|
@ -192,7 +192,7 @@ public:
|
|||
}
|
||||
void SetHspace(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::hspace, aValue, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::hspace, aValue, 0, aRv);
|
||||
}
|
||||
void GetStandby(DOMString& aValue)
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ public:
|
|||
}
|
||||
void SetVspace(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::vspace, aValue, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::vspace, aValue, 0, aRv);
|
||||
}
|
||||
// XPCOM GetCodebase is ok; note that it's a URI attribute
|
||||
void SetCodeBase(const nsAString& aValue, ErrorResult& aRv)
|
||||
|
|
|
@ -210,7 +210,7 @@ public:
|
|||
}
|
||||
void SetSize(uint32_t aSize, ErrorResult& aRv)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::size, aSize, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::size, aSize, 0, aRv);
|
||||
}
|
||||
|
||||
// Uses XPCOM GetType.
|
||||
|
|
|
@ -137,7 +137,7 @@ public:
|
|||
}
|
||||
void SetHspace(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::hspace, aValue, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::hspace, aValue, 0, aRv);
|
||||
}
|
||||
void GetName(DOMString& aValue)
|
||||
{
|
||||
|
@ -158,7 +158,7 @@ public:
|
|||
}
|
||||
void SetVspace(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetUnsignedIntAttr(nsGkAtoms::vspace, aValue, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::vspace, aValue, 0, aRv);
|
||||
}
|
||||
void GetWidth(DOMString& aValue)
|
||||
{
|
||||
|
|
|
@ -179,7 +179,7 @@ public:
|
|||
if (aCols == 0) {
|
||||
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
} else {
|
||||
SetUnsignedIntAttr(nsGkAtoms::cols, aCols, aError);
|
||||
SetUnsignedIntAttr(nsGkAtoms::cols, aCols, DEFAULT_COLS, aError);
|
||||
}
|
||||
}
|
||||
bool Disabled()
|
||||
|
@ -247,7 +247,7 @@ public:
|
|||
if (aRows == 0) {
|
||||
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
} else {
|
||||
SetUnsignedIntAttr(nsGkAtoms::rows, aRows, aError);
|
||||
SetUnsignedIntAttr(nsGkAtoms::rows, aRows, DEFAULT_ROWS_TEXTAREA, aError);
|
||||
}
|
||||
}
|
||||
// XPCOM GetWrap is fine
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
void SetWidth(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLIntAttr(nsGkAtoms::width, aValue, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::width, aValue, 0, aRv);
|
||||
}
|
||||
|
||||
uint32_t Height() const
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
void SetHeight(uint32_t aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLIntAttr(nsGkAtoms::height, aValue, aRv);
|
||||
SetUnsignedIntAttr(nsGkAtoms::height, aValue, 0, aRv);
|
||||
}
|
||||
|
||||
uint32_t VideoWidth() const
|
||||
|
|
|
@ -1136,12 +1136,19 @@ protected:
|
|||
*
|
||||
* @param aAttr name of attribute.
|
||||
* @param aValue Integer value of attribute.
|
||||
* @param aDefault Default value (in case value is out of range). If the spec
|
||||
* doesn't provide one, should be 1 if the value is limited to
|
||||
* nonzero values, and 0 otherwise.
|
||||
*/
|
||||
void SetUnsignedIntAttr(nsIAtom* aName, uint32_t aValue,
|
||||
void SetUnsignedIntAttr(nsIAtom* aName, uint32_t aValue, uint32_t aDefault,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
nsAutoString value;
|
||||
value.AppendInt(aValue);
|
||||
if (aValue > INT32_MAX) {
|
||||
value.AppendInt(aDefault);
|
||||
} else {
|
||||
value.AppendInt(aValue);
|
||||
}
|
||||
|
||||
SetHTMLAttr(aName, value, aError);
|
||||
}
|
||||
|
@ -1555,7 +1562,7 @@ protected:
|
|||
_class::Set##_method(uint32_t aValue) \
|
||||
{ \
|
||||
mozilla::ErrorResult rv; \
|
||||
SetUnsignedIntAttr(nsGkAtoms::_atom, aValue, rv); \
|
||||
SetUnsignedIntAttr(nsGkAtoms::_atom, aValue, _default, rv); \
|
||||
return rv.StealNSResult(); \
|
||||
}
|
||||
|
||||
|
@ -1582,7 +1589,7 @@ protected:
|
|||
return NS_ERROR_DOM_INDEX_SIZE_ERR; \
|
||||
} \
|
||||
mozilla::ErrorResult rv; \
|
||||
SetUnsignedIntAttr(nsGkAtoms::_atom, aValue, rv); \
|
||||
SetUnsignedIntAttr(nsGkAtoms::_atom, aValue, _default, rv); \
|
||||
return rv.StealNSResult(); \
|
||||
}
|
||||
|
||||
|
|
|
@ -176,24 +176,21 @@ function reflectUnsignedInt(aParameters)
|
|||
is(element.getAttribute(attr), "1294967296",
|
||||
"@" + attr + " should be equals to 1294967296");
|
||||
|
||||
// When setting the content atribute, it's a string so it will be unvalid.
|
||||
// When setting the content attribute, it's a string so it will be invalid.
|
||||
element.setAttribute(attr, -3000000000);
|
||||
is(element.getAttribute(attr), "-3000000000",
|
||||
"@" + attr + " should be equals to " + -3000000000);
|
||||
is(element[attr], defaultValue,
|
||||
"." + attr + " should be equals to " + defaultValue);
|
||||
|
||||
var nonValidValues = [
|
||||
/* invalid value, value in the unsigned int range */
|
||||
[ -2147483648, 2147483648 ],
|
||||
[ -1, 4294967295 ],
|
||||
[ 3147483647, 3147483647 ],
|
||||
];
|
||||
// When interpreted as unsigned 32-bit integers, all of these fall between
|
||||
// 2^31 and 2^32 - 1, so per spec they return the default value.
|
||||
var nonValidValues = [ -2147483648, -1, 3147483647];
|
||||
|
||||
for (var values of nonValidValues) {
|
||||
element[attr] = values[0];
|
||||
is(element.getAttribute(attr), String(values[1]),
|
||||
"@" + attr + " should be equals to " + values[1]);
|
||||
for (var value of nonValidValues) {
|
||||
element[attr] = value;
|
||||
is(element.getAttribute(attr), String(defaultValue),
|
||||
"@" + attr + " should be equals to " + defaultValue);
|
||||
is(element[attr], defaultValue,
|
||||
"." + attr + " should be equals to " + defaultValue);
|
||||
}
|
||||
|
|
|
@ -951,63 +951,3 @@
|
|||
[area.type: IDL set to object "test-valueOf" followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[img.width: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[img.width: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[img.height: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[img.height: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[img.hspace: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[img.hspace: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[img.vspace: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[img.vspace: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[object.hspace: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[object.hspace: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[object.vspace: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[object.vspace: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[video.width: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[video.width: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[video.height: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[video.height: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[canvas.width: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[canvas.width: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[canvas.height: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[canvas.height: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -2056,27 +2056,3 @@
|
|||
[meter.tabIndex: IDL set to -2147483648 followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[input.size: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[input.size: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[select.size: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[select.size: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[textarea.cols: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[textarea.cols: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[textarea.rows: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[textarea.rows: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1557,18 +1557,6 @@
|
|||
[font.tabIndex: IDL set to -2147483648 followed by IDL get]
|
||||
expected: FAIL
|
||||
|
||||
[applet.hspace: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[applet.hspace: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[applet.vspace: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[applet.vspace: IDL set to 4294967295 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
[marquee.hspace: IDL set to 2147483648 followed by getAttribute()]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче