Bug 1375829 part 3. Align our definition of "JSON type" with the spec. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 17 May 2018 23:39:52 -0400
changeset 418797 3db98d12d700
parent 418796 5a9cdc8de26a
child 418798 23c967ee8611
push id34013
push userdluca@mozilla.com
push date2018-05-18 09:56 +0000
treeherdermozilla-central@11ee70f24ea5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1375829
milestone62.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 1375829 part 3. Align our definition of "JSON type" with the spec. r=qdot Compared to the spec, we had the following differences: * Date was a JSON type in our implementation. It doesn't even exist as a type in the spec. It stops being a JSON type. * Annotated types are not supported yet. Nothing changes here. * Typedef types were not JSON types in our implementation. They become JSON types if the type it's a typedef for is one. * Frozen arrays are not supported yet. nothing changes here. * Records were not JSON types in our implementation. They become JSON types when the value type is a JSON type. * Object was not a JSON type in our implementation. It becomes a JSON type. * Interface types were only JSON types in our implementation if they had a jsonifier. We change to treating them as JSON types if there is a jsonifier anywhere on the inheritance chain. In terms of observable behavior, the following properties now get included by toJSON methods that didn't use to be included: PaymentResponse.details Performance.mozMemory both because they're of type "object".
dom/bindings/parser/WebIDL.py
--- a/dom/bindings/parser/WebIDL.py
+++ b/dom/bindings/parser/WebIDL.py
@@ -2468,16 +2468,19 @@ class IDLRecordType(IDLParametrizedType)
         return isinstance(other, IDLRecordType) and self.inner == other.inner
 
     def __str__(self):
         return self.keyType.__str__() + self.inner.__str__() + "Record"
 
     def isRecord(self):
         return True
 
+    def isJSONType(self):
+        return self.inner.isJSONType()
+
     def tag(self):
         return IDLType.Tags.record
 
     def complete(self, scope):
         self.inner = self.inner.complete(scope)
         self.name = self.keyType.name + self.inner.name + "Record"
         return self
 
@@ -2660,16 +2663,19 @@ class IDLTypedefType(IDLType):
         return self.inner.isDOMString()
 
     def isUSVString(self):
         return self.inner.isUSVString()
 
     def isVoid(self):
         return self.inner.isVoid()
 
+    def isJSONType(self):
+        return self.inner.isJSONType()
+
     def isSequence(self):
         return self.inner.isSequence()
 
     def isRecord(self):
         return self.inner.isRecord()
 
     def isReadableStream(self):
         return self.inner.isReadableStream()
@@ -2805,17 +2811,22 @@ class IDLWrapperType(IDLType):
 
     def isEnum(self):
         return isinstance(self.inner, IDLEnum)
 
     def isJSONType(self):
         if self.isInterface():
             if self.inner.isExternal():
                 return False
-            return any(m.isMethod() and m.isJsonifier() for m in self.inner.members)
+            iface = self.inner
+            while iface:
+                if any(m.isMethod() and m.isJsonifier() for m in self.inner.members):
+                    return True
+                iface = iface.parent
+            return False
         elif self.isEnum():
             return True
         elif self.isDictionary():
             return all(m.type.isJSONType() for m in self.inner.members)
         else:
             raise WebIDLError("IDLWrapperType wraps type %s that we don't know if "
                               "is serializable" % type(self.inner), [self.location])
 
@@ -3096,17 +3107,17 @@ class IDLBuiltinType(IDLType):
                 self._typeTag == IDLBuiltinType.Types.unrestricted_double)
 
     def isUnrestricted(self):
         assert self.isFloat()
         return (self._typeTag == IDLBuiltinType.Types.unrestricted_float or
                 self._typeTag == IDLBuiltinType.Types.unrestricted_double)
 
     def isJSONType(self):
-        return self.isPrimitive() or self.isString() or self.isDate()
+        return self.isPrimitive() or self.isString() or self.isObject()
 
     def includesRestrictedFloat(self):
         return self.isFloat() and not self.isUnrestricted()
 
     def tag(self):
         return IDLBuiltinType.TagLookup[self._typeTag]
 
     def isDistinguishableFrom(self, other):