aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNgo Iok Ui (Wu Yu Wei) <yuweiwu@pm.me>2024-06-15 13:22:42 +0900
committerGitHub <noreply@github.com>2024-06-15 04:22:42 +0000
commit8eed3b442b214f678b80dbcc7dca07eeaa1e26ff (patch)
treef8a232e86616e8e5fd234e7bbb32bed4ff7077f2
parent19067366df28c9131dcbc436bc96a27e64e0a194 (diff)
downloadservo-8eed3b442b214f678b80dbcc7dca07eeaa1e26ff.tar.gz
servo-8eed3b442b214f678b80dbcc7dca07eeaa1e26ff.zip
Update WebIDL.py (#32495)
* Update WebIDL.py * Update WebIDL.py * Add builtin-array.patch * Fix CodegenRust.py and Configuration.py * Fix missing downcasts * mach fmt * Update check and comment to explain why we need this check * Update Global of DissimilarOriginWindow.webidl
-rw-r--r--components/script/dom/bindings/codegen/Configuration.py10
-rw-r--r--components/script/dom/testbinding.rs13
-rw-r--r--components/script/dom/webidls/DissimilarOriginWindow.webidl2
-rw-r--r--components/script/dom/xmlhttprequest.rs2
-rw-r--r--third_party/WebIDL/WebIDL.py660
-rw-r--r--third_party/WebIDL/builtin-array.patch49
-rw-r--r--third_party/WebIDL/tests/test_any_null.py7
-rw-r--r--third_party/WebIDL/tests/test_argument_identifier_conflicts.py7
-rw-r--r--third_party/WebIDL/tests/test_argument_novoid.py19
-rw-r--r--third_party/WebIDL/tests/test_attr.py8
-rw-r--r--third_party/WebIDL/tests/test_attr_sequence_type.py29
-rw-r--r--third_party/WebIDL/tests/test_attributes_on_types.py42
-rw-r--r--third_party/WebIDL/tests/test_builtin_filename.py5
-rw-r--r--third_party/WebIDL/tests/test_bytestring.py8
-rw-r--r--third_party/WebIDL/tests/test_callback_constructor.py4
-rw-r--r--third_party/WebIDL/tests/test_callback_interface.py10
-rw-r--r--third_party/WebIDL/tests/test_cereactions.py35
-rw-r--r--third_party/WebIDL/tests/test_const.py4
-rw-r--r--third_party/WebIDL/tests/test_constructor.py50
-rw-r--r--third_party/WebIDL/tests/test_constructor_global.py26
-rw-r--r--third_party/WebIDL/tests/test_constructor_no_interface_object.py11
-rw-r--r--third_party/WebIDL/tests/test_deduplicate.py3
-rw-r--r--third_party/WebIDL/tests/test_dictionary.py155
-rw-r--r--third_party/WebIDL/tests/test_distinguishability.py112
-rw-r--r--third_party/WebIDL/tests/test_double_null.py7
-rw-r--r--third_party/WebIDL/tests/test_duplicate_qualifiers.py19
-rw-r--r--third_party/WebIDL/tests/test_empty_enum.py4
-rw-r--r--third_party/WebIDL/tests/test_empty_sequence_default_value.py2
-rw-r--r--third_party/WebIDL/tests/test_enum.py4
-rw-r--r--third_party/WebIDL/tests/test_enum_duplicate_values.py2
-rw-r--r--third_party/WebIDL/tests/test_error_colno.py2
-rw-r--r--third_party/WebIDL/tests/test_error_lineno.py2
-rw-r--r--third_party/WebIDL/tests/test_exposed_extended_attribute.py40
-rw-r--r--third_party/WebIDL/tests/test_extended_attributes.py16
-rw-r--r--third_party/WebIDL/tests/test_float_types.py12
-rw-r--r--third_party/WebIDL/tests/test_forward_decl.py5
-rw-r--r--third_party/WebIDL/tests/test_global_extended_attr.py54
-rw-r--r--third_party/WebIDL/tests/test_identifier_conflict.py10
-rw-r--r--third_party/WebIDL/tests/test_incomplete_parent.py3
-rw-r--r--third_party/WebIDL/tests/test_interface.py38
-rw-r--r--third_party/WebIDL/tests/test_interface_const_identifier_conflicts.py7
-rw-r--r--third_party/WebIDL/tests/test_interface_identifier_conflicts_across_members.py129
-rw-r--r--third_party/WebIDL/tests/test_interface_maplikesetlikeiterable.py83
-rw-r--r--third_party/WebIDL/tests/test_interfacemixin.py48
-rw-r--r--third_party/WebIDL/tests/test_legacyTreatNonObjectAsNull.py11
-rw-r--r--third_party/WebIDL/tests/test_lenientSetter.py4
-rw-r--r--third_party/WebIDL/tests/test_method.py20
-rw-r--r--third_party/WebIDL/tests/test_namespace.py21
-rw-r--r--third_party/WebIDL/tests/test_newobject.py18
-rw-r--r--third_party/WebIDL/tests/test_nullable_equivalency.py12
-rw-r--r--third_party/WebIDL/tests/test_nullable_void.py19
-rw-r--r--third_party/WebIDL/tests/test_observableArray.py1
-rw-r--r--third_party/WebIDL/tests/test_optional_constraints.py7
-rw-r--r--third_party/WebIDL/tests/test_promise.py45
-rw-r--r--third_party/WebIDL/tests/test_prototype_ident.py15
-rw-r--r--third_party/WebIDL/tests/test_putForwards.py27
-rw-r--r--third_party/WebIDL/tests/test_record.py4
-rw-r--r--third_party/WebIDL/tests/test_replaceable.py4
-rw-r--r--third_party/WebIDL/tests/test_securecontext_extended_attribute.py84
-rw-r--r--third_party/WebIDL/tests/test_special_method_signature_mismatch.py67
-rw-r--r--third_party/WebIDL/tests/test_special_methods.py2
-rw-r--r--third_party/WebIDL/tests/test_special_methods_uniqueness.py12
-rw-r--r--third_party/WebIDL/tests/test_stringifier.py10
-rw-r--r--third_party/WebIDL/tests/test_toJSON.py27
-rw-r--r--third_party/WebIDL/tests/test_treatNonCallableAsNull.py6
-rw-r--r--third_party/WebIDL/tests/test_typedef.py9
-rw-r--r--third_party/WebIDL/tests/test_typedef_identifier_conflict.py2
-rw-r--r--third_party/WebIDL/tests/test_undefined.py48
-rw-r--r--third_party/WebIDL/tests/test_unenumerable_own_properties.py10
-rw-r--r--third_party/WebIDL/tests/test_unforgeable.py19
-rw-r--r--third_party/WebIDL/tests/test_union.py10
-rw-r--r--third_party/WebIDL/tests/test_union_any.py7
-rw-r--r--third_party/WebIDL/tests/test_union_callback_dict.py132
-rw-r--r--third_party/WebIDL/tests/test_union_nullable.py15
-rw-r--r--third_party/WebIDL/tests/test_variadic_callback.py5
-rw-r--r--third_party/WebIDL/tests/test_variadic_constraints.py19
-rwxr-xr-xthird_party/WebIDL/update.sh1
77 files changed, 1658 insertions, 793 deletions
diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py
index a220df2b73d..81ebe68d8bb 100644
--- a/components/script/dom/bindings/codegen/Configuration.py
+++ b/components/script/dom/bindings/codegen/Configuration.py
@@ -76,7 +76,7 @@ class Configuration:
for key, val in filters.items():
if key == 'webIDLFile':
def getter(x):
- return x.interface.filename()
+ return x.interface.location.filename
elif key == 'hasInterfaceObject':
def getter(x):
return x.interface.hasInterfaceObject()
@@ -108,10 +108,10 @@ class Configuration:
return curr
def getEnums(self, webIDLFile):
- return [e for e in self.enums if e.filename() == webIDLFile]
+ return [e for e in self.enums if e.filename == webIDLFile]
def getTypedefs(self, webIDLFile):
- return [e for e in self.typedefs if e.filename() == webIDLFile]
+ return [e for e in self.typedefs if e.filename == webIDLFile]
@staticmethod
def _filterForFile(items, webIDLFile=""):
@@ -119,7 +119,7 @@ class Configuration:
if not webIDLFile:
return items
- return [x for x in items if x.filename() == webIDLFile]
+ return [x for x in items if x.filename == webIDLFile]
def getDictionaries(self, webIDLFile=""):
return self._filterForFile(self.dictionaries, webIDLFile=webIDLFile)
@@ -471,7 +471,7 @@ def MakeNativeName(name):
def getIdlFileName(object):
- return os.path.basename(object.location.filename()).split('.webidl')[0]
+ return os.path.basename(object.location.filename).split('.webidl')[0]
def getModuleFromObject(object):
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index 13ae19333b5..388af65e23c 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -28,11 +28,10 @@ use crate::dom::bindings::codegen::Bindings::TestBindingBinding::{
use crate::dom::bindings::codegen::UnionTypes;
use crate::dom::bindings::codegen::UnionTypes::{
BlobOrBlobSequence, BlobOrBoolean, BlobOrString, BlobOrUnsignedLong, ByteStringOrLong,
- ByteStringSequenceOrLong, ByteStringSequenceOrLongOrString, DocumentOrTestTypedef,
- EventOrString, EventOrUSVString, HTMLElementOrLong, HTMLElementOrUnsignedLongOrStringOrBoolean,
- LongOrLongSequenceSequence, LongSequenceOrBoolean, LongSequenceOrTestTypedef, StringOrBoolean,
- StringOrLongSequence, StringOrStringSequence, StringOrUnsignedLong,
- StringSequenceOrUnsignedLong, UnsignedLongOrBoolean,
+ ByteStringSequenceOrLong, ByteStringSequenceOrLongOrString, EventOrString, EventOrUSVString,
+ HTMLElementOrLong, HTMLElementOrUnsignedLongOrStringOrBoolean, LongOrLongSequenceSequence,
+ LongSequenceOrBoolean, StringOrBoolean, StringOrLongSequence, StringOrStringSequence,
+ StringOrUnsignedLong, StringSequenceOrUnsignedLong, UnsignedLongOrBoolean,
};
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::num::Finite;
@@ -655,8 +654,8 @@ impl TestBindingMethods for TestBinding {
fn PassUnion9(&self, _: UnionTypes::TestDictionaryOrLong) {}
fn PassUnion10(&self, _: SafeJSContext, _: UnionTypes::StringOrObject) {}
fn PassUnion11(&self, _: UnionTypes::ArrayBufferOrArrayBufferView) {}
- fn PassUnionWithTypedef(&self, _: DocumentOrTestTypedef) {}
- fn PassUnionWithTypedef2(&self, _: LongSequenceOrTestTypedef) {}
+ fn PassUnionWithTypedef(&self, _: UnionTypes::DocumentOrStringOrURLOrBlob) {}
+ fn PassUnionWithTypedef2(&self, _: UnionTypes::LongSequenceOrStringOrURLOrBlob) {}
fn PassAny(&self, _: SafeJSContext, _: HandleValue) {}
fn PassObject(&self, _: SafeJSContext, _: *mut JSObject) {}
fn PassCallbackFunction(&self, _: Rc<Function>) {}
diff --git a/components/script/dom/webidls/DissimilarOriginWindow.webidl b/components/script/dom/webidls/DissimilarOriginWindow.webidl
index 0f77aba7d05..bce8bddb572 100644
--- a/components/script/dom/webidls/DissimilarOriginWindow.webidl
+++ b/components/script/dom/webidls/DissimilarOriginWindow.webidl
@@ -13,7 +13,7 @@
// way to enforce security policy.
// https://html.spec.whatwg.org/multipage/#window
-[Global, Exposed=(Window,DissimilarOriginWindow), LegacyNoInterfaceObject]
+[Global=DissimilarOriginWindow, Exposed=(Window,DissimilarOriginWindow), LegacyNoInterfaceObject]
interface DissimilarOriginWindow : GlobalScope {
[LegacyUnforgeable] readonly attribute WindowProxy window;
[BinaryName="Self_", Replaceable] readonly attribute WindowProxy self;
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index e9966f22774..9b4e5b2cbdc 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -46,7 +46,7 @@ use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use crate::dom::bindings::codegen::Bindings::XMLHttpRequestBinding::{
XMLHttpRequestMethods, XMLHttpRequestResponseType,
};
-use crate::dom::bindings::codegen::UnionTypes::DocumentOrXMLHttpRequestBodyInit;
+use crate::dom::bindings::codegen::UnionTypes::DocumentOrBlobOrArrayBufferViewOrArrayBufferOrFormDataOrStringOrURLSearchParams as DocumentOrXMLHttpRequestBodyInit;
use crate::dom::bindings::conversions::ToJSValConvertible;
use crate::dom::bindings::error::{Error, ErrorResult, Fallible};
use crate::dom::bindings::inheritance::Castable;
diff --git a/third_party/WebIDL/WebIDL.py b/third_party/WebIDL/WebIDL.py
index 2d5c56f1086..482aa13bc2f 100644
--- a/third_party/WebIDL/WebIDL.py
+++ b/third_party/WebIDL/WebIDL.py
@@ -43,25 +43,22 @@ def parseInt(literal):
return value * sign
-def enum(*names, **kw):
- class Foo(object):
- attrs = OrderedDict()
+# This is surprisingly faster than using the enum.IntEnum type (which doesn't
+# support 'base' anyway)
+def enum(*names, base=None):
+ if base is not None:
+ names = base.attrs + names
- def __init__(self, names):
- for v, k in enumerate(names):
- self.attrs[k] = v
-
- def __getattr__(self, attr):
- if attr in self.attrs:
- return self.attrs[attr]
- raise AttributeError
+ class CustomEnumType(object):
+ attrs = names
def __setattr__(self, name, value): # this makes it read-only
raise NotImplementedError
- if "base" not in kw:
- return Foo(names)
- return Foo(chain(kw["base"].attrs.keys(), names))
+ for v, k in enumerate(names):
+ setattr(CustomEnumType, k, v)
+
+ return CustomEnumType()
class WebIDLError(Exception):
@@ -85,13 +82,10 @@ class Location(object):
self._lineno = lineno
self._lexpos = lexpos
self._lexdata = lexer.lexdata
- self._file = filename if filename else "<unknown>"
+ self.filename = filename if filename else "<unknown>"
def __eq__(self, other):
- return self._lexpos == other._lexpos and self._file == other._file
-
- def filename(self):
- return self._file
+ return self._lexpos == other._lexpos and self.filename == other.filename
def resolve(self):
if self._line:
@@ -110,7 +104,7 @@ class Location(object):
def get(self):
self.resolve()
- return "%s line %s:%s" % (self._file, self._lineno, self._colno)
+ return "%s line %s:%s" % (self.filename, self._lineno, self._colno)
def _pointerline(self):
return " " * self._colno + "^"
@@ -118,7 +112,7 @@ class Location(object):
def __str__(self):
self.resolve()
return "%s line %s:%s\n%s\n%s" % (
- self._file,
+ self.filename,
self._lineno,
self._colno,
self._line,
@@ -127,15 +121,15 @@ class Location(object):
class BuiltinLocation(object):
+ __slots__ = "msg", "filename"
+
def __init__(self, text):
self.msg = text + "\n"
+ self.filename = "<builtin>"
def __eq__(self, other):
return isinstance(other, BuiltinLocation) and self.msg == other.msg
- def filename(self):
- return "<builtin>"
-
def resolve(self):
pass
@@ -150,12 +144,12 @@ class BuiltinLocation(object):
class IDLObject(object):
+ __slots__ = "location", "userData", "filename"
+
def __init__(self, location):
self.location = location
- self.userData = dict()
-
- def filename(self):
- return self.location.filename()
+ self.userData = {}
+ self.filename = location and location.filename
def isInterface(self):
return False
@@ -220,8 +214,8 @@ class IDLObject(object):
visited.add(self)
deps = set()
- if self.filename() != "<builtin>":
- deps.add(self.filename())
+ if self.filename != "<builtin>":
+ deps.add(self.filename)
for d in self._getDependentObjects():
deps.update(d.getDeps(visited))
@@ -230,6 +224,8 @@ class IDLObject(object):
class IDLScope(IDLObject):
+ __slots__ = "parentScope", "_name", "_dict", "globalNames", "globalNameMapping"
+
def __init__(self, location, parentScope, identifier):
IDLObject.__init__(self, location)
@@ -283,6 +279,9 @@ class IDLScope(IDLObject):
self._dict[identifier.name] = replacement
return
+ self.addNewIdentifier(identifier, object)
+
+ def addNewIdentifier(self, identifier, object):
assert object
self._dict[identifier.name] = object
@@ -323,6 +322,9 @@ class IDLScope(IDLObject):
return originalObject.addOverload(newObject)
# Default to throwing, derived classes can override.
+ raise self.createIdentifierConflictError(identifier, originalObject, newObject)
+
+ def createIdentifierConflictError(self, identifier, originalObject, newObject):
conflictdesc = "\n\t%s at %s\n\t%s at %s" % (
originalObject,
originalObject.location,
@@ -330,7 +332,7 @@ class IDLScope(IDLObject):
newObject.location,
)
- raise WebIDLError(
+ return WebIDLError(
"Multiple unresolvable definitions of identifier '%s' in scope '%s'%s"
% (identifier.name, str(self), conflictdesc),
[],
@@ -353,6 +355,8 @@ class IDLScope(IDLObject):
class IDLIdentifier(IDLObject):
+ __slots__ = "name", "scope"
+
def __init__(self, location, scope, name):
IDLObject.__init__(self, location)
@@ -377,12 +381,14 @@ class IDLIdentifier(IDLObject):
class IDLUnresolvedIdentifier(IDLObject):
+ __slots__ = ("name",)
+
def __init__(
self, location, name, allowDoubleUnderscore=False, allowForbidden=False
):
IDLObject.__init__(self, location)
- assert len(name) > 0
+ assert name
if name == "__noSuchMethod__":
raise WebIDLError("__noSuchMethod__ is deprecated", [location])
@@ -421,6 +427,7 @@ class IDLUnresolvedIdentifier(IDLObject):
class IDLObjectWithIdentifier(IDLObject):
+ # no slots, incompatible with multiple inheritance
def __init__(self, location, parentScope, identifier):
IDLObject.__init__(self, location)
@@ -438,6 +445,8 @@ class IDLObjectWithIdentifier(IDLObject):
class IDLObjectWithScope(IDLObjectWithIdentifier, IDLScope):
+ __slots__ = ()
+
def __init__(self, location, parentScope, identifier):
assert isinstance(identifier, IDLUnresolvedIdentifier)
@@ -446,6 +455,8 @@ class IDLObjectWithScope(IDLObjectWithIdentifier, IDLScope):
class IDLIdentifierPlaceholder(IDLObjectWithIdentifier):
+ __slots__ = ()
+
def __init__(self, location, identifier):
assert isinstance(identifier, IDLUnresolvedIdentifier)
IDLObjectWithIdentifier.__init__(self, location, None, identifier)
@@ -453,7 +464,7 @@ class IDLIdentifierPlaceholder(IDLObjectWithIdentifier):
def finish(self, scope):
try:
scope._lookupIdentifier(self.identifier)
- except:
+ except Exception:
raise WebIDLError(
"Unresolved type '%s'." % self.identifier, [self.location]
)
@@ -463,6 +474,7 @@ class IDLIdentifierPlaceholder(IDLObjectWithIdentifier):
class IDLExposureMixins:
+ # no slots, incompatible with multiple inheritance
def __init__(self, location):
# _exposureGlobalNames are the global names listed in our [Exposed]
# extended attribute. exposureSet is the exposure set as defined in the
@@ -492,16 +504,15 @@ class IDLExposureMixins:
# they don't include any globals, and we don't really want to go through
# and add global interfaces and [Exposed] annotations to all those
# tests.
- if len(scope.globalNames) != 0:
- if len(self._exposureGlobalNames) == 0 and not self.isPseudoInterface():
- raise WebIDLError(
- (
- "'%s' is not exposed anywhere even though we have "
- "globals to be exposed to"
- )
- % self,
- [self.location],
+ if len(scope.globalNames) != 0 and len(self._exposureGlobalNames) == 0:
+ raise WebIDLError(
+ (
+ "'%s' is not exposed anywhere even though we have "
+ "globals to be exposed to"
)
+ % self,
+ [self.location],
+ )
globalNameSetToExposureSet(scope, self._exposureGlobalNames, self.exposureSet)
@@ -546,6 +557,8 @@ class IDLExposureMixins:
class IDLExternalInterface(IDLObjectWithIdentifier):
+ __slots__ = ("parent",)
+
def __init__(self, location, parentScope, identifier):
assert isinstance(identifier, IDLUnresolvedIdentifier)
assert isinstance(parentScope, IDLScope)
@@ -596,6 +609,8 @@ class IDLExternalInterface(IDLObjectWithIdentifier):
class IDLPartialDictionary(IDLObject):
+ __slots__ = "identifier", "members", "_nonPartialDictionary", "_finished"
+
def __init__(self, location, name, members, nonPartialDictionary):
assert isinstance(name, IDLUnresolvedIdentifier)
@@ -624,6 +639,15 @@ class IDLPartialDictionary(IDLObject):
class IDLPartialInterfaceOrNamespace(IDLObject):
+ __slots__ = (
+ "identifier",
+ "members",
+ "propagatedExtendedAttrs",
+ "_haveSecureContextExtendedAttribute",
+ "_nonPartialInterfaceOrNamespace",
+ "_finished",
+ )
+
def __init__(self, location, name, members, nonPartialInterfaceOrNamespace):
assert isinstance(name, IDLUnresolvedIdentifier)
@@ -727,7 +751,26 @@ def globalNameSetToExposureSet(globalScope, nameSet, exposureSet):
exposureSet.update(globalScope.globalNameMapping[name])
+# Because WebIDL allows static and regular operations with the same identifier
+# we use a special class to be able to store them both in the scope for the
+# same identifier.
+class IDLOperations:
+ __slots__ = "static", "regular"
+
+ def __init__(self, static=None, regular=None):
+ self.static = static
+ self.regular = regular
+
+
class IDLInterfaceOrInterfaceMixinOrNamespace(IDLObjectWithScope, IDLExposureMixins):
+ __slots__ = (
+ "_finished",
+ "members",
+ "_partials",
+ "_extendedAttrDict",
+ "_isKnownNonPartial",
+ )
+
def __init__(self, location, parentScope, name):
assert isinstance(parentScope, IDLScope)
assert isinstance(name, IDLUnresolvedIdentifier)
@@ -756,15 +799,66 @@ class IDLInterfaceOrInterfaceMixinOrNamespace(IDLObjectWithScope, IDLExposureMix
self.addExtendedAttributes(partial.propagatedExtendedAttrs)
self.members.extend(partial.members)
+ def addNewIdentifier(self, identifier, object):
+ if isinstance(object, IDLMethod):
+ if object.isStatic():
+ object = IDLOperations(static=object)
+ else:
+ object = IDLOperations(regular=object)
+
+ IDLScope.addNewIdentifier(self, identifier, object)
+
def resolveIdentifierConflict(self, scope, identifier, originalObject, newObject):
assert isinstance(scope, IDLScope)
- assert isinstance(originalObject, IDLInterfaceMember)
assert isinstance(newObject, IDLInterfaceMember)
+ # The identifier of a regular operation or static operation must not be
+ # the same as the identifier of a constant or attribute.
+ if isinstance(newObject, IDLMethod) != isinstance(
+ originalObject, IDLOperations
+ ):
+ if isinstance(originalObject, IDLOperations):
+ if originalObject.regular is not None:
+ originalObject = originalObject.regular
+ else:
+ assert originalObject.static is not None
+ originalObject = originalObject.static
+
+ raise self.createIdentifierConflictError(
+ identifier, originalObject, newObject
+ )
+
+ if isinstance(newObject, IDLMethod):
+ originalOperations = originalObject
+ if newObject.isStatic():
+ if originalOperations.static is None:
+ originalOperations.static = newObject
+ return originalOperations
+
+ originalObject = originalOperations.static
+ else:
+ if originalOperations.regular is None:
+ originalOperations.regular = newObject
+ return originalOperations
+
+ originalObject = originalOperations.regular
+
+ assert isinstance(originalObject, IDLMethod)
+ else:
+ assert isinstance(originalObject, IDLInterfaceMember)
+
retval = IDLScope.resolveIdentifierConflict(
self, scope, identifier, originalObject, newObject
)
+ if isinstance(newObject, IDLMethod):
+ if newObject.isStatic():
+ originalOperations.static = retval
+ else:
+ originalOperations.regular = retval
+
+ retval = originalOperations
+
# Might be a ctor, which isn't in self.members
if newObject in self.members:
self.members.remove(newObject)
@@ -842,10 +936,12 @@ class IDLInterfaceOrInterfaceMixinOrNamespace(IDLObjectWithScope, IDLExposureMix
class IDLInterfaceMixin(IDLInterfaceOrInterfaceMixinOrNamespace):
+ __slots__ = ("actualExposureGlobalNames",)
+
def __init__(self, location, parentScope, name, members, isKnownNonPartial):
self.actualExposureGlobalNames = set()
- assert isKnownNonPartial or len(members) == 0
+ assert isKnownNonPartial or not members
IDLInterfaceOrInterfaceMixinOrNamespace.__init__(
self, location, parentScope, name
)
@@ -881,7 +977,6 @@ class IDLInterfaceMixin(IDLInterfaceOrInterfaceMixinOrNamespace):
def validate(self):
for member in self.members:
-
if member.isAttr():
if member.inherit:
raise WebIDLError(
@@ -947,27 +1042,43 @@ class IDLInterfaceMixin(IDLInterfaceOrInterfaceMixinOrNamespace):
class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
+ __slots__ = (
+ "parent",
+ "_callback",
+ "maplikeOrSetlikeOrIterable",
+ "legacyFactoryFunctions",
+ "legacyWindowAliases",
+ "includedMixins",
+ "interfacesBasedOnSelf",
+ "_hasChildInterfaces",
+ "_isOnGlobalProtoChain",
+ "totalMembersInSlots",
+ "_ownMembersInSlots",
+ "iterableInterface",
+ "asyncIterableInterface",
+ "hasCrossOriginMembers",
+ "hasDescendantWithCrossOriginMembers",
+ )
+
def __init__(self, location, parentScope, name, parent, members, isKnownNonPartial):
assert isKnownNonPartial or not parent
- assert isKnownNonPartial or len(members) == 0
+ assert isKnownNonPartial or not members
self.parent = None
self._callback = False
self.maplikeOrSetlikeOrIterable = None
- # namedConstructors needs deterministic ordering because bindings code
- # outputs the constructs in the order that namedConstructors enumerates
+ # legacyFactoryFunctions needs deterministic ordering because bindings code
+ # outputs the constructs in the order that legacyFactoryFunctions enumerates
# them.
- self.legacyFactoryFunctions = list()
+ self.legacyFactoryFunctions = []
self.legacyWindowAliases = []
self.includedMixins = set()
# self.interfacesBasedOnSelf is the set of interfaces that inherit from
# self, including self itself.
# Used for distinguishability checking.
- self.interfacesBasedOnSelf = set([self])
+ self.interfacesBasedOnSelf = {self}
self._hasChildInterfaces = False
self._isOnGlobalProtoChain = False
- # Pseudo interfaces aren't exposed anywhere, and so shouldn't issue warnings
- self._isPseudo = False
# Tracking of the number of reserved slots we need for our
# members and those of ancestor interfaces.
@@ -995,8 +1106,8 @@ class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
self.location, "constructor", allowForbidden=True
)
try:
- return self._lookupIdentifier(identifier)
- except:
+ return self._lookupIdentifier(identifier).static
+ except Exception:
return None
def isIterable(self):
@@ -1234,7 +1345,11 @@ class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
for mixin in sorted(self.includedMixins, key=lambda x: x.identifier.name):
for mixinMember in mixin.members:
for member in self.members:
- if mixinMember.identifier.name == member.identifier.name:
+ if mixinMember.identifier.name == member.identifier.name and (
+ not mixinMember.isMethod()
+ or not member.isMethod()
+ or mixinMember.isStatic() == member.isStatic()
+ ):
raise WebIDLError(
"Multiple definitions of %s on %s coming from 'includes' statements"
% (member.identifier.name, self),
@@ -1733,14 +1848,13 @@ class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
def hasInterfaceObject(self):
if self.isCallback():
return self.hasConstants()
- return not hasattr(self, "_noInterfaceObject") and not self.isPseudoInterface()
+ return not hasattr(self, "_noInterfaceObject")
def hasInterfacePrototypeObject(self):
return (
not self.isCallback()
and not self.isNamespace()
and self.getUserData("hasConcreteDescendant", False)
- and not self.isPseudoInterface()
)
def addIncludedMixin(self, includedMixin):
@@ -1804,9 +1918,6 @@ class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
def isOnGlobalProtoChain(self):
return self._isOnGlobalProtoChain
- def isPseudoInterface(self):
- return self._isPseudo
-
def _getDependentObjects(self):
deps = set(self.members)
deps.update(self.includedMixins)
@@ -1827,12 +1938,14 @@ class IDLInterfaceOrNamespace(IDLInterfaceOrInterfaceMixinOrNamespace):
def isExposedConditionally(self, exclusions=[]):
return any(
- ((not a in exclusions) and self.getExtendedAttribute(a))
+ ((a not in exclusions) and self.getExtendedAttribute(a))
for a in self.conditionExtendedAttributes
)
class IDLInterface(IDLInterfaceOrNamespace):
+ __slots__ = ("classNameOverride",)
+
def __init__(
self,
location,
@@ -1885,18 +1998,19 @@ class IDLInterface(IDLInterfaceOrNamespace):
elif identifier == "LegacyFactoryFunction":
if not attr.hasValue():
raise WebIDLError(
- "LegacyFactoryFunction must either take an identifier or take a named argument list",
+ (
+ "LegacyFactoryFunction must either take an "
+ "identifier or take a named argument list"
+ ),
[attr.location],
)
args = attr.args() if attr.hasArgs() else []
- retType = IDLWrapperType(self.location, self)
-
method = IDLConstructor(attr.location, args, attr.value())
method.reallyInit(self)
- # Named constructors are always assumed to be able to
+ # Legacy factory functions are always assumed to be able to
# throw (since there's no way to indicate otherwise).
method.addExtendedAttributes(
[IDLExtendedAttribute(self.location, ("Throws",))]
@@ -1942,7 +2056,10 @@ class IDLInterface(IDLInterfaceOrNamespace):
elif attr.hasArgs():
self.globalNames = attr.args()
else:
- self.globalNames = [self.identifier.name]
+ raise WebIDLError(
+ "[Global] must either take an identifier or take an identifier list",
+ [attr.location, self.location],
+ )
self.parentScope.addIfaceGlobalNames(
self.identifier.name, self.globalNames
)
@@ -2052,6 +2169,8 @@ class IDLInterface(IDLInterfaceOrNamespace):
class IDLNamespace(IDLInterfaceOrNamespace):
+ __slots__ = ()
+
def __init__(self, location, parentScope, name, members, isKnownNonPartial):
IDLInterfaceOrNamespace.__init__(
self, location, parentScope, name, None, members, isKnownNonPartial
@@ -2110,6 +2229,17 @@ class IDLNamespace(IDLInterfaceOrNamespace):
class IDLDictionary(IDLObjectWithScope):
+ __slots__ = (
+ "parent",
+ "_finished",
+ "members",
+ "_partialDictionaries",
+ "_extendedAttrDict",
+ "needsConversionToJS",
+ "needsConversionFromJS",
+ "needsEqualityOperator",
+ )
+
def __init__(self, location, parentScope, name, parent, members):
assert isinstance(parentScope, IDLScope)
assert isinstance(name, IDLUnresolvedIdentifier)
@@ -2122,6 +2252,7 @@ class IDLDictionary(IDLObjectWithScope):
self._extendedAttrDict = {}
self.needsConversionToJS = False
self.needsConversionFromJS = False
+ self.needsEqualityOperator = None
IDLObjectWithScope.__init__(self, location, parentScope, name)
@@ -2186,6 +2317,14 @@ class IDLDictionary(IDLObjectWithScope):
[self.identifier.location],
)
inheritedMembers.extend(ancestor.members)
+ if (
+ self.getExtendedAttribute("GenerateEqualityOperator")
+ and ancestor.needsEqualityOperator is None
+ ):
+ # Store the dictionary that has the [GenerateEqualityOperator]
+ # extended attribute, so we can use it when generating error
+ # messages.
+ ancestor.needsEqualityOperator = self
ancestor = ancestor.parent
# Catch name duplication
@@ -2311,6 +2450,13 @@ class IDLDictionary(IDLObjectWithScope):
# implement ToJSON by converting to a JS object and
# then using JSON.stringify.
self.needsConversionToJS = True
+ elif identifier == "GenerateEqualityOperator":
+ if not attr.noArguments():
+ raise WebIDLError(
+ "[GenerateEqualityOperator] must take no arguments",
+ [attr.location],
+ )
+ self.needsEqualityOperator = self
elif identifier == "Unsorted":
if not attr.noArguments():
raise WebIDLError(
@@ -2337,6 +2483,8 @@ class IDLDictionary(IDLObjectWithScope):
class IDLEnum(IDLObjectWithIdentifier):
+ __slots__ = ("_values",)
+
def __init__(self, location, parentScope, name, values):
assert isinstance(parentScope, IDLScope)
assert isinstance(name, IDLUnresolvedIdentifier)
@@ -2422,6 +2570,16 @@ class IDLType(IDLObject):
"observablearray",
)
+ __slots__ = (
+ "name",
+ "builtin",
+ "legacyNullToEmptyString",
+ "_clamp",
+ "_enforceRange",
+ "_allowShared",
+ "_extendedAttrDict",
+ )
+
def __init__(self, location, name):
IDLObject.__init__(self, location)
self.name = name
@@ -2625,6 +2783,8 @@ class IDLUnresolvedType(IDLType):
Unresolved types are interface types
"""
+ __slots__ = ("extraTypeAttributes",)
+
def __init__(self, location, name, attrs=[]):
IDLType.__init__(self, location, name)
self.extraTypeAttributes = attrs
@@ -2636,7 +2796,7 @@ class IDLUnresolvedType(IDLType):
obj = None
try:
obj = scope._lookupIdentifier(self.name)
- except:
+ except Exception:
raise WebIDLError("Unresolved type '%s'." % self.name, [self.location])
assert obj
@@ -2652,7 +2812,6 @@ class IDLUnresolvedType(IDLType):
assert self.name.name == obj.identifier.name
return IDLCallbackType(obj.location, obj)
- name = self.name.resolve(scope, None)
return IDLWrapperType(self.location, obj)
def withExtendedAttributes(self, attrs):
@@ -2666,6 +2825,8 @@ class IDLUnresolvedType(IDLType):
class IDLParametrizedType(IDLType):
+ __slots__ = "builtin", "inner"
+
def __init__(self, location, name, innerType):
IDLType.__init__(self, location, name)
self.builtin = False
@@ -2689,6 +2850,8 @@ class IDLParametrizedType(IDLType):
class IDLNullableType(IDLParametrizedType):
+ __slots__ = ()
+
def __init__(self, location, innerType):
assert not innerType == BuiltinTypes[IDLBuiltinType.Types.any]
@@ -2867,6 +3030,8 @@ class IDLNullableType(IDLParametrizedType):
class IDLSequenceType(IDLParametrizedType):
+ __slots__ = ("name",)
+
def __init__(self, location, parameterType):
assert not parameterType.isUndefined()
@@ -2927,10 +3092,17 @@ class IDLSequenceType(IDLParametrizedType):
class IDLRecordType(IDLParametrizedType):
+ __slots__ = "keyType", "name"
+
def __init__(self, location, keyType, valueType):
assert keyType.isString()
assert keyType.isComplete()
- assert not valueType.isUndefined()
+
+ if valueType.isUndefined():
+ raise WebIDLError(
+ "We don't support undefined as a Record's values' type",
+ [location, valueType.location],
+ )
IDLParametrizedType.__init__(self, location, valueType.name, valueType)
self.keyType = keyType
@@ -2984,6 +3156,9 @@ class IDLRecordType(IDLParametrizedType):
if other.isUnion():
# Just forward to the union; it'll deal
return other.isDistinguishableFrom(self)
+ if other.isCallback():
+ # Let other determine if it's a LegacyTreatNonObjectAsNull callback
+ return other.isDistinguishableFrom(self)
return (
other.isPrimitive()
or other.isString()
@@ -2997,6 +3172,8 @@ class IDLRecordType(IDLParametrizedType):
class IDLObservableArrayType(IDLParametrizedType):
+ __slots__ = ()
+
def __init__(self, location, innerType):
assert not innerType.isUndefined()
IDLParametrizedType.__init__(self, location, None, innerType)
@@ -3063,6 +3240,14 @@ class IDLObservableArrayType(IDLParametrizedType):
class IDLUnionType(IDLType):
+ __slots__ = (
+ "memberTypes",
+ "hasNullableType",
+ "_dictionaryType",
+ "flatMemberTypes",
+ "builtin",
+ )
+
def __init__(self, location, memberTypes):
IDLType.__init__(self, location, "")
self.memberTypes = memberTypes
@@ -3114,19 +3299,11 @@ class IDLUnionType(IDLType):
return "MaybeShared" + type.name
return type.name
- for (i, type) in enumerate(self.memberTypes):
- # Exclude typedefs because if given "typedef (B or C) test",
- # we want AOrTest, not AOrBOrC
- if not type.isComplete() and not isinstance(type, IDLTypedefType):
- self.memberTypes[i] = type.complete(scope)
-
- self.name = "Or".join(typeName(type) for type in self.memberTypes)
-
- # We do this again to complete the typedef types
- for (i, type) in enumerate(self.memberTypes):
+ for i, type in enumerate(self.memberTypes):
if not type.isComplete():
self.memberTypes[i] = type.complete(scope)
+ self.name = "Or".join(typeName(type) for type in self.memberTypes)
self.flatMemberTypes = list(self.memberTypes)
i = 0
while i < len(self.flatMemberTypes):
@@ -3163,7 +3340,7 @@ class IDLUnionType(IDLType):
continue
i += 1
- for (i, t) in enumerate(self.flatMemberTypes[:-1]):
+ for i, t in enumerate(self.flatMemberTypes[:-1]):
for u in self.flatMemberTypes[i + 1 :]:
if not t.isDistinguishableFrom(u):
raise WebIDLError(
@@ -3191,7 +3368,8 @@ class IDLUnionType(IDLType):
return True
def isExposedInAllOf(self, exposureSet):
- # We could have different member types in different globals. Just make sure that each thing in exposureSet has one of our member types exposed in it.
+ # We could have different member types in different globals.
+ # Just make sure that each thing in exposureSet has one of our member types exposed in it.
for globalName in exposureSet:
if not any(
t.unroll().isExposedInAllOf(set([globalName]))
@@ -3213,6 +3391,8 @@ class IDLUnionType(IDLType):
class IDLTypedefType(IDLType):
+ __slots__ = "inner", "builtin"
+
def __init__(self, location, innerType, name):
IDLType.__init__(self, location, name)
self.inner = innerType
@@ -3323,6 +3503,8 @@ class IDLTypedefType(IDLType):
class IDLTypedef(IDLObjectWithIdentifier):
+ __slots__ = ("innerType",)
+
def __init__(self, location, parentScope, innerType, name):
# Set self.innerType first, because IDLObjectWithIdentifier.__init__
# will call our __str__, which wants to use it.
@@ -3355,6 +3537,8 @@ class IDLTypedef(IDLObjectWithIdentifier):
class IDLWrapperType(IDLType):
+ __slots__ = "inner", "_identifier", "builtin"
+
def __init__(self, location, inner):
IDLType.__init__(self, location, inner.identifier.name)
self.inner = inner
@@ -3452,7 +3636,7 @@ class IDLWrapperType(IDLType):
or other.isSequence()
or other.isRecord()
)
- if self.isDictionary() and (other.nullable() or other.isUndefined()):
+ if self.isDictionary() and other.nullable():
return False
if (
other.isPrimitive()
@@ -3461,31 +3645,57 @@ class IDLWrapperType(IDLType):
or other.isSequence()
):
return True
- if self.isDictionary():
+
+ # If this needs to handle other dictionary-like types we probably need
+ # some additional checks first.
+ assert self.isDictionaryLike() == (
+ self.isDictionary() or self.isCallbackInterface()
+ )
+ if self.isDictionaryLike():
+ if other.isCallback():
+ # Let other determine if it's a LegacyTreatNonObjectAsNull callback
+ return other.isDistinguishableFrom(self)
+
+ assert (
+ other.isNonCallbackInterface()
+ or other.isAny()
+ or other.isUndefined()
+ or other.isObject()
+ or other.isDictionaryLike()
+ )
+ # At this point, dictionary-like (for 'self') and interface-like
+ # (for 'other') are the only two that are distinguishable.
+ # any is the union of all non-union types, so it's not distinguishable
+ # from other unions (because it is a union itself), or from all
+ # non-union types (because it has all of them as its members).
return other.isNonCallbackInterface()
- assert self.isInterface()
- if other.isInterface():
+ assert self.isNonCallbackInterface()
+
+ if other.isUndefined() or other.isDictionaryLike() or other.isCallback():
+ return True
+
+ if other.isNonCallbackInterface():
if other.isSpiderMonkeyInterface():
# Just let |other| handle things
return other.isDistinguishableFrom(self)
+
assert self.isGeckoInterface() and other.isGeckoInterface()
if self.inner.isExternal() or other.unroll().inner.isExternal():
return self != other
- return len(
- self.inner.interfacesBasedOnSelf
- & other.unroll().inner.interfacesBasedOnSelf
- ) == 0 and (self.isNonCallbackInterface() or other.isNonCallbackInterface())
- if (
- other.isUndefined()
- or other.isDictionary()
- or other.isCallback()
- or other.isRecord()
- ):
- return self.isNonCallbackInterface()
+ return (
+ len(
+ self.inner.interfacesBasedOnSelf
+ & other.unroll().inner.interfacesBasedOnSelf
+ )
+ == 0
+ )
- # Not much else |other| can be
- assert other.isObject()
+ # Not much else |other| can be.
+ # any is the union of all non-union types, so it's not distinguishable
+ # from other unions (because it is a union itself), or from all
+ # non-union types (because it has all of them as its members).
+ assert other.isAny() or other.isObject()
return False
def isExposedInAllOf(self, exposureSet):
@@ -3525,6 +3735,8 @@ class IDLWrapperType(IDLType):
class IDLPromiseType(IDLParametrizedType):
+ __slots__ = ()
+
def __init__(self, location, innerType):
IDLParametrizedType.__init__(self, location, "Promise", innerType)
@@ -3578,7 +3790,6 @@ class IDLPromiseType(IDLParametrizedType):
class IDLBuiltinType(IDLType):
-
Types = enum(
# The integer types
"byte",
@@ -3692,6 +3903,14 @@ class IDLBuiltinType(IDLType):
Types.ReadableStream: "ReadableStream",
}
+ __slots__ = (
+ "_typeTag",
+ "_clamped",
+ "_rangeEnforced",
+ "_withLegacyNullToEmptyString",
+ "_withAllowShared",
+ )
+
def __init__(
self,
location,
@@ -3704,9 +3923,9 @@ class IDLBuiltinType(IDLType):
attrLocation=[],
):
"""
- The mutually exclusive clamp/enforceRange/legacyNullToEmptyString/allowShared arguments are used
- to create instances of this type with the appropriate attributes attached. Use .clamped(),
- .rangeEnforced(), .withLegacyNullToEmptyString() and .withAllowShared().
+ The mutually exclusive clamp/enforceRange/legacyNullToEmptyString/allowShared arguments
+ are used to create instances of this type with the appropriate attributes attached. Use
+ .clamped(), .rangeEnforced(), .withLegacyNullToEmptyString() and .withAllowShared().
attrLocation is an array of source locations of these attributes for error reporting.
"""
@@ -4203,6 +4422,11 @@ class NoCoercionFoundError(WebIDLError):
class IDLValue(IDLObject):
+ __slots__ = (
+ "type",
+ "value",
+ )
+
def __init__(self, location, type, value):
IDLObject.__init__(self, location)
self.type = type
@@ -4263,7 +4487,7 @@ class IDLValue(IDLObject):
)
elif self.type.isInteger() and type.isFloat():
# Convert an integer literal into float
- if -(2 ** 24) <= self.value <= 2 ** 24:
+ if -(2**24) <= self.value <= 2**24:
return IDLValue(self.location, type, float(self.value))
else:
raise WebIDLError(
@@ -4335,6 +4559,8 @@ class IDLValue(IDLObject):
class IDLNullValue(IDLObject):
+ __slots__ = "type", "value"
+
def __init__(self, location):
IDLObject.__init__(self, location)
self.type = None
@@ -4364,6 +4590,8 @@ class IDLNullValue(IDLObject):
class IDLEmptySequenceValue(IDLObject):
+ __slots__ = "type", "value"
+
def __init__(self, location):
IDLObject.__init__(self, location)
self.type = None
@@ -4377,7 +4605,7 @@ class IDLEmptySequenceValue(IDLObject):
for subtype in type.unroll().flatMemberTypes:
try:
return self.coerceToType(subtype, location)
- except:
+ except Exception:
pass
if not type.isSequence():
@@ -4394,6 +4622,8 @@ class IDLEmptySequenceValue(IDLObject):
class IDLDefaultDictionaryValue(IDLObject):
+ __slots__ = "type", "value"
+
def __init__(self, location):
IDLObject.__init__(self, location)
self.type = None
@@ -4407,7 +4637,7 @@ class IDLDefaultDictionaryValue(IDLObject):
for subtype in type.unroll().flatMemberTypes:
try:
return self.coerceToType(subtype, location)
- except:
+ except Exception:
pass
if not type.isDictionary():
@@ -4424,6 +4654,8 @@ class IDLDefaultDictionaryValue(IDLObject):
class IDLUndefinedValue(IDLObject):
+ __slots__ = "type", "value"
+
def __init__(self, location):
IDLObject.__init__(self, location)
self.type = None
@@ -4444,7 +4676,6 @@ class IDLUndefinedValue(IDLObject):
class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
-
Tags = enum(
"Const", "Attr", "Method", "MaplikeOrSetlike", "AsyncIterable", "Iterable"
)
@@ -4454,6 +4685,7 @@ class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
AffectsValues = ("Nothing", "Everything")
DependsOnValues = ("Nothing", "DOMState", "DeviceState", "Everything")
+ # no slots : multiple inheritance
def __init__(self, location, identifier, tag, extendedAttrDict=None):
IDLObjectWithIdentifier.__init__(self, location, None, identifier)
IDLExposureMixins.__init__(self, location)
@@ -4552,7 +4784,7 @@ class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
)
if affects not in IDLInterfaceMember.AffectsValues:
raise WebIDLError(
- "Invalid [Affects=%s] on attribute" % dependsOn, [self.location]
+ "Invalid [Affects=%s] on attribute" % affects, [self.location]
)
self.affects = affects
@@ -4573,6 +4805,14 @@ class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
class IDLMaplikeOrSetlikeOrIterableBase(IDLInterfaceMember):
+ __slots__ = (
+ "keyType",
+ "valueType",
+ "maplikeOrSetlikeOrIterableType",
+ "disallowedMemberNames",
+ "disallowedNonMethodNames",
+ )
+
def __init__(self, location, identifier, ifaceType, keyType, valueType, ifaceKind):
IDLInterfaceMember.__init__(self, location, identifier, ifaceKind)
if keyType is not None:
@@ -4610,7 +4850,12 @@ class IDLMaplikeOrSetlikeOrIterableBase(IDLInterfaceMember):
for member in members:
# Check that there are no disallowed members
if member.identifier.name in self.disallowedMemberNames and not (
- (member.isMethod() and member.isMaplikeOrSetlikeOrIterableMethod())
+ (
+ member.isMethod()
+ and (
+ member.isStatic() or member.isMaplikeOrSetlikeOrIterableMethod()
+ )
+ )
or (member.isAttr() and member.isMaplikeOrSetlikeAttr())
):
raise WebIDLError(
@@ -4676,9 +4921,7 @@ class IDLMaplikeOrSetlikeOrIterableBase(IDLInterfaceMember):
self.disallowedNonMethodNames.append(name)
# If allowExistingOperations is True, and another operation exists
# with the same name as the one we're trying to add, don't add the
- # maplike/setlike operation. However, if the operation is static,
- # then fail by way of creating the function, which will cause a
- # naming conflict, per the spec.
+ # maplike/setlike operation.
if allowExistingOperations:
for m in members:
if m.identifier.name == name and m.isMethod() and not m.isStatic():
@@ -4786,6 +5029,8 @@ class IDLMaplikeOrSetlikeOrIterableBase(IDLInterfaceMember):
# Iterable adds ES6 iterator style functions and traits
# (keys/values/entries/@@iterator) to an interface.
class IDLIterable(IDLMaplikeOrSetlikeOrIterableBase):
+ __slots__ = ("iteratorType",)
+
def __init__(self, location, identifier, keyType, valueType, scope):
IDLMaplikeOrSetlikeOrIterableBase.__init__(
self,
@@ -4861,6 +5106,8 @@ class IDLIterable(IDLMaplikeOrSetlikeOrIterableBase):
class IDLAsyncIterable(IDLMaplikeOrSetlikeOrIterableBase):
+ __slots__ = "iteratorType", "argList"
+
def __init__(self, location, identifier, keyType, valueType, argList, scope):
for arg in argList:
if not arg.optional:
@@ -4945,6 +5192,8 @@ class IDLAsyncIterable(IDLMaplikeOrSetlikeOrIterableBase):
# MaplikeOrSetlike adds ES6 map-or-set-like traits to an interface.
class IDLMaplikeOrSetlike(IDLMaplikeOrSetlikeOrIterableBase):
+ __slots__ = "readonly", "slotIndices", "prefix"
+
def __init__(
self, location, identifier, maplikeOrSetlikeType, readonly, keyType, valueType
):
@@ -5112,6 +5361,8 @@ class IDLMaplikeOrSetlike(IDLMaplikeOrSetlikeOrIterableBase):
class IDLConst(IDLInterfaceMember):
+ __slots__ = "type", "value"
+
def __init__(self, location, identifier, type, value):
IDLInterfaceMember.__init__(
self, location, identifier, IDLInterfaceMember.Tags.Const
@@ -5144,7 +5395,7 @@ class IDLConst(IDLInterfaceMember):
locations = [self.type.location, type.location]
try:
locations.append(type.inner.location)
- except:
+ except Exception:
pass
raise WebIDLError("Incorrect type for constant", locations)
self.type = type
@@ -5184,6 +5435,21 @@ class IDLConst(IDLInterfaceMember):
class IDLAttribute(IDLInterfaceMember):
+ __slots__ = (
+ "type",
+ "readonly",
+ "inherit",
+ "_static",
+ "legacyLenientThis",
+ "_legacyUnforgeable",
+ "stringifier",
+ "slotIndices",
+ "maplikeOrSetlike",
+ "dependsOn",
+ "affects",
+ "bindingAliases",
+ )
+
def __init__(
self,
location,
@@ -5695,9 +5961,9 @@ class IDLAttribute(IDLInterfaceMember):
or identifier == "SetterNeedsSubjectPrincipal"
or identifier == "GetterNeedsSubjectPrincipal"
or identifier == "NeedsCallerType"
- or identifier == "ReturnValueNeedsContainsHack"
or identifier == "BinaryName"
or identifier == "NonEnumerable"
+ or identifier == "BindingTemplate"
):
# Known attributes that we don't need to do anything with here
pass
@@ -5708,6 +5974,9 @@ class IDLAttribute(IDLInterfaceMember):
)
IDLInterfaceMember.handleExtendedAttribute(self, attr)
+ def getExtendedAttributes(self):
+ return self._extendedAttrDict
+
def resolve(self, parentScope):
assert isinstance(parentScope, IDLScope)
self.type.resolveType(parentScope)
@@ -5760,7 +6029,7 @@ class IDLAttribute(IDLInterfaceMember):
"CrossOriginWritable",
"SetterThrows",
]
- for (key, value) in self._extendedAttrDict.items():
+ for key, value in self._extendedAttrDict.items():
if key in allowedExtAttrs:
if value is not True:
raise WebIDLError(
@@ -5772,7 +6041,7 @@ class IDLAttribute(IDLInterfaceMember):
method.addExtendedAttributes(
[IDLExtendedAttribute(self.location, (key,))]
)
- elif not key in attributeOnlyExtAttrs:
+ elif key not in attributeOnlyExtAttrs:
raise WebIDLError(
"[%s] is currently unsupported in "
"stringifier attributes, please file a bug "
@@ -5783,6 +6052,18 @@ class IDLAttribute(IDLInterfaceMember):
class IDLArgument(IDLObjectWithIdentifier):
+ __slots__ = (
+ "type",
+ "optional",
+ "defaultValue",
+ "variadic",
+ "dictionaryMember",
+ "_isComplete",
+ "_allowTreatNonCallableAsNull",
+ "_extendedAttrDict",
+ "allowTypeAttributes",
+ )
+
def __init__(
self,
location,
@@ -5835,6 +6116,18 @@ class IDLArgument(IDLObjectWithIdentifier):
"dictionary member" % identifier,
[attribute.location],
)
+ elif self.dictionaryMember and identifier == "BinaryType":
+ if not len(attribute.listValue()) == 1:
+ raise WebIDLError(
+ "[%s] BinaryType must take one argument" % identifier,
+ [attribute.location],
+ )
+ if not self.defaultValue:
+ raise WebIDLError(
+ "[%s] BinaryType can't be used without default value"
+ % identifier,
+ [attribute.location],
+ )
else:
raise WebIDLError(
"Unhandled extended attribute on %s"
@@ -5914,6 +6207,15 @@ class IDLArgument(IDLObjectWithIdentifier):
class IDLCallback(IDLObjectWithScope):
+ __slots__ = (
+ "_returnType",
+ "_arguments",
+ "_treatNonCallableAsNull",
+ "_treatNonObjectAsNull",
+ "_isRunScriptBoundary",
+ "_isConstructor",
+ )
+
def __init__(
self, location, parentScope, identifier, returnType, arguments, isConstructor
):
@@ -5925,7 +6227,7 @@ class IDLCallback(IDLObjectWithScope):
IDLObjectWithScope.__init__(self, location, parentScope, identifier)
- for (returnType, arguments) in self.signatures():
+ for returnType, arguments in self.signatures():
for argument in arguments:
argument.resolve(self)
@@ -6011,6 +6313,8 @@ class IDLCallback(IDLObjectWithScope):
class IDLCallbackType(IDLType):
+ __slots__ = ("callback",)
+
def __init__(self, location, callback):
IDLType.__init__(self, location, callback.identifier.name)
self.callback = callback
@@ -6027,6 +6331,9 @@ class IDLCallbackType(IDLType):
if other.isUnion():
# Just forward to the union; it'll deal
return other.isDistinguishableFrom(self)
+ # Callbacks without `LegacyTreatNonObjectAsNull` are distinguishable from Dictionary likes
+ if other.isDictionaryLike():
+ return not self.callback._treatNonObjectAsNull
return (
other.isUndefined()
or other.isPrimitive()
@@ -6050,6 +6357,8 @@ class IDLMethodOverload:
the full set of overloads.
"""
+ __slots__ = "returnType", "arguments", "location"
+
def __init__(self, returnType, arguments, location):
self.returnType = returnType
# Clone the list of arguments, just in case
@@ -6066,13 +6375,31 @@ class IDLMethodOverload:
class IDLMethod(IDLInterfaceMember, IDLScope):
-
Special = enum(
"Getter", "Setter", "Deleter", "LegacyCaller", base=IDLInterfaceMember.Special
)
NamedOrIndexed = enum("Neither", "Named", "Indexed")
+ __slots__ = (
+ "_hasOverloads",
+ "_overloads",
+ "_static",
+ "_getter",
+ "_setter",
+ "_deleter",
+ "_legacycaller",
+ "_stringifier",
+ "maplikeOrSetlikeOrIterable",
+ "_htmlConstructor",
+ "underlyingAttr",
+ "_specialType",
+ "_legacyUnforgeable",
+ "dependsOn",
+ "affects",
+ "aliases",
+ )
+
def __init__(
self,
location,
@@ -6249,7 +6576,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
assert isinstance(parentScope, IDLScope)
IDLObjectWithIdentifier.resolve(self, parentScope)
IDLScope.__init__(self, self.location, parentScope, self.identifier)
- for (returnType, arguments) in self.signatures():
+ for returnType, arguments in self.signatures():
for argument in arguments:
argument.resolve(self)
@@ -6299,22 +6626,35 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
if self.isLegacycaller() != method.isLegacycaller():
raise WebIDLError(
- "Overloaded identifier %s appears with different values of the 'legacycaller' attribute"
- % method.identifier,
+ (
+ "Overloaded identifier %s appears with different "
+ "values of the 'legacycaller' attribute" % method.identifier
+ ),
[method.location],
)
# Can't overload special things!
- assert not self.isGetter()
- assert not method.isGetter()
- assert not self.isSetter()
- assert not method.isSetter()
- assert not self.isDeleter()
- assert not method.isDeleter()
- assert not self.isStringifier()
- assert not method.isStringifier()
- assert not self.isHTMLConstructor()
- assert not method.isHTMLConstructor()
+ if (
+ self.isGetter()
+ or method.isGetter()
+ or self.isSetter()
+ or method.isSetter()
+ or self.isDeleter()
+ or method.isDeleter()
+ or self.isStringifier()
+ or method.isStringifier()
+ ):
+ raise WebIDLError(
+ ("Can't overload a special operation"),
+ [self.location, method.location],
+ )
+ if self.isHTMLConstructor() or method.isHTMLConstructor():
+ raise WebIDLError(
+ (
+ "An interface must contain only a single operation annotated with HTMLConstructor, and no others"
+ ),
+ [self.location, method.location],
+ )
return self
@@ -6390,7 +6730,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
variadicArgument = None
arguments = overload.arguments
- for (idx, argument) in enumerate(arguments):
+ for idx, argument in enumerate(arguments):
assert argument.type.isComplete()
if (
@@ -6523,8 +6863,8 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
def distinguishingIndexForArgCount(self, argc):
def isValidDistinguishingIndex(idx, signatures):
- for (firstSigIndex, (firstRetval, firstArgs)) in enumerate(signatures[:-1]):
- for (secondRetval, secondArgs) in signatures[firstSigIndex + 1 :]:
+ for firstSigIndex, (firstRetval, firstArgs) in enumerate(signatures[:-1]):
+ for secondRetval, secondArgs in signatures[firstSigIndex + 1 :]:
if idx < len(firstArgs):
firstType = firstArgs[idx].type
else:
@@ -6726,6 +7066,14 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
class IDLConstructor(IDLMethod):
+ __slots__ = (
+ "_initLocation",
+ "_initArgs",
+ "_initName",
+ "_inited",
+ "_initExtendedAttrs",
+ )
+
def __init__(self, location, args, name):
# We can't actually init our IDLMethod yet, because we do not know the
# return type yet. Just save the info we have for now and we will init
@@ -6795,6 +7143,8 @@ class IDLConstructor(IDLMethod):
class IDLIncludesStatement(IDLObject):
+ __slots__ = ("interface", "mixin", "_finished")
+
def __init__(self, location, interface, mixin):
IDLObject.__init__(self, location)
self.interface = interface
@@ -6851,6 +7201,8 @@ class IDLExtendedAttribute(IDLObject):
A class to represent IDL extended attributes so we can give them locations
"""
+ __slots__ = ("_tuple",)
+
def __init__(self, location, tuple):
IDLObject.__init__(self, location)
self._tuple = tuple
@@ -6891,7 +7243,7 @@ class IDLExtendedAttribute(IDLObject):
class Tokenizer(object):
- tokens = ["INTEGER", "FLOATLITERAL", "IDENTIFIER", "STRING", "WHITESPACE", "OTHER"]
+ tokens = ["INTEGER", "FLOATLITERAL", "IDENTIFIER", "STRING", "COMMENTS", "OTHER"]
def t_FLOATLITERAL(self, t):
r"(-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+|Infinity))|NaN"
@@ -6903,7 +7255,7 @@ class Tokenizer(object):
try:
# Can't use int(), because that doesn't handle octal properly.
t.value = parseInt(t.value)
- except:
+ except Exception:
raise WebIDLError(
"Invalid integer literal",
[
@@ -6930,17 +7282,19 @@ class Tokenizer(object):
t.value = t.value[1:-1]
return t
- def t_WHITESPACE(self, t):
- r"[\t\n\r ]+|[\t\n\r ]*((//[^\n]*|/\*.*?\*/)[\t\n\r ]*)+"
+ t_ignore = "\t\n\r "
+
+ def t_COMMENTS(self, t):
+ r"//[^\n]*|/\*(?s:.)*?\*/"
pass
def t_ELLIPSIS(self, t):
r"\.\.\."
- t.type = self.keywords.get(t.value)
+ t.type = "ELLIPSIS"
return t
def t_OTHER(self, t):
- r"[^\t\n\r 0-9A-Z_a-z]"
+ r"[^0-9A-Z_a-z]"
t.type = self.keywords.get(t.value, "OTHER")
return t
@@ -7029,7 +7383,7 @@ class Tokenizer(object):
lexer=self.lexer,
lineno=self.lexer.lineno,
lexpos=self.lexer.lexpos,
- filename=self.filename,
+ filename=self._filename,
)
],
)
@@ -7039,14 +7393,14 @@ class Tokenizer(object):
if lexer:
self.lexer = lexer
else:
- self.lexer = lex.lex(object=self, reflags=re.DOTALL)
+ self.lexer = lex.lex(object=self)
class SqueakyCleanLogger(object):
errorWhitelist = [
- # Web IDL defines the WHITESPACE token, but doesn't actually
+ # Web IDL defines the COMMENTS token, but doesn't actually
# use it ... so far.
- "Token 'WHITESPACE' defined, but not used",
+ "Token 'COMMENTS' defined, but not used",
# And that means we have an unused token
"There is 1 unused token",
# Web IDL defines a OtherOrComma rule that's only used in
@@ -8600,7 +8954,7 @@ class Parser(Tokenizer):
type = IDLWrapperType(self.getLocation(p, 1), p[1])
p[0] = self.handleNullable(type, p[2])
return
- except:
+ except Exception:
pass
type = IDLUnresolvedType(self.getLocation(p, 1), p[1])
@@ -8863,7 +9217,10 @@ class Parser(Tokenizer):
def p_error(self, p):
if not p:
raise WebIDLError(
- "Syntax Error at end of file. Possibly due to missing semicolon(;), braces(}) or both",
+ (
+ "Syntax Error at end of file. Possibly due to "
+ "missing semicolon(;), braces(}) or both"
+ ),
[self._filename],
)
else:
@@ -8912,9 +9269,7 @@ class Parser(Tokenizer):
):
builtin = BuiltinTypes[x]
name = builtin.name
- typedef = IDLTypedef(
- BuiltinLocation("<builtin type>"), scope, builtin, name
- )
+ IDLTypedef(BuiltinLocation("<builtin type>"), scope, builtin, name)
@staticmethod
def handleNullable(type, questionMarkLocation):
@@ -9114,13 +9469,8 @@ class Parser(Tokenizer):
production.validate()
# De-duplicate self._productions, without modifying its order.
- seen = set()
- result = []
- for p in self._productions:
- if p not in seen:
- seen.add(p)
- result.append(p)
- return result
+ result = dict.fromkeys(self._productions)
+ return list(result.keys())
def reset(self):
return Parser(lexer=self.lexer)
diff --git a/third_party/WebIDL/builtin-array.patch b/third_party/WebIDL/builtin-array.patch
new file mode 100644
index 00000000000..bba7660c382
--- /dev/null
+++ b/third_party/WebIDL/builtin-array.patch
@@ -0,0 +1,49 @@
+--- WebIDL.py
++++ WebIDL.py
+@@ -2549,6 +2549,17 @@ class IDLType(IDLObject):
+ "object",
+ # Funny stuff
+ "interface",
++ "int8array",
++ "uint8array",
++ "int16array",
++ "uint16array",
++ "int32array",
++ "uint32array",
++ "float32array",
++ "float64array",
++ "arrayBuffer",
++ "arrayBufferView",
++ "uint8clampedarray",
+ "dictionary",
+ "enum",
+ "callback",
+@@ -3842,17 +3853,17 @@ class IDLBuiltinType(IDLType):
+ Types.utf8string: IDLType.Tags.utf8string,
+ Types.jsstring: IDLType.Tags.jsstring,
+ Types.object: IDLType.Tags.object,
+- Types.ArrayBuffer: IDLType.Tags.interface,
+- Types.ArrayBufferView: IDLType.Tags.interface,
+- Types.Int8Array: IDLType.Tags.interface,
+- Types.Uint8Array: IDLType.Tags.interface,
+- Types.Uint8ClampedArray: IDLType.Tags.interface,
+- Types.Int16Array: IDLType.Tags.interface,
+- Types.Uint16Array: IDLType.Tags.interface,
+- Types.Int32Array: IDLType.Tags.interface,
+- Types.Uint32Array: IDLType.Tags.interface,
+- Types.Float32Array: IDLType.Tags.interface,
+- Types.Float64Array: IDLType.Tags.interface,
++ Types.ArrayBuffer: IDLType.Tags.arrayBuffer,
++ Types.ArrayBufferView: IDLType.Tags.arrayBufferView,
++ Types.Int8Array: IDLType.Tags.int8array,
++ Types.Uint8Array: IDLType.Tags.uint8array,
++ Types.Uint8ClampedArray: IDLType.Tags.uint8clampedarray,
++ Types.Int16Array: IDLType.Tags.int16array,
++ Types.Uint16Array: IDLType.Tags.uint16array,
++ Types.Int32Array: IDLType.Tags.int32array,
++ Types.Uint32Array: IDLType.Tags.uint32array,
++ Types.Float32Array: IDLType.Tags.float32array,
++ Types.Float64Array: IDLType.Tags.float64array,
+ Types.ReadableStream: IDLType.Tags.interface,
+ }
+
diff --git a/third_party/WebIDL/tests/test_any_null.py b/third_party/WebIDL/tests/test_any_null.py
index f9afdacb02f..e76935d0056 100644
--- a/third_party/WebIDL/tests/test_any_null.py
+++ b/third_party/WebIDL/tests/test_any_null.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_argument_identifier_conflicts.py b/third_party/WebIDL/tests/test_argument_identifier_conflicts.py
index 3f50cb05158..b6d60345160 100644
--- a/third_party/WebIDL/tests/test_argument_identifier_conflicts.py
+++ b/third_party/WebIDL/tests/test_argument_identifier_conflicts.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_argument_novoid.py b/third_party/WebIDL/tests/test_argument_novoid.py
new file mode 100644
index 00000000000..a72865e35b4
--- /dev/null
+++ b/third_party/WebIDL/tests/test_argument_novoid.py
@@ -0,0 +1,19 @@
+import WebIDL
+
+
+def WebIDLTest(parser, harness):
+ threw = False
+ try:
+ parser.parse(
+ """
+ interface VoidArgument1 {
+ void foo(void arg2);
+ };
+ """
+ )
+
+ parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+
+ harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_attr.py b/third_party/WebIDL/tests/test_attr.py
index e19689a81a9..b8dbccf41e7 100644
--- a/third_party/WebIDL/tests/test_attr.py
+++ b/third_party/WebIDL/tests/test_attr.py
@@ -147,7 +147,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [SetterThrows] on readonly attributes")
@@ -162,7 +162,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should spell [Throws] correctly")
@@ -177,7 +177,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should not allow [SameObject] on attributes not of interface type"
@@ -194,6 +194,6 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should allow [SameObject] on attributes of interface type")
diff --git a/third_party/WebIDL/tests/test_attr_sequence_type.py b/third_party/WebIDL/tests/test_attr_sequence_type.py
index f3249de900a..7a23265daf6 100644
--- a/third_party/WebIDL/tests/test_attr_sequence_type.py
+++ b/third_party/WebIDL/tests/test_attr_sequence_type.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Attribute type must not be a sequence type")
@@ -27,8 +30,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Attribute type must not be a union with a sequence member type")
@@ -45,8 +48,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -59,15 +62,15 @@ def WebIDLTest(parser, harness):
threw = False
try:
parser.parse(
- """
- interface AttrUnionWithUnionWithSequenceType {
- attribute ((sequence<object> or DOMString) or AttrUnionWithUnionWithSequenceType) foo;
- };
- """
+ "\n"
+ " interface AttrUnionWithUnionWithSequenceType {\n"
+ " attribute ((sequence<object> or DOMString) or "
+ "AttrUnionWithUnionWithSequenceType) foo;\n"
+ " };\n"
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
diff --git a/third_party/WebIDL/tests/test_attributes_on_types.py b/third_party/WebIDL/tests/test_attributes_on_types.py
index 97a7f47859a..d47fc87110e 100644
--- a/third_party/WebIDL/tests/test_attributes_on_types.py
+++ b/third_party/WebIDL/tests/test_attributes_on_types.py
@@ -1,4 +1,3 @@
-# Import the WebIDL module, so we can do isinstance checks and whatnot
import WebIDL
@@ -46,7 +45,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should not have thrown on parsing normal")
@@ -182,7 +181,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should not have thrown on parsing normal")
@@ -341,22 +340,22 @@ def WebIDLTest(parser, harness):
),
]
- for (name, template) in TEMPLATES:
+ for name, template in TEMPLATES:
parser = parser.reset()
threw = False
try:
parser.parse(template % ("", "long"))
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Template for %s parses without attributes" % name)
- for (attribute, type) in ATTRIBUTES:
+ for attribute, type in ATTRIBUTES:
parser = parser.reset()
threw = False
try:
parser.parse(template % (attribute, type))
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow %s on %s" % (attribute, name))
@@ -369,7 +368,7 @@ def WebIDLTest(parser, harness):
"""
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange]")
@@ -383,7 +382,7 @@ def WebIDLTest(parser, harness):
"""
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange]")
@@ -398,7 +397,7 @@ def WebIDLTest(parser, harness):
"""
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange] via typedefs")
@@ -413,7 +412,7 @@ def WebIDLTest(parser, harness):
"""
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow mixing [Clamp] and [EnforceRange] via typedefs")
@@ -437,7 +436,7 @@ def WebIDLTest(parser, harness):
% type
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [Clamp] on %s" % type)
@@ -452,7 +451,7 @@ def WebIDLTest(parser, harness):
% type
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [EnforceRange] on %s" % type)
@@ -466,7 +465,7 @@ def WebIDLTest(parser, harness):
"""
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [LegacyNullToEmptyString] on long")
@@ -480,7 +479,7 @@ def WebIDLTest(parser, harness):
"""
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [LegacyNullToEmptyString] on JSString")
@@ -494,7 +493,7 @@ def WebIDLTest(parser, harness):
"""
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -510,7 +509,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[AllowShared] only allowed on buffer source types")
@@ -523,7 +522,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[AllowShared] must take no arguments")
@@ -539,7 +538,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should allow type attributes on unresolved types")
harness.check(
@@ -560,11 +559,12 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should allow type attributes on typedefs")
harness.check(
results[0].members[0].signatures()[0][1][0].type.hasClamp(),
True,
- "Unresolved types that resolve to typedefs with attributes should correctly resolve with attributes",
+ "Unresolved types that resolve to typedefs with attributes should correctly resolve with "
+ "attributes",
)
diff --git a/third_party/WebIDL/tests/test_builtin_filename.py b/third_party/WebIDL/tests/test_builtin_filename.py
index 6c913bba822..97e8cb061f5 100644
--- a/third_party/WebIDL/tests/test_builtin_filename.py
+++ b/third_party/WebIDL/tests/test_builtin_filename.py
@@ -1,6 +1,3 @@
-import WebIDL
-
-
def WebIDLTest(parser, harness):
parser.parse(
"""
@@ -11,4 +8,4 @@ def WebIDLTest(parser, harness):
)
attr = parser.finish()[0].members[0]
- harness.check(attr.type.filename(), "<builtin>", "Filename on builtin type")
+ harness.check(attr.type.filename, "<builtin>", "Filename on builtin type")
diff --git a/third_party/WebIDL/tests/test_bytestring.py b/third_party/WebIDL/tests/test_bytestring.py
index a6f9f6ab9cb..248d2716f36 100644
--- a/third_party/WebIDL/tests/test_bytestring.py
+++ b/third_party/WebIDL/tests/test_bytestring.py
@@ -79,7 +79,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results2 = parser.finish()
+ parser.finish()
except WebIDL.WebIDLError as e:
harness.ok(
False,
@@ -96,7 +96,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results3 = parser.finish()
+ parser.finish()
except WebIDL.WebIDLError as e:
harness.ok(
False,
@@ -114,8 +114,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results4 = parser.finish()
- except WebIDL.WebIDLError as e:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
diff --git a/third_party/WebIDL/tests/test_callback_constructor.py b/third_party/WebIDL/tests/test_callback_constructor.py
index 832a92bb147..67ea8ff755a 100644
--- a/third_party/WebIDL/tests/test_callback_constructor.py
+++ b/third_party/WebIDL/tests/test_callback_constructor.py
@@ -59,7 +59,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -76,7 +76,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
diff --git a/third_party/WebIDL/tests/test_callback_interface.py b/third_party/WebIDL/tests/test_callback_interface.py
index 0d657f48032..102e96401bf 100644
--- a/third_party/WebIDL/tests/test_callback_interface.py
+++ b/third_party/WebIDL/tests/test_callback_interface.py
@@ -28,8 +28,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow non-callback parent of callback interface")
@@ -46,8 +46,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow callback parent of non-callback interface")
@@ -97,7 +97,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- for (i, iface) in enumerate(results):
+ for i, iface in enumerate(results):
harness.check(
iface.isSingleOperationInterface(),
i < 4,
diff --git a/third_party/WebIDL/tests/test_cereactions.py b/third_party/WebIDL/tests/test_cereactions.py
index c56c3dbde10..2aa4da40c82 100644
--- a/third_party/WebIDL/tests/test_cereactions.py
+++ b/third_party/WebIDL/tests/test_cereactions.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] with an argument")
@@ -26,8 +29,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] with an argument")
@@ -43,7 +46,7 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
+ parser.finish()
except Exception as e:
harness.ok(
False,
@@ -63,7 +66,7 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
+ parser.finish()
except Exception as e:
harness.ok(
False,
@@ -83,8 +86,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -102,8 +105,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] used on a interface")
@@ -118,8 +121,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] used on a named getter")
@@ -134,8 +137,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] used on a legacycaller")
@@ -150,8 +153,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] used on a stringifier")
diff --git a/third_party/WebIDL/tests/test_const.py b/third_party/WebIDL/tests/test_const.py
index f2d4b79d467..da83db41ef5 100644
--- a/third_party/WebIDL/tests/test_const.py
+++ b/third_party/WebIDL/tests/test_const.py
@@ -64,7 +64,7 @@ def WebIDLTest(parser, harness):
len(iface.members), len(expected), "Expect %s members" % len(expected)
)
- for (const, (QName, name, type, value)) in zip(iface.members, expected):
+ for const, (QName, name, type, value) in zip(iface.members, expected):
harness.ok(isinstance(const, WebIDL.IDLConst), "Should be an IDLConst")
harness.ok(const.isConst(), "Const is a const")
harness.ok(not const.isAttr(), "Const is not an attr")
@@ -91,6 +91,6 @@ def WebIDLTest(parser, harness):
"""
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Nullable types are not allowed for consts.")
diff --git a/third_party/WebIDL/tests/test_constructor.py b/third_party/WebIDL/tests/test_constructor.py
index de5d52f1412..1a08a828fd1 100644
--- a/third_party/WebIDL/tests/test_constructor.py
+++ b/third_party/WebIDL/tests/test_constructor.py
@@ -87,7 +87,7 @@ def WebIDLTest(parser, harness):
)
sigpairs = zip(method.signatures(), signatures)
- for (gotSignature, expectedSignature) in sigpairs:
+ for gotSignature, expectedSignature in sigpairs:
(gotRetType, gotArgs) = gotSignature
(expectedRetType, expectedArgs) = expectedSignature
@@ -264,7 +264,7 @@ def WebIDLTest(parser, harness):
parser.parse(
"""
interface TestFuncConstructor {
- [Func="Document::IsWebAnimationsEnabled"] constructor();
+ [Func="IsNotUAWidget"] constructor();
};
"""
)
@@ -277,17 +277,19 @@ def WebIDLTest(parser, harness):
"::TestFuncConstructor::constructor",
"constructor",
[("TestFuncConstructor (Wrapper)", [])],
- func=["Document::IsWebAnimationsEnabled"],
+ func=["IsNotUAWidget"],
)
parser = parser.reset()
parser.parse(
- """
- interface TestPrefChromeOnlySCFuncConstructor {
- [ChromeOnly, Pref="dom.webidl.test1", SecureContext, Func="Document::IsWebAnimationsEnabled"]
- constructor();
- };
- """
+ (
+ "\n"
+ " interface TestPrefChromeOnlySCFuncConstructor {\n"
+ ' [ChromeOnly, Pref="dom.webidl.test1", SecureContext, '
+ 'Func="IsNotUAWidget"]\n'
+ " constructor();\n"
+ " };\n"
+ )
)
results = parser.finish()
harness.check(len(results), 1, "Should be one production")
@@ -298,7 +300,7 @@ def WebIDLTest(parser, harness):
"::TestPrefChromeOnlySCFuncConstructor::constructor",
"constructor",
[("TestPrefChromeOnlySCFuncConstructor (Wrapper)", [])],
- func=["Document::IsWebAnimationsEnabled"],
+ func=["IsNotUAWidget"],
pref=["dom.webidl.test1"],
chromeOnly=True,
secureContext=True,
@@ -336,7 +338,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Can't have both a constructor and a ChromeOnly constructor")
@@ -353,7 +355,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "HTMLConstructor should take no argument")
@@ -370,7 +372,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "HTMLConstructor can't be used on a callback interface")
@@ -388,7 +390,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Can't have both a constructor and a HTMLConstructor")
@@ -406,7 +408,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Can't have both a throwing constructor and a HTMLConstructor")
@@ -423,7 +425,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Can't have both a HTMLConstructor and a constructor operation")
@@ -441,7 +443,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -463,7 +465,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Can't have both a ChromeOnly constructor and a HTMLConstructor")
@@ -481,7 +483,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -502,7 +504,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -523,7 +525,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -544,7 +546,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -567,7 +569,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Can't have a constructor operation on a partial interface")
@@ -588,7 +590,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Can't have a constructor operation on a mixin")
diff --git a/third_party/WebIDL/tests/test_constructor_global.py b/third_party/WebIDL/tests/test_constructor_global.py
index 5f3663602e4..387698d9dd5 100644
--- a/third_party/WebIDL/tests/test_constructor_global.py
+++ b/third_party/WebIDL/tests/test_constructor_global.py
@@ -1,4 +1,4 @@
-import traceback
+import WebIDL
def WebIDLTest(parser, harness):
@@ -6,15 +6,15 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=TestConstructorGlobal]
+ [Global=TestConstructorGlobal, Exposed=TestConstructorGlobal]
interface TestConstructorGlobal {
constructor();
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -24,14 +24,14 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=TestLegacyFactoryFunctionGlobal,
+ [Global=TestLegacyFactoryFunctionGlobal, Exposed=TestLegacyFactoryFunctionGlobal,
LegacyFactoryFunction=FooBar]
interface TestLegacyFactoryFunctionGlobal {
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -41,14 +41,14 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [LegacyFactoryFunction=FooBar, Global,
+ [LegacyFactoryFunction=FooBar, Global=TestLegacyFactoryFunctionGlobal,
Exposed=TestLegacyFactoryFunctionGlobal]
interface TestLegacyFactoryFunctionGlobal {
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -58,15 +58,15 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=TestHTMLConstructorGlobal]
+ [Global=TestHTMLConstructorGlobal, Exposed=TestHTMLConstructorGlobal]
interface TestHTMLConstructorGlobal {
[HTMLConstructor] constructor();
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_constructor_no_interface_object.py b/third_party/WebIDL/tests/test_constructor_no_interface_object.py
index 9855352a9d4..b8f8589f280 100644
--- a/third_party/WebIDL/tests/test_constructor_no_interface_object.py
+++ b/third_party/WebIDL/tests/test_constructor_no_interface_object.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -10,8 +13,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -40,8 +43,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_deduplicate.py b/third_party/WebIDL/tests/test_deduplicate.py
index 6649f4ec05d..2308f6201e4 100644
--- a/third_party/WebIDL/tests/test_deduplicate.py
+++ b/third_party/WebIDL/tests/test_deduplicate.py
@@ -1,6 +1,3 @@
-import WebIDL
-
-
def WebIDLTest(parser, harness):
parser.parse(
"""
diff --git a/third_party/WebIDL/tests/test_dictionary.py b/third_party/WebIDL/tests/test_dictionary.py
index e7d04f995a9..80c13a4238e 100644
--- a/third_party/WebIDL/tests/test_dictionary.py
+++ b/third_party/WebIDL/tests/test_dictionary.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
parser.parse(
"""
@@ -67,8 +70,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow name duplication in a dictionary")
@@ -87,8 +90,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -112,8 +115,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -132,8 +135,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow non-dictionary parents for dictionaries")
@@ -148,8 +151,8 @@ def WebIDLTest(parser, harness):
dictionary B : A {};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow cycles in dictionary inheritance chains")
@@ -164,8 +167,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -184,8 +187,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Trailing dictionary arg must be optional")
@@ -202,8 +205,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Trailing dictionary arg must have a default value")
@@ -220,8 +223,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Trailing union arg containing a dictionary must be optional")
@@ -238,8 +241,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -258,8 +261,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Dictionary arg followed by optional arg must be optional")
@@ -276,8 +279,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Dictionary arg followed by optional arg must have default value")
@@ -294,8 +297,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -315,8 +318,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -336,8 +339,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -356,7 +359,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(True, "Dictionary arg followed by required arg can be required")
parser = parser.reset()
@@ -371,7 +374,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
except Exception as x:
threw = x
@@ -394,7 +397,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
except Exception as x:
threw = x
@@ -416,7 +419,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
except Exception as x:
threw = x
@@ -440,7 +443,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
except Exception as x:
threw = x
@@ -463,8 +466,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Nullable union should be allowed in a sequence argument")
@@ -481,8 +484,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Dictionary must not be in a union with a nullable type")
@@ -498,8 +501,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "A nullable type must not be in a union with a dictionary")
@@ -513,7 +516,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(True, "Dictionary return value can be nullable")
parser = parser.reset()
@@ -526,7 +529,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(True, "Dictionary arg should actually parse")
parser = parser.reset()
@@ -539,7 +542,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(True, "Union arg containing a dictionary should actually parse")
parser = parser.reset()
@@ -552,7 +555,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(
True,
"Union arg containing a dictionary with string default should actually parse",
@@ -568,8 +571,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Member type must not be its Dictionary.")
@@ -596,8 +599,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -615,8 +618,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -635,8 +638,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -655,8 +658,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -675,8 +678,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -707,8 +710,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -731,8 +734,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Member type must not be a nullable dictionary")
@@ -759,7 +762,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(True, "Parsing default values for unrestricted types succeeded.")
parser = parser.reset()
@@ -772,8 +775,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Only unrestricted values can be initialized to Infinity")
@@ -788,8 +791,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Only unrestricted values can be initialized to -Infinity")
@@ -804,8 +807,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Only unrestricted values can be initialized to NaN")
@@ -820,8 +823,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Only unrestricted values can be initialized to Infinity")
@@ -836,8 +839,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Only unrestricted values can be initialized to -Infinity")
@@ -852,8 +855,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Only unrestricted values can be initialized to NaN")
@@ -868,8 +871,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should be able to use 'module' as a dictionary member name")
diff --git a/third_party/WebIDL/tests/test_distinguishability.py b/third_party/WebIDL/tests/test_distinguishability.py
index e96026c2a09..caf726c16b8 100644
--- a/third_party/WebIDL/tests/test_distinguishability.py
+++ b/third_party/WebIDL/tests/test_distinguishability.py
@@ -1,4 +1,4 @@
-import traceback
+import WebIDL
def firstArgType(method):
@@ -143,8 +143,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -167,8 +167,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should throw when there is no distinguishing index")
@@ -228,7 +228,9 @@ def WebIDLTest(parser, harness):
and (a != "any" and a != "Promise<any>" and a != "Promise<any>?")
]
- unions = ["(long or Callback)", "(long or Dict)"]
+ unionsWithCallback = ["(long or Callback)"]
+ unionsNoCallback = ["(long or Dict)"]
+ unions = unionsWithCallback + unionsNoCallback
numerics = ["long", "short", "long?", "short?"]
booleans = ["boolean", "boolean?"]
undefineds = ["undefined", "undefined?"]
@@ -246,7 +248,6 @@ def WebIDLTest(parser, harness):
]
nonStrings = allBut(argTypes, strings)
nonObjects = undefineds + primitives + strings
- objects = allBut(argTypes, nonObjects)
bufferSourceTypes = ["ArrayBuffer", "ArrayBufferView", "Uint8Array", "Uint16Array"]
interfaces = [
"Interface",
@@ -266,7 +267,7 @@ def WebIDLTest(parser, harness):
"Date?",
"any",
"Promise<any>?",
- ] + allBut(unions, ["(long or Callback)"])
+ ] + unionsNoCallback
sequences = ["sequence<long>", "sequence<short>"]
nonUserObjects = nonObjects + interfaces + sequences
otherObjects = allBut(argTypes, nonUserObjects + ["object"])
@@ -283,17 +284,14 @@ def WebIDLTest(parser, harness):
"record<ByteString, long>",
"record<UTF8String, long>",
] # JSString not supported in records
- dictionaryLike = (
- [
- "Dict",
- "Dict2",
- "CallbackInterface",
- "CallbackInterface?",
- "CallbackInterface2",
- ]
- + records
- + allBut(unions, ["(long or Callback)"])
- )
+ dicts = ["Dict", "Dict2"]
+ callbacks = ["Callback", "Callback2"]
+ callbackInterfaces = [
+ "CallbackInterface",
+ "CallbackInterface?",
+ "CallbackInterface2",
+ ]
+ dictionaryLike = dicts + callbackInterfaces + records + unionsNoCallback
# Build a representation of the distinguishability table as a dict
# of dicts, holding True values where needed, holes elsewhere.
@@ -328,23 +326,60 @@ def WebIDLTest(parser, harness):
setDistinguishable(
"UnrelatedInterface", allBut(argTypes, ["object", "UnrelatedInterface"])
)
- setDistinguishable("CallbackInterface", allBut(nonUserObjects, undefineds))
setDistinguishable(
- "CallbackInterface?", allBut(nonUserObjects, nullables + undefineds)
+ "CallbackInterface",
+ allBut(nonUserObjects + callbacks + unionsWithCallback, undefineds),
+ )
+ setDistinguishable(
+ "CallbackInterface?",
+ allBut(nonUserObjects + callbacks + unionsWithCallback, nullables + undefineds),
+ )
+ setDistinguishable(
+ "CallbackInterface2",
+ allBut(nonUserObjects + callbacks + unionsWithCallback, undefineds),
)
- setDistinguishable("CallbackInterface2", allBut(nonUserObjects, undefineds))
setDistinguishable("object", nonObjects)
- setDistinguishable("Callback", nonUserObjects)
- setDistinguishable("Callback2", nonUserObjects)
- setDistinguishable("Dict", allBut(nonUserObjects, nullables + undefineds))
- setDistinguishable("Dict2", allBut(nonUserObjects, nullables + undefineds))
- setDistinguishable("sequence<long>", allBut(argTypes, sequences + ["object"]))
- setDistinguishable("sequence<short>", allBut(argTypes, sequences + ["object"]))
- setDistinguishable("record<DOMString, object>", allBut(nonUserObjects, undefineds))
- setDistinguishable("record<USVString, Dict>", allBut(nonUserObjects, undefineds))
+ setDistinguishable(
+ "Callback",
+ nonUserObjects + unionsNoCallback + dicts + records + callbackInterfaces,
+ )
+ setDistinguishable(
+ "Callback2",
+ nonUserObjects + unionsNoCallback + dicts + records + callbackInterfaces,
+ )
+ setDistinguishable(
+ "Dict",
+ allBut(nonUserObjects + unionsWithCallback + callbacks, nullables + undefineds),
+ )
+ setDistinguishable(
+ "Dict2",
+ allBut(nonUserObjects + unionsWithCallback + callbacks, nullables + undefineds),
+ )
+ setDistinguishable(
+ "sequence<long>",
+ allBut(argTypes, sequences + ["object"]),
+ )
+ setDistinguishable(
+ "sequence<short>",
+ allBut(argTypes, sequences + ["object"]),
+ )
+ setDistinguishable(
+ "record<DOMString, object>",
+ allBut(nonUserObjects + unionsWithCallback + callbacks, undefineds),
+ )
+ setDistinguishable(
+ "record<USVString, Dict>",
+ allBut(nonUserObjects + unionsWithCallback + callbacks, undefineds),
+ )
# JSString not supported in records
- setDistinguishable("record<ByteString, long>", allBut(nonUserObjects, undefineds))
- setDistinguishable("record<UTF8String, long>", allBut(nonUserObjects, undefineds))
+ setDistinguishable(
+ "record<ByteString, long>",
+ allBut(nonUserObjects + unionsWithCallback + callbacks, undefineds),
+ )
+ setDistinguishable(
+ "record<UTF8String, long>",
+ allBut(nonUserObjects + unionsWithCallback + callbacks, undefineds),
+ )
setDistinguishable("any", [])
setDistinguishable("Promise<any>", [])
setDistinguishable("Promise<any>?", [])
@@ -359,9 +394,13 @@ def WebIDLTest(parser, harness):
setDistinguishable(
"Uint16Array", allBut(argTypes, ["ArrayBufferView", "Uint16Array", "object"])
)
- setDistinguishable("(long or Callback)", allBut(nonUserObjects, numerics))
setDistinguishable(
- "(long or Dict)", allBut(nonUserObjects, numerics + nullables + undefineds)
+ "(long or Callback)",
+ allBut(nonUserObjects + dicts + records + callbackInterfaces, numerics),
+ )
+ setDistinguishable(
+ "(long or Dict)",
+ allBut(nonUserObjects + callbacks, numerics + nullables + undefineds),
)
def areDistinguishable(type1, type2):
@@ -378,6 +417,7 @@ def WebIDLTest(parser, harness):
callback interface CallbackInterface2 {};
callback Callback = any();
callback Callback2 = long(short arg);
+ [LegacyTreatNonObjectAsNull] callback LegacyCallback1 = any();
// Give our dictionaries required members so we don't need to
// mess with optional and default values.
dictionary Dict { required long member; };
@@ -401,8 +441,8 @@ def WebIDLTest(parser, harness):
threw = False
try:
parser.parse(idl)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
if areDistinguishable(type1, type2):
diff --git a/third_party/WebIDL/tests/test_double_null.py b/third_party/WebIDL/tests/test_double_null.py
index a8876a7fd2d..28166020c10 100644
--- a/third_party/WebIDL/tests/test_double_null.py
+++ b/third_party/WebIDL/tests/test_double_null.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_duplicate_qualifiers.py b/third_party/WebIDL/tests/test_duplicate_qualifiers.py
index 89a4e1acf0b..bb02f96acfb 100644
--- a/third_party/WebIDL/tests/test_duplicate_qualifiers.py
+++ b/third_party/WebIDL/tests/test_duplicate_qualifiers.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -25,8 +28,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -41,8 +44,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -57,8 +60,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_empty_enum.py b/third_party/WebIDL/tests/test_empty_enum.py
index 09333a659cd..ad002caa4ee 100644
--- a/third_party/WebIDL/tests/test_empty_enum.py
+++ b/third_party/WebIDL/tests/test_empty_enum.py
@@ -11,7 +11,7 @@ def WebIDLTest(parser, harness):
)
harness.ok(False, "Should have thrown!")
- except:
+ except WebIDL.WebIDLError:
harness.ok(True, "Parsing TestEmptyEnum enum should fail")
- results = parser.finish()
+ parser.finish()
diff --git a/third_party/WebIDL/tests/test_empty_sequence_default_value.py b/third_party/WebIDL/tests/test_empty_sequence_default_value.py
index 21837743523..4771a6b1e54 100644
--- a/third_party/WebIDL/tests/test_empty_sequence_default_value.py
+++ b/third_party/WebIDL/tests/test_empty_sequence_default_value.py
@@ -13,7 +13,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Constant cannot have [] as a default value")
diff --git a/third_party/WebIDL/tests/test_enum.py b/third_party/WebIDL/tests/test_enum.py
index 56c6b3f64aa..4eb26f7eaf9 100644
--- a/third_party/WebIDL/tests/test_enum.py
+++ b/third_party/WebIDL/tests/test_enum.py
@@ -86,8 +86,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow a bogus default value for an enum")
diff --git a/third_party/WebIDL/tests/test_enum_duplicate_values.py b/third_party/WebIDL/tests/test_enum_duplicate_values.py
index 8969281e1c7..f40a178442b 100644
--- a/third_party/WebIDL/tests/test_enum_duplicate_values.py
+++ b/third_party/WebIDL/tests/test_enum_duplicate_values.py
@@ -12,5 +12,5 @@ def WebIDLTest(parser, harness):
"""
)
harness.ok(False, "Should have thrown!")
- except:
+ except WebIDL.WebIDLError:
harness.ok(True, "Enum TestEnumDuplicateValue should throw")
diff --git a/third_party/WebIDL/tests/test_error_colno.py b/third_party/WebIDL/tests/test_error_colno.py
index 1c9bb065580..b08ba7cc172 100644
--- a/third_party/WebIDL/tests/test_error_colno.py
+++ b/third_party/WebIDL/tests/test_error_colno.py
@@ -8,7 +8,7 @@ def WebIDLTest(parser, harness):
input = "interface ?"
try:
parser.parse(input)
- results = parser.finish()
+ parser.finish()
except WebIDL.WebIDLError as e:
threw = True
lines = str(e).split("\n")
diff --git a/third_party/WebIDL/tests/test_error_lineno.py b/third_party/WebIDL/tests/test_error_lineno.py
index 0d10e006787..30629be30c0 100644
--- a/third_party/WebIDL/tests/test_error_lineno.py
+++ b/third_party/WebIDL/tests/test_error_lineno.py
@@ -14,7 +14,7 @@ interface Foo {
interface ?"""
try:
parser.parse(input)
- results = parser.finish()
+ parser.finish()
except WebIDL.WebIDLError as e:
threw = True
lines = str(e).split("\n")
diff --git a/third_party/WebIDL/tests/test_exposed_extended_attribute.py b/third_party/WebIDL/tests/test_exposed_extended_attribute.py
index c5ea8e4b88b..015b495be28 100644
--- a/third_party/WebIDL/tests/test_exposed_extended_attribute.py
+++ b/third_party/WebIDL/tests/test_exposed_extended_attribute.py
@@ -4,7 +4,7 @@ import WebIDL
def WebIDLTest(parser, harness):
parser.parse(
"""
- [Global, Exposed=Foo] interface Foo {};
+ [Global=Foo, Exposed=Foo] interface Foo {};
[Global=(Bar, Bar1,Bar2), Exposed=Bar] interface Bar {};
[Global=(Baz, Baz2), Exposed=Baz] interface Baz {};
@@ -70,7 +70,7 @@ def WebIDLTest(parser, harness):
parser = parser.reset()
parser.parse(
"""
- [Global, Exposed=Foo] interface Foo {};
+ [Global=Foo, Exposed=Foo] interface Foo {};
[Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {};
[Global=(Baz, Baz2), Exposed=Baz] interface Baz {};
@@ -108,7 +108,7 @@ def WebIDLTest(parser, harness):
parser = parser.reset()
parser.parse(
"""
- [Global, Exposed=Foo] interface Foo {};
+ [Global=Foo, Exposed=Foo] interface Foo {};
[Global=(Bar, Bar1, Bar2), Exposed=Bar] interface Bar {};
[Global=(Baz, Baz2), Exposed=Baz] interface Baz {};
@@ -162,7 +162,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown on invalid Exposed value on interface.")
@@ -180,7 +180,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown on invalid Exposed value on attribute.")
@@ -198,7 +198,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown on invalid Exposed value on operation.")
@@ -216,7 +216,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown on invalid Exposed value on constant.")
@@ -226,8 +226,8 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Foo] interface Foo {};
- [Global, Exposed=Bar] interface Bar {};
+ [Global=Foo, Exposed=Foo] interface Foo {};
+ [Global=Bar, Exposed=Bar] interface Bar {};
[Exposed=Foo]
interface Baz {
@@ -238,7 +238,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -248,8 +248,8 @@ def WebIDLTest(parser, harness):
parser = parser.reset()
parser.parse(
"""
- [Global, Exposed=Foo] interface Foo {};
- [Global, Exposed=Bar] interface Bar {};
+ [Global=Foo, Exposed=Foo] interface Foo {};
+ [Global=Bar, Exposed=Bar] interface Bar {};
[Exposed=Foo]
interface Baz {
@@ -294,8 +294,8 @@ def WebIDLTest(parser, harness):
parser = parser.reset()
parser.parse(
"""
- [Global, Exposed=Foo] interface Foo {};
- [Global, Exposed=Bar] interface Bar {};
+ [Global=Foo, Exposed=Foo] interface Foo {};
+ [Global=Bar, Exposed=Bar] interface Bar {};
[Exposed=*]
interface Baz {
@@ -342,8 +342,8 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Foo] interface Foo {};
- [Global, Exposed=Bar] interface Bar {};
+ [Global=Foo, Exposed=Foo] interface Foo {};
+ [Global=Bar, Exposed=Bar] interface Bar {};
[Exposed=Foo]
interface Baz {
@@ -354,7 +354,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -366,8 +366,8 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Foo] interface Foo {};
- [Global, Exposed=Bar] interface Bar {};
+ [Global=Foo, Exposed=Foo] interface Foo {};
+ [Global=Bar, Exposed=Bar] interface Bar {};
[Exposed=(Foo,*)]
interface Baz {
@@ -377,7 +377,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown on a wildcard in an identifier list.")
diff --git a/third_party/WebIDL/tests/test_extended_attributes.py b/third_party/WebIDL/tests/test_extended_attributes.py
index 423a67540c7..96c8ee9acbb 100644
--- a/third_party/WebIDL/tests/test_extended_attributes.py
+++ b/third_party/WebIDL/tests/test_extended_attributes.py
@@ -11,7 +11,7 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
+ parser.finish()
parser = parser.reset()
parser.parse(
@@ -23,7 +23,7 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
+ parser.finish()
parser = parser.reset()
parser.parse(
@@ -49,8 +49,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[LegacyLenientThis] must take no arguments")
@@ -86,8 +86,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[Clamp] must take no arguments")
@@ -124,8 +124,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[EnforceRange] must take no arguments")
diff --git a/third_party/WebIDL/tests/test_float_types.py b/third_party/WebIDL/tests/test_float_types.py
index d37443819d8..1b3b6556d85 100644
--- a/third_party/WebIDL/tests/test_float_types.py
+++ b/third_party/WebIDL/tests/test_float_types.py
@@ -55,7 +55,7 @@ def WebIDLTest(parser, harness):
method = iface.members[6]
harness.ok(isinstance(method, WebIDL.IDLMethod), "Should be an IDLMethod")
argtypes = [a.type for a in method.signatures()[0][1]]
- for (idx, type) in enumerate(argtypes):
+ for idx, type in enumerate(argtypes):
harness.ok(type.isFloat(), "Type %d should be float" % idx)
harness.check(
type.isUnrestricted(),
@@ -74,7 +74,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[LenientFloat] only allowed on methods returning undefined")
@@ -89,7 +89,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "[LenientFloat] only allowed on methods with unrestricted float args"
@@ -106,7 +106,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "[LenientFloat] only allowed on methods with unrestricted float args (2)"
@@ -123,7 +123,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "[LenientFloat] only allowed on methods with unrestricted float args (3)"
@@ -140,6 +140,6 @@ def WebIDLTest(parser, harness):
};
"""
)
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[LenientFloat] only allowed on writable attributes")
diff --git a/third_party/WebIDL/tests/test_forward_decl.py b/third_party/WebIDL/tests/test_forward_decl.py
index 1c81718400a..1ba19e42fc7 100644
--- a/third_party/WebIDL/tests/test_forward_decl.py
+++ b/third_party/WebIDL/tests/test_forward_decl.py
@@ -1,6 +1,3 @@
-import WebIDL
-
-
def WebIDLTest(parser, harness):
parser.parse(
"""
@@ -13,6 +10,6 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(True, "TestForwardDeclared interface parsed without error.")
diff --git a/third_party/WebIDL/tests/test_global_extended_attr.py b/third_party/WebIDL/tests/test_global_extended_attr.py
index 9ee27efbc8d..9d52747a1da 100644
--- a/third_party/WebIDL/tests/test_global_extended_attr.py
+++ b/third_party/WebIDL/tests/test_global_extended_attr.py
@@ -1,7 +1,10 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
parser.parse(
"""
- [Global, Exposed=Foo]
+ [Global=Foo, Exposed=Foo]
interface Foo : Bar {
getter any(DOMString name);
};
@@ -26,15 +29,15 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Foo]
+ [Global=Foo, Exposed=Foo]
interface Foo {
getter any(DOMString name);
setter undefined(DOMString name, any arg);
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -47,15 +50,15 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Foo]
+ [Global=Foo, Exposed=Foo]
interface Foo {
getter any(DOMString name);
deleter undefined(DOMString name);
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -68,13 +71,13 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, LegacyOverrideBuiltIns, Exposed=Foo]
+ [Global=Foo, LegacyOverrideBuiltIns, Exposed=Foo]
interface Foo {
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -88,7 +91,7 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Foo]
+ [Global=Foo, Exposed=Foo]
interface Foo : Bar {
};
[LegacyOverrideBuiltIns, Exposed=Foo]
@@ -96,8 +99,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -111,7 +114,7 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Foo]
+ [Global=Foo, Exposed=Foo]
interface Foo {
};
[Exposed=Foo]
@@ -119,11 +122,30 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
"Should have thrown for [Global] used on an interface with a " "descendant",
)
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse(
+ """
+ [Global, Exposed=Foo]
+ interface Foo {
+ };
+ """
+ )
+ parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+
+ harness.ok(
+ threw,
+ "Should have thrown for [Global] without a right hand side value",
+ )
diff --git a/third_party/WebIDL/tests/test_identifier_conflict.py b/third_party/WebIDL/tests/test_identifier_conflict.py
index 7404c86f944..424f4d6285b 100644
--- a/third_party/WebIDL/tests/test_identifier_conflict.py
+++ b/third_party/WebIDL/tests/test_identifier_conflict.py
@@ -1,7 +1,3 @@
-# Import the WebIDL module, so we can do isinstance checks and whatnot
-import WebIDL
-
-
def WebIDLTest(parser, harness):
try:
parser.parse(
@@ -10,7 +6,7 @@ def WebIDLTest(parser, harness):
interface Foo;
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(False, "Should fail to parse")
except Exception as e:
harness.ok(
@@ -25,7 +21,7 @@ def WebIDLTest(parser, harness):
enum Foo { "a" };
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(False, "Should fail to parse")
except Exception as e:
harness.ok(
@@ -40,7 +36,7 @@ def WebIDLTest(parser, harness):
enum Foo { "b" };
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(False, "Should fail to parse")
except Exception as e:
harness.ok(
diff --git a/third_party/WebIDL/tests/test_incomplete_parent.py b/third_party/WebIDL/tests/test_incomplete_parent.py
index ed476b8ed4c..80662a7848f 100644
--- a/third_party/WebIDL/tests/test_incomplete_parent.py
+++ b/third_party/WebIDL/tests/test_incomplete_parent.py
@@ -1,6 +1,3 @@
-import WebIDL
-
-
def WebIDLTest(parser, harness):
parser.parse(
"""
diff --git a/third_party/WebIDL/tests/test_interface.py b/third_party/WebIDL/tests/test_interface.py
index 85748848e1b..5b32a27f4d3 100644
--- a/third_party/WebIDL/tests/test_interface.py
+++ b/third_party/WebIDL/tests/test_interface.py
@@ -70,7 +70,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow cycles in interface inheritance chains")
@@ -86,7 +86,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -103,7 +103,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -223,7 +223,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow two non-partial interfaces with the same name")
@@ -241,7 +241,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Must have a non-partial interface for a given name")
@@ -259,7 +259,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -281,7 +281,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should not allow a name collision between interface " "and other object"
@@ -299,7 +299,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -319,7 +319,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -351,14 +351,14 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow unknown extended attributes on interfaces")
parser = parser.reset()
parser.parse(
"""
- [Global, Exposed=Window] interface Window {};
+ [Global=Window, Exposed=Window] interface Window {};
[Exposed=Window, LegacyWindowAlias=A]
interface B {};
[Exposed=Window, LegacyWindowAlias=(C, D)]
@@ -383,7 +383,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [LegacyWindowAlias] with no value")
@@ -397,7 +397,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [LegacyWindowAlias] without Window exposure")
@@ -406,7 +406,7 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Window] interface Window {};
+ [Global=Window, Exposed=Window] interface Window {};
[Exposed=Window]
interface A {};
[Exposed=Window, LegacyWindowAlias=A]
@@ -414,7 +414,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should not allow [LegacyWindowAlias] to conflict with other identifiers"
@@ -425,7 +425,7 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Window] interface Window {};
+ [Global=Window, Exposed=Window] interface Window {};
[Exposed=Window, LegacyWindowAlias=A]
interface B {};
[Exposed=Window]
@@ -433,7 +433,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should not allow [LegacyWindowAlias] to conflict with other identifiers"
@@ -444,7 +444,7 @@ def WebIDLTest(parser, harness):
try:
parser.parse(
"""
- [Global, Exposed=Window] interface Window {};
+ [Global=Window, Exposed=Window] interface Window {};
[Exposed=Window, LegacyWindowAlias=A]
interface B {};
[Exposed=Window, LegacyWindowAlias=A]
@@ -452,7 +452,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should not allow [LegacyWindowAlias] to conflict with other identifiers"
diff --git a/third_party/WebIDL/tests/test_interface_const_identifier_conflicts.py b/third_party/WebIDL/tests/test_interface_const_identifier_conflicts.py
index 5750f87a6fc..84f9eeb1f45 100644
--- a/third_party/WebIDL/tests/test_interface_const_identifier_conflicts.py
+++ b/third_party/WebIDL/tests/test_interface_const_identifier_conflicts.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -10,8 +13,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_interface_identifier_conflicts_across_members.py b/third_party/WebIDL/tests/test_interface_identifier_conflicts_across_members.py
index c1a544ce718..32c0b24704f 100644
--- a/third_party/WebIDL/tests/test_interface_identifier_conflicts_across_members.py
+++ b/third_party/WebIDL/tests/test_interface_identifier_conflicts_across_members.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -10,12 +13,13 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
- harness.ok(threw, "Should have thrown.")
+ harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers1.")
+ parser = parser.reset()
threw = False
try:
parser.parse(
@@ -27,12 +31,13 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
- harness.ok(threw, "Should have thrown.")
+ harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers2.")
+ parser = parser.reset()
threw = False
try:
parser.parse(
@@ -44,25 +49,123 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
- harness.ok(threw, "Should have thrown.")
+ harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers3.")
+ parser = parser.reset()
threw = False
try:
parser.parse(
"""
- interface IdentifierConflictAcrossMembers1 {
+ interface IdentifierConflictAcrossMembers4 {
const byte thing1 = 1;
long thing1();
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+
+ harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers4.")
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse(
+ """
+ interface IdentifierConflictAcrossMembers5 {
+ static long thing1();
+ undefined thing1();
+ };
+ """
+ )
+
+ parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+
+ harness.ok(
+ not threw, "Should not have thrown for IdentifierConflictAcrossMembers5."
+ )
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse(
+ """
+ interface mixin IdentifierConflictAcrossMembers6Mixin {
+ undefined thing1();
+ };
+ interface IdentifierConflictAcrossMembers6 {
+ static long thing1();
+ };
+ IdentifierConflictAcrossMembers6 includes IdentifierConflictAcrossMembers6Mixin;
+ """
+ )
+
+ parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+
+ harness.ok(
+ not threw, "Should not have thrown for IdentifierConflictAcrossMembers6."
+ )
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse(
+ """
+ interface IdentifierConflictAcrossMembers7 {
+ const byte thing1 = 1;
+ static readonly attribute long thing1;
+ };
+ """
+ )
+
+ parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+
+ harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers7.")
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse(
+ """
+ interface IdentifierConflictAcrossMembers8 {
+ readonly attribute long thing1 = 1;
+ static readonly attribute long thing1;
+ };
+ """
+ )
+
+ parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+
+ harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers8.")
+
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse(
+ """
+ interface IdentifierConflictAcrossMembers9 {
+ void thing1();
+ static readonly attribute long thing1;
+ };
+ """
+ )
+
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
- harness.ok(threw, "Should have thrown.")
+ harness.ok(threw, "Should have thrown for IdentifierConflictAcrossMembers9.")
diff --git a/third_party/WebIDL/tests/test_interface_maplikesetlikeiterable.py b/third_party/WebIDL/tests/test_interface_maplikesetlikeiterable.py
index 18c6023dd3b..fdd9c009653 100644
--- a/third_party/WebIDL/tests/test_interface_maplikesetlikeiterable.py
+++ b/third_party/WebIDL/tests/test_interface_maplikesetlikeiterable.py
@@ -1,5 +1,4 @@
import WebIDL
-import traceback
def WebIDLTest(parser, harness):
@@ -20,7 +19,10 @@ def WebIDLTest(parser, harness):
expectedMembers = list(expectedMembers)
for m in results[0].members:
name = m.identifier.name
- if (name, type(m)) in expectedMembers:
+ if m.isMethod() and m.isStatic():
+ # None of the expected members are static methods, so ignore those.
+ harness.ok(True, "%s - %s - Should be a %s" % (prefix, name, type(m)))
+ elif (name, type(m)) in expectedMembers:
harness.ok(True, "%s - %s - Should be a %s" % (prefix, name, type(m)))
expectedMembers.remove((name, type(m)))
else:
@@ -45,7 +47,7 @@ def WebIDLTest(parser, harness):
p.parse(iface)
p.finish()
harness.ok(False, prefix + " - Interface passed when should've failed")
- except WebIDL.WebIDLError as e:
+ except WebIDL.WebIDLError:
harness.ok(True, prefix + " - Interface failed as expected")
except Exception as e:
harness.ok(
@@ -66,12 +68,6 @@ def WebIDLTest(parser, harness):
setRWMembers = [
(x, WebIDL.IDLMethod) for x in ["add", "clear", "delete"]
] + setROMembers
- setROChromeMembers = [
- (x, WebIDL.IDLMethod) for x in ["__add", "__clear", "__delete"]
- ] + setROMembers
- setRWChromeMembers = [
- (x, WebIDL.IDLMethod) for x in ["__add", "__clear", "__delete"]
- ] + setRWMembers
mapROMembers = (
[(x, WebIDL.IDLMethod) for x in ["get", "has"]]
+ [("__maplike", WebIDL.IDLMaplikeOrSetlike)]
@@ -81,9 +77,6 @@ def WebIDLTest(parser, harness):
mapRWMembers = [
(x, WebIDL.IDLMethod) for x in ["set", "clear", "delete"]
] + mapROMembers
- mapRWChromeMembers = [
- (x, WebIDL.IDLMethod) for x in ["__set", "__clear", "__delete"]
- ] + mapRWMembers
# OK, now that we've used iterableMembers to set up the above, append
# __iterable to it for the iterable<> case.
@@ -101,12 +94,23 @@ def WebIDLTest(parser, harness):
valueAsyncIterableMembers = [("__iterable", WebIDL.IDLAsyncIterable)]
valueAsyncIterableMembers.append(("values", WebIDL.IDLMethod))
- disallowedIterableNames = ["keys", "entries", "values"]
- disallowedMemberNames = ["forEach", "has", "size"] + disallowedIterableNames
- mapDisallowedMemberNames = ["get"] + disallowedMemberNames
- disallowedNonMethodNames = ["clear", "delete"]
- mapDisallowedNonMethodNames = ["set"] + disallowedNonMethodNames
- setDisallowedNonMethodNames = ["add"] + disallowedNonMethodNames
+ disallowedIterableNames = [
+ ("keys", WebIDL.IDLMethod),
+ ("entries", WebIDL.IDLMethod),
+ ("values", WebIDL.IDLMethod),
+ ]
+ disallowedMemberNames = [
+ ("forEach", WebIDL.IDLMethod),
+ ("has", WebIDL.IDLMethod),
+ ("size", WebIDL.IDLAttribute),
+ ] + disallowedIterableNames
+ mapDisallowedMemberNames = [("get", WebIDL.IDLMethod)] + disallowedMemberNames
+ disallowedNonMethodNames = [
+ ("clear", WebIDL.IDLMethod),
+ ("delete", WebIDL.IDLMethod),
+ ]
+ mapDisallowedNonMethodNames = [("set", WebIDL.IDLMethod)] + disallowedNonMethodNames
+ setDisallowedNonMethodNames = [("add", WebIDL.IDLMethod)] + disallowedNonMethodNames
unrelatedMembers = [
("unrelatedAttribute", WebIDL.IDLAttribute),
("unrelatedMethod", WebIDL.IDLMethod),
@@ -570,7 +574,9 @@ def WebIDLTest(parser, harness):
# Member name collision tests
#
- def testConflictingMembers(likeMember, conflictName, expectedMembers, methodPasses):
+ def testConflictingMembers(
+ likeMember, conflict, expectedMembers, methodPasses, numProductions=1
+ ):
"""
Tests for maplike/setlike member generation against conflicting member
names. If methodPasses is True, this means we expect the interface to
@@ -578,6 +584,7 @@ def WebIDLTest(parser, harness):
list of interface members to check against on the passing interface.
"""
+ (conflictName, conflictType) = conflict
if methodPasses:
shouldPass(
"Conflicting method: %s and %s" % (likeMember, conflictName),
@@ -616,16 +623,30 @@ def WebIDLTest(parser, harness):
"""
% (conflictName, likeMember),
)
- shouldFail(
- "Conflicting static method: %s and %s" % (likeMember, conflictName),
- """
- interface Foo1 {
- %s;
- static undefined %s(long test1, double test2, double test3);
- };
- """
- % (likeMember, conflictName),
- )
+ if conflictType == WebIDL.IDLAttribute:
+ shouldFail(
+ "Conflicting static method: %s and %s" % (likeMember, conflictName),
+ """
+ interface Foo1 {
+ %s;
+ static undefined %s(long test1, double test2, double test3);
+ };
+ """
+ % (likeMember, conflictName),
+ )
+ else:
+ shouldPass(
+ "Conflicting static method: %s and %s" % (likeMember, conflictName),
+ """
+ interface Foo1 {
+ %s;
+ static undefined %s(long test1, double test2, double test3);
+ };
+ """
+ % (likeMember, conflictName),
+ expectedMembers,
+ numProductions=numProductions,
+ )
shouldFail(
"Conflicting attribute: %s and %s" % (likeMember, conflictName),
"""
@@ -658,7 +679,9 @@ def WebIDLTest(parser, harness):
)
for member in disallowedIterableNames:
- testConflictingMembers("iterable<long, long>", member, iterableMembers, False)
+ testConflictingMembers(
+ "iterable<long, long>", member, iterableMembers, False, numProductions=2
+ )
for member in mapDisallowedMemberNames:
testConflictingMembers("maplike<long, long>", member, mapRWMembers, False)
for member in disallowedMemberNames:
diff --git a/third_party/WebIDL/tests/test_interfacemixin.py b/third_party/WebIDL/tests/test_interfacemixin.py
index b3c8573fa59..297cc109150 100644
--- a/third_party/WebIDL/tests/test_interfacemixin.py
+++ b/third_party/WebIDL/tests/test_interfacemixin.py
@@ -155,7 +155,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should not allow two non-partial interface mixins with the same name"
@@ -175,7 +175,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Must have a non-partial interface mixin for a given name")
@@ -193,7 +193,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -215,7 +215,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -234,7 +234,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -254,7 +254,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should not allow unknown extended attributes on interface mixins"
@@ -271,7 +271,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow getters on interface mixins")
@@ -286,7 +286,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow setters on interface mixins")
@@ -301,7 +301,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow deleters on interface mixins")
@@ -316,7 +316,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow legacycallers on interface mixins")
@@ -331,7 +331,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow inherited attribute on interface mixins")
@@ -348,7 +348,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should fail if the right side does not point an interface mixin")
@@ -365,7 +365,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should fail if the left side does not point an interface")
@@ -380,7 +380,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should fail if an interface mixin includes iterable")
@@ -395,7 +395,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should fail if an interface mixin includes setlike")
@@ -410,7 +410,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should fail if an interface mixin includes maplike")
@@ -429,7 +429,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should fail if the included mixin interface has duplicated member"
@@ -452,7 +452,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should fail if the included mixin interfaces have duplicated member"
@@ -461,8 +461,8 @@ def WebIDLTest(parser, harness):
parser = parser.reset()
parser.parse(
"""
- [Global, Exposed=Window] interface Window {};
- [Global, Exposed=Worker] interface Worker {};
+ [Global=Window, Exposed=Window] interface Window {};
+ [Global=Worker, Exposed=Worker] interface Worker {};
[Exposed=Window]
interface Base {};
interface mixin Mixin {
@@ -483,8 +483,8 @@ def WebIDLTest(parser, harness):
parser = parser.reset()
parser.parse(
"""
- [Global, Exposed=Window] interface Window {};
- [Global, Exposed=Worker] interface Worker {};
+ [Global=Window, Exposed=Window] interface Window {};
+ [Global=Worker, Exposed=Worker] interface Worker {};
[Exposed=Window]
interface Base {};
[Exposed=Window]
@@ -504,8 +504,8 @@ def WebIDLTest(parser, harness):
parser = parser.reset()
parser.parse(
"""
- [Global, Exposed=Window] interface Window {};
- [Global, Exposed=Worker] interface Worker {};
+ [Global=Window, Exposed=Window] interface Window {};
+ [Global=Worker, Exposed=Worker] interface Worker {};
[Exposed=Window]
interface Base1 {};
[Exposed=Worker]
diff --git a/third_party/WebIDL/tests/test_legacyTreatNonObjectAsNull.py b/third_party/WebIDL/tests/test_legacyTreatNonObjectAsNull.py
new file mode 100644
index 00000000000..380ccdc4e72
--- /dev/null
+++ b/third_party/WebIDL/tests/test_legacyTreatNonObjectAsNull.py
@@ -0,0 +1,11 @@
+def WebIDLTest(parser, harness):
+ parser.parse(
+ """
+ [LegacyTreatNonObjectAsNull] callback Function = any(any... arguments);
+ """
+ )
+
+ results = parser.finish()
+
+ callback = results[0]
+ harness.check(callback._treatNonObjectAsNull, True, "Got the expected value")
diff --git a/third_party/WebIDL/tests/test_lenientSetter.py b/third_party/WebIDL/tests/test_lenientSetter.py
index 9d2230c3bec..9059255594f 100644
--- a/third_party/WebIDL/tests/test_lenientSetter.py
+++ b/third_party/WebIDL/tests/test_lenientSetter.py
@@ -2,6 +2,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import WebIDL
+
def should_throw(parser, harness, message, code):
parser = parser.reset()
@@ -9,7 +11,7 @@ def should_throw(parser, harness, message, code):
try:
parser.parse(code)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown: %s" % message)
diff --git a/third_party/WebIDL/tests/test_method.py b/third_party/WebIDL/tests/test_method.py
index 0ddfada28ac..80eb0043728 100644
--- a/third_party/WebIDL/tests/test_method.py
+++ b/third_party/WebIDL/tests/test_method.py
@@ -90,7 +90,7 @@ def WebIDLTest(parser, harness):
)
sigpairs = zip(method.signatures(), signatures)
- for (gotSignature, expectedSignature) in sigpairs:
+ for gotSignature, expectedSignature in sigpairs:
(gotRetType, gotArgs) = gotSignature
(expectedRetType, expectedArgs) = expectedSignature
@@ -267,7 +267,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should allow integer to float type corecion")
@@ -282,7 +282,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [GetterThrows] on methods")
@@ -297,7 +297,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [SetterThrows] on methods")
@@ -312,7 +312,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should spell [Throws] correctly on methods")
@@ -327,7 +327,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow __noSuchMethod__ methods")
@@ -345,7 +345,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should allow LenientFloat to be only in a specific overload")
@@ -383,7 +383,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -404,7 +404,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -425,6 +425,6 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should prevent overloads from getting redundant [LenientFloat]")
diff --git a/third_party/WebIDL/tests/test_namespace.py b/third_party/WebIDL/tests/test_namespace.py
index 247c5b22232..5812364dddc 100644
--- a/third_party/WebIDL/tests/test_namespace.py
+++ b/third_party/WebIDL/tests/test_namespace.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
parser.parse(
"""
@@ -71,7 +74,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -87,7 +90,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -107,7 +110,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -127,7 +130,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -147,7 +150,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -167,7 +170,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -187,7 +190,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -207,7 +210,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -227,6 +230,6 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_newobject.py b/third_party/WebIDL/tests/test_newobject.py
index c12995a0e86..b30e9c58160 100644
--- a/third_party/WebIDL/tests/test_newobject.py
+++ b/third_party/WebIDL/tests/test_newobject.py
@@ -1,7 +1,7 @@
-# Import the WebIDL module, so we can do isinstance checks and whatnot
import WebIDL
+# Import the WebIDL module, so we can do isinstance checks and whatnot
def WebIDLTest(parser, harness):
# Basic functionality
parser.parse(
@@ -25,8 +25,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[NewObject] attributes must depend on something")
@@ -40,8 +40,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[NewObject] methods must depend on something")
@@ -55,8 +55,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[NewObject] attributes must not be [Cached]")
@@ -70,7 +70,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[NewObject] attributes must not be [StoreInSlot]")
diff --git a/third_party/WebIDL/tests/test_nullable_equivalency.py b/third_party/WebIDL/tests/test_nullable_equivalency.py
index 012c5fcff7c..5790288ccb9 100644
--- a/third_party/WebIDL/tests/test_nullable_equivalency.py
+++ b/third_party/WebIDL/tests/test_nullable_equivalency.py
@@ -105,13 +105,17 @@ def checkEquivalent(iface, harness):
if callable(a1):
try:
v1 = a1()
- except:
- # Can't call a1 with no args, so skip this attriute.
+ except AssertionError:
+ # Various methods assert that they're called on objects of
+ # the right type, skip them if the assert fails.
+ continue
+ except TypeError:
+ # a1 requires positional arguments, so skip this attribute.
continue
try:
a2 = getattr(type2, attr)
- except:
+ except WebIDL.WebIDLError:
harness.ok(
False,
"Missing %s attribute on type %s in %s" % (attr, type2, iface),
@@ -131,7 +135,7 @@ def checkEquivalent(iface, harness):
else:
try:
a2 = getattr(type2, attr)
- except:
+ except WebIDL.WebIDLError:
harness.ok(
False,
"Missing %s attribute on type %s in %s" % (attr, type2, iface),
diff --git a/third_party/WebIDL/tests/test_nullable_void.py b/third_party/WebIDL/tests/test_nullable_void.py
new file mode 100644
index 00000000000..f2a0177ced5
--- /dev/null
+++ b/third_party/WebIDL/tests/test_nullable_void.py
@@ -0,0 +1,19 @@
+import WebIDL
+
+
+def WebIDLTest(parser, harness):
+ threw = False
+ try:
+ parser.parse(
+ """
+ interface NullableVoid {
+ void? foo();
+ };
+ """
+ )
+
+ parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+
+ harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_observableArray.py b/third_party/WebIDL/tests/test_observableArray.py
index 601f626bcf4..7fe9511e074 100644
--- a/third_party/WebIDL/tests/test_observableArray.py
+++ b/third_party/WebIDL/tests/test_observableArray.py
@@ -4,7 +4,6 @@
def WebIDLTest(parser, harness):
-
# Test dictionary as inner type
harness.should_throw(
parser,
diff --git a/third_party/WebIDL/tests/test_optional_constraints.py b/third_party/WebIDL/tests/test_optional_constraints.py
index 2044c6362c3..34f03467621 100644
--- a/third_party/WebIDL/tests/test_optional_constraints.py
+++ b/third_party/WebIDL/tests/test_optional_constraints.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
diff --git a/third_party/WebIDL/tests/test_promise.py b/third_party/WebIDL/tests/test_promise.py
index 9b418d51afe..1dfb6d4643c 100644
--- a/third_party/WebIDL/tests/test_promise.py
+++ b/third_party/WebIDL/tests/test_promise.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -8,9 +11,9 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow Promise return values for legacycaller.")
@@ -25,8 +28,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -45,8 +48,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -64,8 +67,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow nullable Promise return values.")
@@ -79,8 +82,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow nullable Promise arguments.")
@@ -93,7 +96,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(
True, "Should allow overloads which only have Promise and return " "types."
@@ -109,8 +112,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow writable Promise-typed attributes.")
@@ -124,8 +127,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should not allow [LegacyLenientSetter] Promise-typed attributes."
@@ -141,8 +144,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [PutForwards] Promise-typed attributes.")
@@ -156,8 +159,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [Replaceable] Promise-typed attributes.")
@@ -171,7 +174,7 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow [SameObject] Promise-typed attributes.")
diff --git a/third_party/WebIDL/tests/test_prototype_ident.py b/third_party/WebIDL/tests/test_prototype_ident.py
index 5a806bf2a2d..5e4d3a20002 100644
--- a/third_party/WebIDL/tests/test_prototype_ident.py
+++ b/third_party/WebIDL/tests/test_prototype_ident.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -8,8 +11,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "The identifier of a static attribute must not be 'prototype'")
@@ -24,8 +27,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "The identifier of a static operation must not be 'prototype'")
@@ -40,8 +43,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "The identifier of a constant must not be 'prototype'")
diff --git a/third_party/WebIDL/tests/test_putForwards.py b/third_party/WebIDL/tests/test_putForwards.py
index 5ec4dde280e..e32e6c14f74 100644
--- a/third_party/WebIDL/tests/test_putForwards.py
+++ b/third_party/WebIDL/tests/test_putForwards.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -28,8 +31,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -48,8 +51,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -68,8 +71,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -88,8 +91,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -112,8 +115,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_record.py b/third_party/WebIDL/tests/test_record.py
index 3a31d721b27..bee5c83953d 100644
--- a/third_party/WebIDL/tests/test_record.py
+++ b/third_party/WebIDL/tests/test_record.py
@@ -38,7 +38,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should have thrown because record can't have undefined as value type."
@@ -56,6 +56,6 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown on dictionary containing itself via record.")
diff --git a/third_party/WebIDL/tests/test_replaceable.py b/third_party/WebIDL/tests/test_replaceable.py
index 06ea6a47239..3b0a6fea360 100644
--- a/third_party/WebIDL/tests/test_replaceable.py
+++ b/third_party/WebIDL/tests/test_replaceable.py
@@ -2,6 +2,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import WebIDL
+
def should_throw(parser, harness, message, code):
parser = parser.reset()
@@ -9,7 +11,7 @@ def should_throw(parser, harness, message, code):
try:
parser.parse(code)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown: %s" % message)
diff --git a/third_party/WebIDL/tests/test_securecontext_extended_attribute.py b/third_party/WebIDL/tests/test_securecontext_extended_attribute.py
index e0e967dd420..4dd0811ed76 100644
--- a/third_party/WebIDL/tests/test_securecontext_extended_attribute.py
+++ b/third_party/WebIDL/tests/test_securecontext_extended_attribute.py
@@ -41,11 +41,17 @@ def WebIDLTest(parser, harness):
)
harness.ok(
results[0].members[3].getExtendedAttribute("SecureContext"),
- "[SecureContext] should propagate from interface to constant members from partial interface",
+ (
+ "[SecureContext] should propagate from interface to "
+ "constant members from partial interface"
+ ),
)
harness.ok(
results[0].members[4].getExtendedAttribute("SecureContext"),
- "[SecureContext] should propagate from interface to attribute members from partial interface",
+ (
+ "[SecureContext] should propagate from interface to "
+ "attribute members from partial interface"
+ ),
)
harness.ok(
results[0].members[5].getExtendedAttribute("SecureContext"),
@@ -93,15 +99,24 @@ def WebIDLTest(parser, harness):
)
harness.ok(
results[1].members[3].getExtendedAttribute("SecureContext"),
- "[SecureContext] should propagate from interface to constant members from partial interface",
+ (
+ "[SecureContext] should propagate from interface to constant members from "
+ "partial interface"
+ ),
)
harness.ok(
results[1].members[4].getExtendedAttribute("SecureContext"),
- "[SecureContext] should propagate from interface to attribute members from partial interface",
+ (
+ "[SecureContext] should propagate from interface to attribute members from "
+ "partial interface"
+ ),
)
harness.ok(
results[1].members[5].getExtendedAttribute("SecureContext"),
- "[SecureContext] should propagate from interface to method members from partial interface",
+ (
+ "[SecureContext] should propagate from interface to method members from partial "
+ "interface"
+ ),
)
parser = parser.reset()
@@ -132,15 +147,24 @@ def WebIDLTest(parser, harness):
)
harness.ok(
results[0].members[0].getExtendedAttribute("SecureContext") is None,
- "[SecureContext] should not propagate from a partial interface to the interface's constant members",
+ (
+ "[SecureContext] should not propagate from a partial interface to the interface's "
+ "constant members"
+ ),
)
harness.ok(
results[0].members[1].getExtendedAttribute("SecureContext") is None,
- "[SecureContext] should not propagate from a partial interface to the interface's attribute members",
+ (
+ "[SecureContext] should not propagate from a partial interface to the interface's "
+ "attribute members"
+ ),
)
harness.ok(
results[0].members[2].getExtendedAttribute("SecureContext") is None,
- "[SecureContext] should not propagate from a partial interface to the interface's method members",
+ (
+ "[SecureContext] should not propagate from a partial interface to the interface's "
+ "method members"
+ ),
)
harness.ok(
results[0].members[3].getExtendedAttribute("SecureContext"),
@@ -297,7 +321,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "[SecureContext] must take no arguments (testing on interface)")
@@ -316,11 +340,14 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
- "If [SecureContext] appears on an overloaded operation, then it MUST appear on all overloads",
+ (
+ "If [SecureContext] appears on an overloaded operation, then it MUST appear on all "
+ "overloads"
+ ),
)
parser = parser.reset()
@@ -339,7 +366,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
not threw,
@@ -359,7 +386,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "[SecureContext] must not appear on an interface and interface member"
@@ -380,11 +407,14 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
- "[SecureContext] must not appear on a partial interface and one of the partial interface's member's",
+ (
+ "[SecureContext] must not appear on a partial interface and one of the partial "
+ "interface's member's"
+ ),
)
parser = parser.reset()
@@ -402,11 +432,14 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
- "[SecureContext] must not appear on an interface and one of its partial interface's member's",
+ (
+ "[SecureContext] must not appear on an interface and one of its partial interface's "
+ "member's"
+ ),
)
parser = parser.reset()
@@ -423,11 +456,14 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
- "[SecureContext] must appear on interfaces that inherit from another [SecureContext] interface",
+ (
+ "[SecureContext] must appear on interfaces that inherit from another [SecureContext] "
+ "interface"
+ ),
)
# Test 'includes'.
@@ -450,7 +486,10 @@ def WebIDLTest(parser, harness):
harness.check(
len(results[0].members),
4,
- "TestSecureContextInterfaceThatImplementsNonSecureContextInterface should have four members",
+ (
+ "TestSecureContextInterfaceThatImplementsNonSecureContextInterface should have four "
+ "members"
+ ),
)
harness.ok(
results[0].getExtendedAttribute("SecureContext"),
@@ -458,7 +497,10 @@ def WebIDLTest(parser, harness):
)
harness.ok(
results[0].members[0].getExtendedAttribute("SecureContext"),
- "[SecureContext] should propagate from interface to constant members even when other members are copied from a non-[SecureContext] interface",
+ (
+ "[SecureContext] should propagate from interface to constant members even when other "
+ "members are copied from a non-[SecureContext] interface"
+ ),
)
harness.ok(
results[0].members[1].getExtendedAttribute("SecureContext") is None,
diff --git a/third_party/WebIDL/tests/test_special_method_signature_mismatch.py b/third_party/WebIDL/tests/test_special_method_signature_mismatch.py
index a11860b3728..5dd581985bd 100644
--- a/third_party/WebIDL/tests/test_special_method_signature_mismatch.py
+++ b/third_party/WebIDL/tests/test_special_method_signature_mismatch.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -25,8 +28,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -41,8 +44,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -57,8 +60,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -73,8 +76,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -89,8 +92,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -105,8 +108,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -121,8 +124,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -137,8 +140,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -153,8 +156,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -169,8 +172,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -185,8 +188,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -201,8 +204,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -217,8 +220,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -233,8 +236,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -249,8 +252,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_special_methods.py b/third_party/WebIDL/tests/test_special_methods.py
index 9601a0a968f..911bb8ec0da 100644
--- a/third_party/WebIDL/tests/test_special_methods.py
+++ b/third_party/WebIDL/tests/test_special_methods.py
@@ -111,7 +111,7 @@ def WebIDLTest(parser, harness):
"""
)
parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "There are no indexed deleters")
diff --git a/third_party/WebIDL/tests/test_special_methods_uniqueness.py b/third_party/WebIDL/tests/test_special_methods_uniqueness.py
index 014737e8168..948c6392040 100644
--- a/third_party/WebIDL/tests/test_special_methods_uniqueness.py
+++ b/third_party/WebIDL/tests/test_special_methods_uniqueness.py
@@ -13,8 +13,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -30,8 +30,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -47,8 +47,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_stringifier.py b/third_party/WebIDL/tests/test_stringifier.py
index 948be71e4dd..c2052c44e57 100644
--- a/third_party/WebIDL/tests/test_stringifier.py
+++ b/third_party/WebIDL/tests/test_stringifier.py
@@ -30,7 +30,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow two 'stringifier;'")
@@ -48,7 +48,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow a 'stringifier;' and a 'stringifier()'")
@@ -156,7 +156,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow ByteString")
@@ -173,7 +173,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow a 'stringifier;' and a stringifier attribute")
@@ -190,7 +190,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow multiple stringifier attributes")
diff --git a/third_party/WebIDL/tests/test_toJSON.py b/third_party/WebIDL/tests/test_toJSON.py
index f312667ec4d..ec81080beca 100644
--- a/third_party/WebIDL/tests/test_toJSON.py
+++ b/third_party/WebIDL/tests/test_toJSON.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -8,8 +11,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should allow a toJSON method.")
@@ -24,8 +27,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow overloads of a toJSON method.")
@@ -39,8 +42,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should not allow a toJSON method with arguments.")
@@ -54,8 +57,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(not threw, "Should allow a toJSON method with 'long' as return type.")
@@ -69,8 +72,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
not threw, "Should allow a default toJSON method with 'object' as return type."
@@ -86,8 +89,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
diff --git a/third_party/WebIDL/tests/test_treatNonCallableAsNull.py b/third_party/WebIDL/tests/test_treatNonCallableAsNull.py
index 7becfdca1f3..8ad7f942b12 100644
--- a/third_party/WebIDL/tests/test_treatNonCallableAsNull.py
+++ b/third_party/WebIDL/tests/test_treatNonCallableAsNull.py
@@ -36,7 +36,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -57,7 +57,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -74,7 +74,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_typedef.py b/third_party/WebIDL/tests/test_typedef.py
index c19d064efff..58c17135de9 100644
--- a/third_party/WebIDL/tests/test_typedef.py
+++ b/third_party/WebIDL/tests/test_typedef.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
parser.parse(
"""
@@ -32,7 +35,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown on nullable inside nullable arg.")
@@ -49,7 +52,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown on nullable inside nullable const.")
@@ -66,7 +69,7 @@ def WebIDLTest(parser, harness):
"""
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
diff --git a/third_party/WebIDL/tests/test_typedef_identifier_conflict.py b/third_party/WebIDL/tests/test_typedef_identifier_conflict.py
index 2aab3a8a91f..90e45ddb7df 100644
--- a/third_party/WebIDL/tests/test_typedef_identifier_conflict.py
+++ b/third_party/WebIDL/tests/test_typedef_identifier_conflict.py
@@ -8,7 +8,7 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
+ parser.finish()
except Exception as e:
exception = e
diff --git a/third_party/WebIDL/tests/test_undefined.py b/third_party/WebIDL/tests/test_undefined.py
index 4731ee1bcd7..34d1ac824ec 100644
--- a/third_party/WebIDL/tests/test_undefined.py
+++ b/third_party/WebIDL/tests/test_undefined.py
@@ -11,8 +11,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "undefined must not be used as the type of a dictionary member")
@@ -28,8 +28,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -49,8 +49,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -70,8 +70,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -91,8 +91,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -112,8 +112,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -133,8 +133,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -152,8 +152,8 @@ def WebIDLTest(parser, harness):
callback Callback = undefined (undefined foo);
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -173,8 +173,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -195,8 +195,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -216,8 +216,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -236,8 +236,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
diff --git a/third_party/WebIDL/tests/test_unenumerable_own_properties.py b/third_party/WebIDL/tests/test_unenumerable_own_properties.py
index b024d317492..f465598efd5 100644
--- a/third_party/WebIDL/tests/test_unenumerable_own_properties.py
+++ b/third_party/WebIDL/tests/test_unenumerable_own_properties.py
@@ -1,5 +1,7 @@
-def WebIDLTest(parser, harness):
+import WebIDL
+
+def WebIDLTest(parser, harness):
parser.parse(
"""
interface Foo {};
@@ -27,7 +29,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -44,7 +46,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
@@ -66,6 +68,6 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_unforgeable.py b/third_party/WebIDL/tests/test_unforgeable.py
index 500d123ddb2..0f7d52349a5 100644
--- a/third_party/WebIDL/tests/test_unforgeable.py
+++ b/third_party/WebIDL/tests/test_unforgeable.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
parser.parse(
"""
@@ -95,7 +98,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -118,7 +121,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -141,7 +144,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -164,7 +167,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except Exception as x:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
threw,
@@ -210,7 +213,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -240,7 +243,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -270,7 +273,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -305,7 +308,7 @@ def WebIDLTest(parser, harness):
)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for static [LegacyUnforgeable] attribute.")
diff --git a/third_party/WebIDL/tests/test_union.py b/third_party/WebIDL/tests/test_union.py
index 7fc1236d54e..71791207bab 100644
--- a/third_party/WebIDL/tests/test_union.py
+++ b/third_party/WebIDL/tests/test_union.py
@@ -1,7 +1,7 @@
-import WebIDL
-import itertools
import string
+import WebIDL
+
# We'd like to use itertools.chain but it's 2.6 or higher.
@@ -91,7 +91,7 @@ def WebIDLTest(parser, harness):
interface PrepareForTest {
"""
)
- for (i, type) in enumerate(types):
+ for i, type in enumerate(types):
interface += string.Template(
"""
readonly attribute ${type} attr${i};
@@ -157,7 +157,7 @@ def WebIDLTest(parser, harness):
interface TestUnion {
"""
)
- for (i, type) in enumerate(validUnionTypes):
+ for i, type in enumerate(validUnionTypes):
interface += string.Template(
"""
undefined method${i}(${type} arg);
@@ -190,7 +190,7 @@ def WebIDLTest(parser, harness):
try:
parser.parse(interface)
results = parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_union_any.py b/third_party/WebIDL/tests/test_union_any.py
index caba44b55f9..7bde16a622a 100644
--- a/third_party/WebIDL/tests/test_union_any.py
+++ b/third_party/WebIDL/tests/test_union_any.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown.")
diff --git a/third_party/WebIDL/tests/test_union_callback_dict.py b/third_party/WebIDL/tests/test_union_callback_dict.py
new file mode 100644
index 00000000000..3e87e16ad47
--- /dev/null
+++ b/third_party/WebIDL/tests/test_union_callback_dict.py
@@ -0,0 +1,132 @@
+import WebIDL
+
+
+def WebIDLTest(parser, harness):
+ parser = parser.reset()
+ threw = False
+ try:
+ parser.parse(
+ """
+ dictionary TestDict {
+ DOMString member;
+ };
+ [LegacyTreatNonObjectAsNull] callback TestCallback = undefined ();
+ typedef (TestCallback or TestDict) TestUnionCallbackDict;
+ """
+ )
+ results = parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+ harness.ok(
+ threw,
+ "Should not allow Dict/Callback union where callback is [LegacyTreatNonObjectAsNull]",
+ )
+
+ parser = parser.reset()
+
+ threw = False
+ try:
+ parser.parse(
+ """
+ dictionary TestDict {
+ DOMString member;
+ };
+ [LegacyTreatNonObjectAsNull] callback TestCallback = undefined ();
+ typedef (TestDict or TestCallback) TestUnionCallbackDict;
+ """
+ )
+ results = parser.finish()
+ except WebIDL.WebIDLError:
+ threw = True
+ harness.ok(
+ threw,
+ "Should not allow Dict/Callback union where callback is [LegacyTreatNonObjectAsNull]",
+ )
+
+ parser = parser.reset()
+
+ parser.parse(
+ """
+ dictionary TestDict {
+ DOMString member;
+ };
+ callback TestCallback = undefined ();
+ typedef (TestCallback or TestDict) TestUnionCallbackDict;
+ """
+ )
+ results = parser.finish()
+
+ harness.ok(True, "TestUnionCallbackDict interface parsed without error")
+ harness.check(len(results), 3, "Document should have 3 types")
+
+ myDict = results[0]
+ harness.ok(isinstance(myDict, WebIDL.IDLDictionary), "Expect an IDLDictionary")
+
+ myCallback = results[1]
+ harness.ok(isinstance(myCallback, WebIDL.IDLCallback), "Expect an IDLCallback")
+
+ myUnion = results[2]
+ harness.ok(isinstance(myUnion, WebIDL.IDLTypedef), "Expect a IDLTypedef")
+ harness.ok(
+ isinstance(myUnion.innerType, WebIDL.IDLUnionType), "Expect a IDLUnionType"
+ )
+ harness.ok(
+ isinstance(myUnion.innerType.memberTypes[0], WebIDL.IDLCallbackType),
+ "Expect a IDLCallbackType",
+ )
+ harness.ok(
+ isinstance(myUnion.innerType.memberTypes[1], WebIDL.IDLWrapperType),
+ "Expect a IDLDictionary",
+ )
+ harness.ok(
+ (myUnion.innerType.memberTypes[0].callback == myCallback),
+ "Expect left Union member to be MyCallback",
+ )
+ harness.ok(
+ (myUnion.innerType.memberTypes[1].inner == myDict),
+ "Expect right Union member to be MyDict",
+ )
+
+ parser = parser.reset()
+
+ parser.parse(
+ """
+ dictionary TestDict {
+ DOMString member;
+ };
+ callback TestCallback = undefined ();
+ typedef (TestDict or TestCallback) TestUnionCallbackDict;
+ """
+ )
+ results = parser.finish()
+
+ harness.ok(True, "TestUnionCallbackDict interface parsed without error")
+ harness.check(len(results), 3, "Document should have 3 types")
+
+ myDict = results[0]
+ harness.ok(isinstance(myDict, WebIDL.IDLDictionary), "Expect an IDLDictionary")
+
+ myCallback = results[1]
+ harness.ok(isinstance(myCallback, WebIDL.IDLCallback), "Expect an IDLCallback")
+
+ myUnion = results[2]
+ harness.ok(isinstance(myUnion, WebIDL.IDLTypedef), "Expect a IDLTypedef")
+ harness.ok(
+ isinstance(myUnion.innerType, WebIDL.IDLUnionType), "Expect a IDLUnionType"
+ )
+ harness.ok(
+ isinstance(myUnion.innerType.memberTypes[0], WebIDL.IDLWrapperType),
+ "Expect a IDLDictionary",
+ )
+ harness.ok(
+ isinstance(myUnion.innerType.memberTypes[1], WebIDL.IDLCallbackType),
+ "Expect a IDLCallbackType",
+ )
+ harness.ok(
+ (myUnion.innerType.memberTypes[0].inner == myDict),
+ "Expect right Union member to be MyDict",
+ )
+ harness.ok(
+ (myUnion.innerType.memberTypes[1].callback == myCallback),
+ "Expect left Union member to be MyCallback",
+ )
diff --git a/third_party/WebIDL/tests/test_union_nullable.py b/third_party/WebIDL/tests/test_union_nullable.py
index d15ed4cfb54..d5ae2e1e74c 100644
--- a/third_party/WebIDL/tests/test_union_nullable.py
+++ b/third_party/WebIDL/tests/test_union_nullable.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -9,8 +12,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Two nullable member types of a union should have thrown.")
@@ -27,8 +30,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -50,8 +53,8 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
diff --git a/third_party/WebIDL/tests/test_variadic_callback.py b/third_party/WebIDL/tests/test_variadic_callback.py
index 3fd3dccd37a..fab1c7ef109 100644
--- a/third_party/WebIDL/tests/test_variadic_callback.py
+++ b/third_party/WebIDL/tests/test_variadic_callback.py
@@ -1,6 +1,3 @@
-import WebIDL
-
-
def WebIDLTest(parser, harness):
parser.parse(
"""
@@ -8,6 +5,6 @@ def WebIDLTest(parser, harness):
"""
)
- results = parser.finish()
+ parser.finish()
harness.ok(True, "TestVariadicCallback callback parsed without error.")
diff --git a/third_party/WebIDL/tests/test_variadic_constraints.py b/third_party/WebIDL/tests/test_variadic_constraints.py
index 06ce09d8236..749c4a7812a 100644
--- a/third_party/WebIDL/tests/test_variadic_constraints.py
+++ b/third_party/WebIDL/tests/test_variadic_constraints.py
@@ -1,3 +1,6 @@
+import WebIDL
+
+
def WebIDLTest(parser, harness):
threw = False
try:
@@ -8,9 +11,9 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -28,8 +31,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -47,9 +50,9 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
+ parser.finish()
- except:
+ except WebIDL.WebIDLError:
threw = True
harness.ok(
@@ -67,8 +70,8 @@ def WebIDLTest(parser, harness):
};
"""
)
- results = parser.finish()
- except:
+ parser.finish()
+ except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown on variadic argument with default value.")
diff --git a/third_party/WebIDL/update.sh b/third_party/WebIDL/update.sh
index e4d1c2d6d32..1572c3752aa 100755
--- a/third_party/WebIDL/update.sh
+++ b/third_party/WebIDL/update.sh
@@ -6,6 +6,7 @@ patch < union-typedef.patch
patch < inline.patch
patch < readable-stream.patch
patch < like-as-iterable.patch
+patch < builtin-array.patch
wget https://hg.mozilla.org/mozilla-central/archive/tip.zip/dom/bindings/parser/tests/ -O tests.zip
rm -r tests