Permalink
Browse files

Bug 826606 - Set uninitialized values for DeviceProximityEvent accord…

…ing to spec. r=dougt,smaug,khuey
  • Loading branch information...
1 parent 52d8796 commit 362524c8d4852c2edc5c4fba7a2ac687d83ef2a2 William Chen committed Jan 8, 2013
@@ -426,6 +426,10 @@
is(e.max, 2, "max should be 2");
document.dispatchEvent(e);
is(receivedEvent, e, "Wrong event!");
+e = new DeviceProximityEvent("hello");
+is(e.value, Infinity, "Uninitialized value should be infinity");
+is(e.min, -Infinity, "Uninitialized min should be -infinity");
+is(e.max, Infinity, "Uninitialized max should be infinity");
// UserProximityEvent
e = new UserProximityEvent("hello", {near: true});
@@ -21,7 +21,7 @@ interface nsIDOMDeviceProximityEvent : nsIDOMEvent
dictionary DeviceProximityEventInit : EventInit
{
- double value;
- double min;
- double max;
+ double value = Infinity;
+ double min = -Infinity;
+ double max = Infinity;
};
@@ -265,18 +265,23 @@ def init_value(attribute):
return "JSVAL_VOID"
return "0"
else:
+ if realtype.count("double") and attribute.defvalue == "Infinity":
+ return "MOZ_DOUBLE_POSITIVE_INFINITY()"
+ if realtype.count("double") and attribute.defvalue == "-Infinity":
+ return "MOZ_DOUBLE_NEGATIVE_INFINITY()"
if realtype.count("nsAString"):
return "NS_LITERAL_STRING(\"%s\")" % attribute.defvalue
if realtype.count("nsACString"):
return "NS_LITERAL_CSTRING(\"%s\")" % attribute.defvalue
- raise xpidl.IDLError("Default value is not supported for type %s" % realtype)
+ raise xpidl.IDLError("Default value of %s is not supported for type %s" %
+ (attribute.defvalue, realtype), attribute.location)
def write_header(iface, fd):
attributes = []
for member in iface.members:
if isinstance(member, xpidl.Attribute):
attributes.append(member)
-
+
fd.write("class %s" % iface.name)
if iface.base is not None:
fd.write(" : public %s" % iface.base)
@@ -287,7 +292,7 @@ def write_header(iface, fd):
fd.write(" // If aCx or aVal is null, NS_OK is returned and \n"
" // dictionary will use the default values. \n"
" nsresult Init(JSContext* aCx, const jsval* aVal);\n")
-
+
fd.write("\n")
for member in attributes:
@@ -1009,7 +1009,8 @@ class IDLParser(object):
'raises': 'RAISES',
'readonly': 'READONLY',
'native': 'NATIVE',
- 'typedef': 'TYPEDEF'
+ 'typedef': 'TYPEDEF',
+ 'Infinity': 'INFINITY'
}
tokens = [
@@ -1439,9 +1440,11 @@ def p_optnullable(self, p):
def p_optdefvalue(self, p):
"""optdefvalue : '=' STRING
+ | '=' INFINITY
+ | '=' '-' INFINITY
| """
if len(p) > 1:
- p[0] = p[2]
+ p[0] = "".join(p[2:])
else:
p[0] = None

0 comments on commit 362524c

Please sign in to comment.