Bug 1562690. Fix parsing of HTML dimension values to follow spec update and align better with other browsers. r=mccr8

See https://github.com/whatwg/html/pull/4747 for the spec changes

Differential Revision: https://phabricator.services.mozilla.com/D36643

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-07-03 06:36:17 +00:00
Родитель c7fc76c18f
Коммит 2ccccf1e48
11 изменённых файлов: 299 добавлений и 244 удалений

Просмотреть файл

@ -1272,7 +1272,7 @@ bool nsAttrValue::DoParseHTMLDimension(const nsAString& aInput,
// https://html.spec.whatwg.org/multipage/#rules-for-parsing-dimension-values
// Step 1 and 2.
// Steps 1 and 2.
const char16_t* position = aInput.BeginReading();
const char16_t* end = aInput.EndReading();
@ -1281,36 +1281,19 @@ bool nsAttrValue::DoParseHTMLDimension(const nsAString& aInput,
// leading '0' characters, or trailing garbage.
bool canonical = true;
// Step 3
// Step 3.
while (position != end && nsContentUtils::IsHTMLWhitespace(*position)) {
canonical = false; // Leading whitespace
++position;
}
// Step 4
if (position == end) {
// Step 4.
if (position == end || *position < char16_t('0') ||
*position > char16_t('9')) {
return false;
}
// Step 5
if (*position == char16_t('+')) {
canonical = false; // Leading '+'
++position;
// Step 6. The spec has this happening regardless of whether we found '+',
// but there's no point repeating the step 4 test if we didn't advance
// position.
if (position == end) {
return false;
}
}
// Step 7.
if (*position < char16_t('0') || *position > char16_t('9')) {
return false;
}
// Step 8.
// Step 5.
CheckedInt32 value = 0;
// Collect up leading '0' first to avoid extra branching in the main
@ -1333,28 +1316,35 @@ bool nsAttrValue::DoParseHTMLDimension(const nsAString& aInput,
++position;
}
// Step 9 is implemented implicitly via the various "position != end" guards
// Step 6 is implemented implicitly via the various "position != end" guards
// from this point on.
Maybe<double> doubleValue;
// Step 10.
// Step 7. The return in step 7.2 is handled by just falling through to the
// code below this block when we reach end of input or a non-digit, because
// the while loop will terminate at that point.
if (position != end && *position == char16_t('.')) {
canonical = false; // Let's not rely on double serialization reproducing
// the string we started with.
// Step 7.1.
++position;
// If we have a '.' _not_ followed by digits, this is not as efficient as it
// could be, because we will store as a double while we could have stored as
// an int. But that seems like a pretty rare case.
doubleValue.emplace(value.value());
// Step 7.3.
double divisor = 1.0f;
// Per spec we should now return a number if there is no next char or if the
// next char is not a digit, but no one does that. See
// https://github.com/whatwg/html/issues/4736
// Step 7.4.
while (position != end && *position >= char16_t('0') &&
*position <= char16_t('9')) {
// Step 7.4.1.
divisor = divisor * 10.0f;
// Step 7.4.2.
doubleValue.ref() += (*position - char16_t('0')) / divisor;
// Step 7.4.3.
++position;
// Step 7.4.4 and 7.4.5 are captured in the while loop condition and the
// "position != end" checks below.
}
}
@ -1364,7 +1354,7 @@ bool nsAttrValue::DoParseHTMLDimension(const nsAString& aInput,
return false;
}
// Steps 11-13.
// Step 8 and the spec's early return from step 7.2.
ValueType type;
if (position != end && *position == char16_t('%')) {
type = ePercent;

Просмотреть файл

@ -1418,7 +1418,21 @@ uint32_t nsGenericHTMLElement::GetDimensionAttrAsUnsignedInt(
return uint32_t(attrVal->GetDoubleValue());
}
return aDefault;
// Unfortunately, the set of values that are valid dimensions is not a
// superset of values that are valid unsigned ints. In particular "+100" is
// not a valid dimension, but should parse as the unsigned int "100". So if
// we got here and we don't have a valid dimension value, just try re-parsing
// the string we have as an integer.
nsAutoString val;
attrVal->ToString(val);
nsContentUtils::ParseHTMLIntegerResultFlags result;
int32_t parsedInt = nsContentUtils::ParseHTMLInteger(val, &result);
if ((result & nsContentUtils::eParseHTMLInteger_Error) ||
parsedInt < 0) {
return aDefault;
}
return parsedInt;
}
void nsGenericHTMLElement::GetURIAttr(nsAtom* aAttr, nsAtom* aBaseAttr,

Просмотреть файл

@ -905,6 +905,12 @@
[iframe.allowUserMedia: setAttribute() to "5%"]
expected: FAIL
[iframe.allowUserMedia: setAttribute() to "+100"]
expected: FAIL
[iframe.allowUserMedia: setAttribute() to ".5"]
expected: FAIL
[iframe.allowUserMedia: setAttribute() to true]
expected: FAIL
@ -956,6 +962,12 @@
[iframe.allowUserMedia: IDL set to "5%"]
expected: FAIL
[iframe.allowUserMedia: IDL set to "+100"]
expected: FAIL
[iframe.allowUserMedia: IDL set to ".5"]
expected: FAIL
[iframe.allowUserMedia: IDL set to false]
expected: FAIL
@ -1013,6 +1025,12 @@
[iframe.delegateStickyUserActivation: IDL set to "5%"]
expected: FAIL
[iframe.delegateStickyUserActivation: IDL set to "+100"]
expected: FAIL
[iframe.delegateStickyUserActivation: IDL set to ".5"]
expected: FAIL
[iframe.delegateStickyUserActivation: IDL set to true]
expected: FAIL
@ -1079,6 +1097,12 @@
[video.playsInline: IDL set to "5%"]
expected: FAIL
[video.playsInline: IDL set to "+100"]
expected: FAIL
[video.playsInline: IDL set to ".5"]
expected: FAIL
[video.playsInline: setAttribute() to object "test-valueOf"]
expected: FAIL
@ -1112,6 +1136,12 @@
[video.playsInline: setAttribute() to "5%"]
expected: FAIL
[video.playsInline: setAttribute() to "+100"]
expected: FAIL
[video.playsInline: setAttribute() to ".5"]
expected: FAIL
[video.playsInline: setAttribute() to object "[object Object\]"]
expected: FAIL

Просмотреть файл

@ -1966,6 +1966,12 @@
[input.dirName: setAttribute() to "5%"]
expected: FAIL
[input.dirName: setAttribute() to "+100"]
expected: FAIL
[input.dirName: setAttribute() to ".5"]
expected: FAIL
[input.dirName: setAttribute() to true]
expected: FAIL
@ -2014,6 +2020,12 @@
[input.dirName: IDL set to "5%"]
expected: FAIL
[input.dirName: IDL set to "+100"]
expected: FAIL
[input.dirName: IDL set to ".5"]
expected: FAIL
[input.dirName: IDL set to true]
expected: FAIL
@ -2494,6 +2506,12 @@
[textarea.dirName: setAttribute() to "5%"]
expected: FAIL
[textarea.dirName: setAttribute() to "+100"]
expected: FAIL
[textarea.dirName: setAttribute() to ".5"]
expected: FAIL
[textarea.dirName: setAttribute() to true]
expected: FAIL
@ -2542,6 +2560,12 @@
[textarea.dirName: IDL set to "5%"]
expected: FAIL
[textarea.dirName: IDL set to "+100"]
expected: FAIL
[textarea.dirName: IDL set to ".5"]
expected: FAIL
[textarea.dirName: IDL set to true]
expected: FAIL

Просмотреть файл

@ -59,6 +59,12 @@
[link.nonce: setAttribute() to "5%"]
expected: FAIL
[link.nonce: setAttribute() to "+100"]
expected: FAIL
[link.nonce: setAttribute() to ".5"]
expected: FAIL
[link.nonce: setAttribute() to true]
expected: FAIL
@ -107,6 +113,12 @@
[link.nonce: IDL set to "5%"]
expected: FAIL
[link.nonce: IDL set to "+100"]
expected: FAIL
[link.nonce: IDL set to ".5"]
expected: FAIL
[link.nonce: IDL set to true]
expected: FAIL
@ -710,6 +722,12 @@
[style.nonce: setAttribute() to "5%"]
expected: FAIL
[style.nonce: setAttribute() to "+100"]
expected: FAIL
[style.nonce: setAttribute() to ".5"]
expected: FAIL
[style.nonce: setAttribute() to true]
expected: FAIL
@ -758,6 +776,12 @@
[style.nonce: IDL set to "5%"]
expected: FAIL
[style.nonce: IDL set to "+100"]
expected: FAIL
[style.nonce: IDL set to ".5"]
expected: FAIL
[style.nonce: IDL set to true]
expected: FAIL

Просмотреть файл

@ -627,6 +627,12 @@
[script.nonce: setAttribute() to "5%"]
expected: FAIL
[script.nonce: setAttribute() to "+100"]
expected: FAIL
[script.nonce: setAttribute() to ".5"]
expected: FAIL
[script.nonce: setAttribute() to true]
expected: FAIL
@ -675,6 +681,12 @@
[script.nonce: IDL set to "5%"]
expected: FAIL
[script.nonce: IDL set to "+100"]
expected: FAIL
[script.nonce: IDL set to ".5"]
expected: FAIL
[script.nonce: IDL set to true]
expected: FAIL
@ -729,6 +741,12 @@
[undefinedelement.inputMode: setAttribute() to "5%"]
expected: FAIL
[undefinedelement.inputMode: setAttribute() to "+100"]
expected: FAIL
[undefinedelement.inputMode: setAttribute() to ".5"]
expected: FAIL
[undefinedelement.inputMode: setAttribute() to true]
expected: FAIL
@ -897,6 +915,12 @@
[undefinedelement.inputMode: IDL set to "5%"]
expected: FAIL
[undefinedelement.inputMode: IDL set to "+100"]
expected: FAIL
[undefinedelement.inputMode: IDL set to ".5"]
expected: FAIL
[undefinedelement.inputMode: IDL set to true]
expected: FAIL
@ -1257,12 +1281,24 @@
[undefinedelement.enterKeyHint: IDL set to "5%"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to "+100"]
expected: FAIL
[undefinedelement.enterKeyHint: IDL set to ".5"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to 1.5]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "5%"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "+100"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to ".5"]
expected: FAIL
[undefinedelement.enterKeyHint: setAttribute() to "next"]
expected: FAIL

Просмотреть файл

@ -29,6 +29,12 @@
[applet.align: setAttribute() to "5%"]
expected: FAIL
[applet.align: setAttribute() to "+100"]
expected: FAIL
[applet.align: setAttribute() to ".5"]
expected: FAIL
[applet.align: setAttribute() to true]
expected: FAIL
@ -77,6 +83,12 @@
[applet.align: IDL set to "5%"]
expected: FAIL
[applet.align: IDL set to "+100"]
expected: FAIL
[applet.align: IDL set to ".5"]
expected: FAIL
[applet.align: IDL set to true]
expected: FAIL
@ -131,6 +143,12 @@
[applet.alt: setAttribute() to "5%"]
expected: FAIL
[applet.alt: setAttribute() to "+100"]
expected: FAIL
[applet.alt: setAttribute() to ".5"]
expected: FAIL
[applet.alt: setAttribute() to true]
expected: FAIL
@ -179,6 +197,12 @@
[applet.alt: IDL set to "5%"]
expected: FAIL
[applet.alt: IDL set to "+100"]
expected: FAIL
[applet.alt: IDL set to ".5"]
expected: FAIL
[applet.alt: IDL set to true]
expected: FAIL
@ -233,6 +257,12 @@
[applet.archive: setAttribute() to "5%"]
expected: FAIL
[applet.archive: setAttribute() to "+100"]
expected: FAIL
[applet.archive: setAttribute() to ".5"]
expected: FAIL
[applet.archive: setAttribute() to true]
expected: FAIL
@ -281,6 +311,12 @@
[applet.archive: IDL set to "5%"]
expected: FAIL
[applet.archive: IDL set to "+100"]
expected: FAIL
[applet.archive: IDL set to ".5"]
expected: FAIL
[applet.archive: IDL set to true]
expected: FAIL
@ -335,6 +371,12 @@
[applet.code: setAttribute() to "5%"]
expected: FAIL
[applet.code: setAttribute() to "+100"]
expected: FAIL
[applet.code: setAttribute() to ".5"]
expected: FAIL
[applet.code: setAttribute() to true]
expected: FAIL
@ -383,6 +425,12 @@
[applet.code: IDL set to "5%"]
expected: FAIL
[applet.code: IDL set to "+100"]
expected: FAIL
[applet.code: IDL set to ".5"]
expected: FAIL
[applet.code: IDL set to true]
expected: FAIL
@ -446,6 +494,12 @@
[applet.codeBase: setAttribute() to "5%"]
expected: FAIL
[applet.codeBase: setAttribute() to "+100"]
expected: FAIL
[applet.codeBase: setAttribute() to ".5"]
expected: FAIL
[applet.codeBase: setAttribute() to true]
expected: FAIL
@ -503,6 +557,12 @@
[applet.codeBase: IDL set to "5%"]
expected: FAIL
[applet.codeBase: IDL set to "+100"]
expected: FAIL
[applet.codeBase: IDL set to ".5"]
expected: FAIL
[applet.codeBase: IDL set to true]
expected: FAIL
@ -557,6 +617,12 @@
[applet.height: setAttribute() to "5%"]
expected: FAIL
[applet.height: setAttribute() to "+100"]
expected: FAIL
[applet.height: setAttribute() to ".5"]
expected: FAIL
[applet.height: setAttribute() to true]
expected: FAIL
@ -605,6 +671,12 @@
[applet.height: IDL set to "5%"]
expected: FAIL
[applet.height: IDL set to "+100"]
expected: FAIL
[applet.height: IDL set to ".5"]
expected: FAIL
[applet.height: IDL set to true]
expected: FAIL
@ -776,6 +848,12 @@
[applet.hspace: setAttribute() to "5%"]
expected: FAIL
[applet.hspace: setAttribute() to "+100"]
expected: FAIL
[applet.hspace: setAttribute() to ".5"]
expected: FAIL
[applet.hspace: setAttribute() to true]
expected: FAIL
@ -848,6 +926,12 @@
[applet.name: setAttribute() to "5%"]
expected: FAIL
[applet.name: setAttribute() to "+100"]
expected: FAIL
[applet.name: setAttribute() to ".5"]
expected: FAIL
[applet.name: setAttribute() to true]
expected: FAIL
@ -896,6 +980,12 @@
[applet.name: IDL set to "5%"]
expected: FAIL
[applet.name: IDL set to "+100"]
expected: FAIL
[applet.name: IDL set to ".5"]
expected: FAIL
[applet.name: IDL set to true]
expected: FAIL
@ -959,6 +1049,12 @@
[applet.object: setAttribute() to "5%"]
expected: FAIL
[applet.object: setAttribute() to "+100"]
expected: FAIL
[applet.object: setAttribute() to ".5"]
expected: FAIL
[applet.object: setAttribute() to true]
expected: FAIL
@ -1016,6 +1112,12 @@
[applet.object: IDL set to "5%"]
expected: FAIL
[applet.object: IDL set to "+100"]
expected: FAIL
[applet.object: IDL set to ".5"]
expected: FAIL
[applet.object: IDL set to true]
expected: FAIL
@ -1187,6 +1289,12 @@
[applet.vspace: setAttribute() to "5%"]
expected: FAIL
[applet.vspace: setAttribute() to "+100"]
expected: FAIL
[applet.vspace: setAttribute() to ".5"]
expected: FAIL
[applet.vspace: setAttribute() to true]
expected: FAIL
@ -1259,6 +1367,12 @@
[applet.width: setAttribute() to "5%"]
expected: FAIL
[applet.width: setAttribute() to "+100"]
expected: FAIL
[applet.width: setAttribute() to ".5"]
expected: FAIL
[applet.width: setAttribute() to true]
expected: FAIL
@ -1307,6 +1421,12 @@
[applet.width: IDL set to "5%"]
expected: FAIL
[applet.width: IDL set to "+100"]
expected: FAIL
[applet.width: IDL set to ".5"]
expected: FAIL
[applet.width: IDL set to true]
expected: FAIL

Просмотреть файл

@ -1,224 +1,36 @@
[dimension-attributes.html]
[<hr width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<iframe width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<input width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<marquee width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<video width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<object width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<embed width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<img width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<td width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<table width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<col width="200.%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<col width="0"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4717
[<col width="+0"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4717
[<col width="0%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4717
[<col width="+0%"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4717
[<col width="0px"> mapping to width]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4717
[<iframe height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<input height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<marquee height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<video height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<object height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<embed height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<img height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<td height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<table height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<table height="0"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4715
[<table height="+0"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4715
[<table height="0%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4715
[<table height="+0%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4715
[<table height="0px"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4715
[<tr height="200.%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<tr height="0"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4716
[<tr height="+0"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4716
[<tr height="0%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4716
[<tr height="+0%"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4716
[<tr height="0px"> mapping to height]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4716
[<embed hspace="200.%"> mapping to marginLeft]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<embed hspace="200.%"> mapping to marginRight]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<embed vspace="200.%"> mapping to marginTop]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<embed vspace="200.%"> mapping to marginBottom]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<img hspace="200.%"> mapping to marginLeft]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<img hspace="200.%"> mapping to marginRight]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<img vspace="200.%"> mapping to marginTop]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<img vspace="200.%"> mapping to marginBottom]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<object hspace="200.%"> mapping to marginLeft]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<object hspace="200.%"> mapping to marginRight]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<object vspace="200.%"> mapping to marginTop]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<object vspace="200.%"> mapping to marginBottom]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<input hspace="200.%"> mapping to marginLeft]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<input hspace="200.%"> mapping to marginRight]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<input vspace="200.%"> mapping to marginTop]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<input vspace="200.%"> mapping to marginBottom]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<marquee hspace="200.%"> mapping to marginLeft]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<marquee hspace="200.%"> mapping to marginRight]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<marquee vspace="200.%"> mapping to marginTop]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736
[<marquee vspace="200.%"> mapping to marginBottom]
expected: FAIL
bug: https://github.com/whatwg/html/issues/4736

Просмотреть файл

@ -145,7 +145,7 @@ ReflectionTests.typeMap = {
"string": {
"jsType": "string",
"defaultVal": "",
"domTests": ["", " " + binaryString + " foo ", undefined, 7, 1.5, "5%", true,
"domTests": ["", " " + binaryString + " foo ", undefined, 7, 1.5, "5%", "+100", ".5", true,
false, {"test": 6}, NaN, +Infinity, -Infinity, "\0", null,
{"toString":function(){return "test-toString";}},
{"valueOf":function(){return "test-valueOf";}, toString:null}
@ -168,7 +168,7 @@ ReflectionTests.typeMap = {
"jsType": "string",
"defaultVal": "",
"domTests": ["", " foo ", "http://site.example/",
"//site.example/path???@#l", binaryString, undefined, 7, 1.5, "5%", true,
"//site.example/path???@#l", binaryString, undefined, 7, 1.5, "5%", "+100", ".5", true,
false, {"test": 6}, NaN, +Infinity, -Infinity, "\0", null,
{"toString":function(){return "test-toString";}},
{"valueOf":function(){return "test-valueOf";}, toString:null}],
@ -233,7 +233,7 @@ ReflectionTests.typeMap = {
"enum": {
"jsType": "string",
"defaultVal": "",
"domTests": ["", " " + binaryString + " foo ", undefined, 7, 1.5, "5%", true,
"domTests": ["", " " + binaryString + " foo ", undefined, 7, 1.5, "5%", "+100", ".5", true,
false, {"test": 6}, NaN, +Infinity, -Infinity, "\0", null,
{"toString":function(){return "test-toString";}},
{"valueOf":function(){return "test-valueOf";}, toString:null}]
@ -249,7 +249,7 @@ ReflectionTests.typeMap = {
"boolean": {
"jsType": "boolean",
"defaultVal": false,
"domTests": ["", " foo ", undefined, null, 7, 1.5, "5%", true, false,
"domTests": ["", " foo ", undefined, null, 7, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{"toString":function(){return "test-toString";}},
{"valueOf":function(){return "test-valueOf";}, toString:null}],
@ -282,7 +282,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
undefined, 1.5, "5%", true, false, {"test": 6}, NaN, +Infinity,
undefined, 1.5, "5%", "+100", ".5", true, false, {"test": 6}, NaN, +Infinity,
-Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
@ -321,7 +321,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
undefined, 1.5, "5%", true, false, {"test": 6}, NaN, +Infinity,
undefined, 1.5, "5%", "+100", ".5", true, false, {"test": 6}, NaN, +Infinity,
-Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
@ -357,7 +357,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
@ -399,7 +399,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
@ -439,7 +439,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
@ -478,7 +478,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
@ -519,7 +519,7 @@ ReflectionTests.typeMap = {
"\u20007", "\u20017", "\u20027", "\u20037", "\u20047", "\u20057",
"\u20067", "\u20077", "\u20087", "\u20097", "\u200A7", "\u202F7",
"\u30007",
" " + binaryString + " foo ", undefined, 1.5, "5%", true, false,
" " + binaryString + " foo ", undefined, 1.5, "5%", "+100", ".5", true, false,
{"test": 6}, NaN, +Infinity, -Infinity, "\0",
{toString:function() {return 2;}, valueOf: null},
{valueOf:function() {return 3;}}],
@ -532,7 +532,7 @@ ReflectionTests.typeMap = {
null, null, null, null, null, null,
null,
// End leading whitespace tests
null, null, 1.5, 5, null, null,
null, null, 1.5, 5, 100, 0.5, null, null,
null, null, null, null, null,
2, 3],
// I checked that ES ToString is well-defined for all of these (I

Просмотреть файл

@ -35,22 +35,16 @@ const valid_values = [
[ "200.25", "200.25px" ],
[ "200.7", "200.7px" ],
[ "200.", "200px" ],
[ "+200", "200px" ],
[ "200in", "200px" ],
[ "200.25in", "200.25px" ],
[ " +200in ", "200px" ],
[ " +200.25in ", "200.25px" ],
[ "200 %", "200px" ],
[ "200 abc", "200px" ],
[ "200%", "200%" ],
[ "200%abc", "200%" ],
[ "+200%", "200%" ],
[ "200.25%", "200.25%" ],
// https://github.com/whatwg/html/issues/4736 tracks the fact that "200.%"
// should probably be mapped as "200%", not "200px".
[ "200.%", "200px" ],
[ " +200.25% ", "200.25%" ],
[ " +200.25%abc", "200.25%" ],
[ "200.%", "200%" ],
[ "20.25e2", "20.25px" ],
[ "20.25E2", "20.25px" ],
];
/*
@ -58,9 +52,7 @@ const valid_values = [
*/
const zero_values = [
[ "0", "0px" ],
[ "+0", "0px" ],
[ "0%", "0%" ],
[ "+0%", "0%" ],
[ "0px", "0px" ],
];
@ -76,7 +68,20 @@ const invalid_values = [
" -200",
"+-200",
"-+200",
"-200%"
"-200%",
"+200",
" +200in ",
" +200.25in ",
"+200%",
" +200.25% ",
" +200.25%abc",
"+0",
"+0%",
".",
".%",
".x",
".5",
".5%"
];
const valid_values_with_0 =

Просмотреть файл

@ -14,6 +14,6 @@
<div class=hr style="width: 100.99px"></div>
<div class=hr style="width: 0%"></div>
<div class=hr style="width: 0%"></div>
<div class=hr style="width: 0%"></div>
<div class=hr style="width: 0%"></div>
<div class=hr></div>
<div class=hr></div>
<div class=hr></div>