mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1603615 - [Clamp] and [EnforceRange] should only appear on integer types; r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D57018 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
271d1b6d1d
commit
12f24b3f73
@ -3162,7 +3162,7 @@ class IDLBuiltinType(IDLType):
|
||||
self._clamped = None
|
||||
self._rangeEnforced = None
|
||||
self._withTreatNullAs = None
|
||||
if self.isNumeric():
|
||||
if self.isInteger():
|
||||
if clamp:
|
||||
self.clamp = True
|
||||
self.name = "Clamped" + self.name
|
||||
@ -3172,7 +3172,7 @@ class IDLBuiltinType(IDLType):
|
||||
self.name = "RangeEnforced" + self.name
|
||||
self._extendedAttrDict["EnforceRange"] = True
|
||||
elif clamp or enforceRange:
|
||||
raise WebIDLError("Non-numeric types cannot be [Clamp] or [EnforceRange]", attrLocation)
|
||||
raise WebIDLError("Non-integer types cannot be [Clamp] or [EnforceRange]", attrLocation)
|
||||
if self.isDOMString():
|
||||
if treatNullAsEmpty:
|
||||
self.treatNullAsEmpty = True
|
||||
|
@ -167,30 +167,32 @@ def WebIDLTest(parser, harness):
|
||||
|
||||
harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange] via typedefs")
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
typedef [Clamp] DOMString Foo;
|
||||
""")
|
||||
parser.finish()
|
||||
except:
|
||||
threw = True
|
||||
TYPES = ["DOMString", "unrestricted float", "float", "unrestricted double", "double"]
|
||||
|
||||
harness.ok(threw, "Should not allow [Clamp] on DOMString")
|
||||
for type in TYPES:
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
typedef [Clamp] %s Foo;
|
||||
""" % type)
|
||||
parser.finish()
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should not allow [Clamp] on %s" % type)
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
typedef [EnforceRange] DOMString Foo;
|
||||
""")
|
||||
parser.finish()
|
||||
except:
|
||||
threw = True
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
typedef [EnforceRange] %s Foo;
|
||||
""" % type)
|
||||
parser.finish()
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should not allow [EnforceRange] on DOMString")
|
||||
harness.ok(threw, "Should not allow [EnforceRange] on %s" % type)
|
||||
|
||||
|
||||
parser = parser.reset()
|
||||
|
Loading…
Reference in New Issue
Block a user