Sync WebIDL.py with gecko

This commit is contained in:
Kagami Sascha Rosylight 2019-07-11 13:16:10 +09:00
parent 5fdc7c0d2c
commit 56f31c85ef
35 changed files with 727 additions and 221 deletions

View file

@ -133,7 +133,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should not allow [SetterThrows] on readonly attributes")
@ -146,7 +146,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should spell [Throws] correctly")
@ -159,7 +159,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should not allow [SameObject] on attributes not of interface type")
@ -172,6 +172,6 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(not threw, "Should allow [SameObject] on attributes of interface type")

View file

@ -32,3 +32,6 @@ def WebIDLTest(parser, harness):
harness.ok(not isinstance(t, WebIDL.IDLWrapperType), "Attr has the right type")
harness.ok(isinstance(t, WebIDL.IDLNullableType), "Attr has the right type")
harness.ok(t.isCallback(), "Attr has the right type")
callback = results[1]
harness.ok(not callback.isConstructor(), "callback is not constructor")

View file

@ -0,0 +1,63 @@
import WebIDL
def WebIDLTest(parser, harness):
parser.parse("""
interface TestCallbackConstructor {
attribute CallbackConstructorType? constructorAttribute;
};
callback constructor CallbackConstructorType = TestCallbackConstructor (unsigned long arg);
""")
results = parser.finish()
harness.ok(True, "TestCallbackConstructor interface parsed without error.")
harness.check(len(results), 2, "Should be two productions.")
iface = results[0]
harness.ok(isinstance(iface, WebIDL.IDLInterface),
"Should be an IDLInterface")
harness.check(iface.identifier.QName(), "::TestCallbackConstructor", "Interface has the right QName")
harness.check(iface.identifier.name, "TestCallbackConstructor", "Interface has the right name")
harness.check(len(iface.members), 1, "Expect %s members" % 1)
attr = iface.members[0]
harness.ok(isinstance(attr, WebIDL.IDLAttribute),
"Should be an IDLAttribute")
harness.ok(attr.isAttr(), "Should be an attribute")
harness.ok(not attr.isMethod(), "Attr is not an method")
harness.ok(not attr.isConst(), "Attr is not a const")
harness.check(attr.identifier.QName(), "::TestCallbackConstructor::constructorAttribute", "Attr has the right QName")
harness.check(attr.identifier.name, "constructorAttribute", "Attr has the right name")
t = attr.type
harness.ok(not isinstance(t, WebIDL.IDLWrapperType), "Attr has the right type")
harness.ok(isinstance(t, WebIDL.IDLNullableType), "Attr has the right type")
harness.ok(t.isCallback(), "Attr has the right type")
callback = results[1]
harness.ok(callback.isConstructor(), "Callback is constructor")
parser.reset()
threw = False
try:
parser.parse("""
[TreatNonObjectAsNull]
callback constructor CallbackConstructorType = object ();
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should throw on TreatNonObjectAsNull callback constructors")
parser.reset()
threw = False
try:
parser.parse("""
[MOZ_CAN_RUN_SCRIPT_BOUNDARY]
callback constructor CallbackConstructorType = object ();
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should not permit MOZ_CAN_RUN_SCRIPT_BOUNDARY callback constructors")

View file

@ -38,7 +38,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, e:
except Exception as e:
harness.ok(False, "Shouldn't have thrown for [CEReactions] used on writable attribute. %s" % e)
threw = True
@ -52,7 +52,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, e:
except Exception as e:
harness.ok(False, "Shouldn't have thrown for [CEReactions] used on regular operations. %s" % e)
threw = True

View file

@ -44,7 +44,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, exception:
except Exception as exception:
pass
harness.ok(exception, "Should have thrown.")
@ -70,7 +70,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, exception:
except Exception as exception:
pass
harness.ok(exception, "Should have thrown (2).")
@ -100,7 +100,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, exception:
except Exception as exception:
pass
harness.ok(exception, "Should have thrown (3).")

View file

@ -12,9 +12,6 @@ expected = [
("::TestConsts::ll", "ll", "LongLong", -8),
("::TestConsts::t", "t", "Boolean", True),
("::TestConsts::f", "f", "Boolean", False),
("::TestConsts::n", "n", "BooleanOrNull", None),
("::TestConsts::nt", "nt", "BooleanOrNull", True),
("::TestConsts::nf", "nf", "BooleanOrNull", False),
("::TestConsts::fl", "fl", "Float", 0.2),
("::TestConsts::db", "db", "Double", 0.2),
("::TestConsts::ufl", "ufl", "UnrestrictedFloat", 0.2),
@ -39,9 +36,6 @@ def WebIDLTest(parser, harness):
const long long ll = -010;
const boolean t = true;
const boolean f = false;
const boolean? n = null;
const boolean? nt = true;
const boolean? nf = false;
const float fl = 0.2;
const double db = 0.2;
const unrestricted float ufl = 0.2;
@ -78,3 +72,16 @@ def WebIDLTest(parser, harness):
"Const's value has the same type as the type")
harness.check(const.value.value, value, "Const value has the right value.")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface TestConsts {
const boolean? zero = 0;
};
""")
parser.finish()
except:
threw = True
harness.ok(threw, "Nullable types are not allowed for consts.")

View file

@ -0,0 +1,87 @@
def WebIDLTest(parser, harness):
threw = False
try:
parser.parse("""
[Constructor, Global]
interface TestConstructorGlobal {
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global, Constructor]
interface TestConstructorGlobal {
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global, NamedConstructor=FooBar]
interface TestNamedConstructorGlobal {
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""
[NamedConstructor=FooBar, Global]
interface TestNamedConstructorGlobal {
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global, HTMLConstructor]
interface TestHTMLConstructorGlobal {
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""
[HTMLConstructor, Global]
interface TestHTMLConstructorGlobal {
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Should have thrown.")

View file

@ -13,6 +13,7 @@ def WebIDLTest(parser, harness):
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""

View file

@ -167,6 +167,22 @@ def WebIDLTest(parser, harness):
harness.ok(threw, "Trailing dictionary arg must be optional")
parser = parser.reset()
threw = False
try:
parser.parse("""
dictionary A {
};
interface X {
void doFoo(optional A arg);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Trailing dictionary arg must have a default value")
parser = parser.reset()
threw = False
try:
@ -184,6 +200,23 @@ def WebIDLTest(parser, harness):
harness.ok(threw,
"Trailing union arg containing a dictionary must be optional")
parser = parser.reset()
threw = False
try:
parser.parse("""
dictionary A {
};
interface X {
void doFoo(optional (A or DOMString) arg);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Trailing union arg containing a dictionary must have a default value")
parser = parser.reset()
threw = False
try:
@ -200,6 +233,22 @@ def WebIDLTest(parser, harness):
harness.ok(threw, "Dictionary arg followed by optional arg must be optional")
parser = parser.reset()
threw = False
try:
parser.parse("""
dictionary A {
};
interface X {
void doFoo(optional A arg1, optional long arg2);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw, "Dictionary arg followed by optional arg must have default value")
parser = parser.reset()
threw = False
try:
@ -235,6 +284,24 @@ def WebIDLTest(parser, harness):
"Union arg containing dictionary followed by optional arg must "
"be optional")
parser = parser.reset()
threw = False
try:
parser.parse("""
dictionary A {
};
interface X {
void doFoo(optional (A or DOMString) arg1, optional long arg2);
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Union arg containing dictionary followed by optional arg must "
"have a default value")
parser = parser.reset()
parser.parse("""
dictionary A {
@ -326,7 +393,7 @@ def WebIDLTest(parser, harness):
dictionary A {
};
interface X {
void doFoo(optional A arg);
void doFoo(optional A arg = {});
};
""")
results = parser.finish()
@ -337,12 +404,23 @@ def WebIDLTest(parser, harness):
dictionary A {
};
interface X {
void doFoo(optional (A or DOMString) arg);
void doFoo(optional (A or DOMString) arg = {});
};
""")
results = parser.finish()
harness.ok(True, "Union arg containing a dictionary should actually parse")
parser = parser.reset()
parser.parse("""
dictionary A {
};
interface X {
void doFoo(optional (A or DOMString) arg = "abc");
};
""")
results = parser.finish()
harness.ok(True, "Union arg containing a dictionary with string default should actually parse")
parser = parser.reset()
threw = False
try:

View file

@ -3,13 +3,16 @@ def firstArgType(method):
def WebIDLTest(parser, harness):
parser.parse("""
// Give our dictionary a required member so we don't need to
// mess with optional and default values.
dictionary Dict {
required long member;
};
callback interface Foo {
};
interface Bar {
// Bit of a pain to get things that have dictionary types
void passDict(optional Dict arg);
void passDict(Dict arg);
void passFoo(Foo arg);
void passNullableUnion((object? or DOMString) arg);
void passNullable(Foo? arg);
@ -156,8 +159,8 @@ def WebIDLTest(parser, harness):
"AncestorInterface", "UnrelatedInterface",
"ImplementedInterface", "CallbackInterface",
"CallbackInterface?", "CallbackInterface2",
"object", "Callback", "Callback2", "optional Dict",
"optional Dict2", "sequence<long>", "sequence<short>",
"object", "Callback", "Callback2", "Dict",
"Dict2", "sequence<long>", "sequence<short>",
"record<DOMString, object>",
"record<USVString, Dict>",
"record<ByteString, long>",
@ -165,7 +168,7 @@ def WebIDLTest(parser, harness):
"Promise<any>", "Promise<any>?",
"USVString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer",
"Uint8Array", "Uint16Array",
"(long or Callback)", "optional (long or Dict)",
"(long or Callback)", "(long or Dict)",
]
# When we can parse Date, we need to add it here.
# XXXbz we can, and should really do that...
@ -174,7 +177,7 @@ def WebIDLTest(parser, harness):
def allBut(list1, list2):
return [a for a in list1 if a not in list2 and
(a != "any" and a != "Promise<any>" and a != "Promise<any>?")]
unions = [ "(long or Callback)", "optional (long or Dict)" ]
unions = [ "(long or Callback)", "(long or Dict)" ]
numerics = [ "long", "short", "long?", "short?" ]
booleans = [ "boolean", "boolean?" ]
primitives = numerics + booleans
@ -189,7 +192,7 @@ def WebIDLTest(parser, harness):
interfaces = [ "Interface", "Interface?", "AncestorInterface",
"UnrelatedInterface", "ImplementedInterface" ] + bufferSourceTypes + sharedBufferSourceTypes
nullables = (["long?", "short?", "boolean?", "Interface?",
"CallbackInterface?", "optional Dict", "optional Dict2",
"CallbackInterface?", "Dict", "Dict2",
"Date?", "any", "Promise<any>?"] +
allBut(unions, [ "(long or Callback)" ]))
dates = [ "Date", "Date?" ]
@ -233,8 +236,8 @@ def WebIDLTest(parser, harness):
setDistinguishable("object", nonObjects)
setDistinguishable("Callback", nonUserObjects)
setDistinguishable("Callback2", nonUserObjects)
setDistinguishable("optional Dict", allBut(nonUserObjects, nullables))
setDistinguishable("optional Dict2", allBut(nonUserObjects, nullables))
setDistinguishable("Dict", allBut(nonUserObjects, nullables))
setDistinguishable("Dict2", allBut(nonUserObjects, nullables))
setDistinguishable("sequence<long>",
allBut(argTypes, sequences + ["object"]))
setDistinguishable("sequence<short>",
@ -254,7 +257,7 @@ def WebIDLTest(parser, harness):
setDistinguishable("SharedArrayBuffer", allBut(argTypes, ["SharedArrayBuffer", "object"]))
setDistinguishable("(long or Callback)",
allBut(nonUserObjects, numerics))
setDistinguishable("optional (long or Dict)",
setDistinguishable("(long or Dict)",
allBut(nonUserObjects, numerics + nullables))
def areDistinguishable(type1, type2):
@ -273,8 +276,10 @@ def WebIDLTest(parser, harness):
callback interface CallbackInterface2 {};
callback Callback = any();
callback Callback2 = long(short arg);
dictionary Dict {};
dictionary Dict2 {};
// Give our dictionaries required members so we don't need to
// mess with optional and default values.
dictionary Dict { required long member; };
dictionary Dict2 { required long member; };
interface TestInterface {%s
};
"""

View file

@ -10,7 +10,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw, "Constant cannot have [] as a default value")

View file

@ -8,7 +8,7 @@ def WebIDLTest(parser, harness):
try:
parser.parse(input)
results = parser.finish()
except WebIDL.WebIDLError, e:
except WebIDL.WebIDLError as e:
threw = True
lines = str(e).split('\n')

View file

@ -14,7 +14,7 @@ interface ?"""
try:
parser.parse(input)
results = parser.finish()
except WebIDL.WebIDLError, e:
except WebIDL.WebIDLError as e:
threw = True
lines = str(e).split('\n')

View file

@ -124,7 +124,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown on invalid Exposed value on interface.")
@ -140,7 +140,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown on invalid Exposed value on attribute.")
@ -156,7 +156,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown on invalid Exposed value on operation.")
@ -172,7 +172,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown on invalid Exposed value on constant.")
@ -192,7 +192,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown on member exposed where its interface is not.")
@ -216,7 +216,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown on LHS of implements being exposed where RHS is not.")

View file

@ -68,7 +68,7 @@ def WebIDLTest(parser, harness):
long m(float arg);
};
""")
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "[LenientFloat] only allowed on void methods")
@ -81,7 +81,7 @@ def WebIDLTest(parser, harness):
void m(unrestricted float arg);
};
""")
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "[LenientFloat] only allowed on methods with unrestricted float args")
@ -94,7 +94,7 @@ def WebIDLTest(parser, harness):
void m(sequence<unrestricted float> arg);
};
""")
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "[LenientFloat] only allowed on methods with unrestricted float args (2)")
@ -107,7 +107,7 @@ def WebIDLTest(parser, harness):
void m((unrestricted float or FloatTypes) arg);
};
""")
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "[LenientFloat] only allowed on methods with unrestricted float args (3)")
@ -120,6 +120,6 @@ def WebIDLTest(parser, harness):
readonly attribute float foo;
};
""")
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "[LenientFloat] only allowed on writable attributes")

View file

@ -9,7 +9,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
harness.ok(False, "Should fail to parse")
except Exception, e:
except Exception as e:
harness.ok("Name collision" in e.message,
"Should have name collision for interface")
@ -21,7 +21,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
harness.ok(False, "Should fail to parse")
except Exception, e:
except Exception as e:
harness.ok("Name collision" in e.message,
"Should have name collision for dictionary")
@ -33,7 +33,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
harness.ok(False, "Should fail to parse")
except Exception, e:
except Exception as e:
harness.ok("Multiple unresolvable definitions" in e.message,
"Should have name collision for dictionary")

View file

@ -374,3 +374,89 @@ def WebIDLTest(parser, harness):
threw = True
harness.ok(threw,
"Should not allow unknown extended attributes on interfaces")
parser = parser.reset()
parser.parse("""
[Global] interface Window {};
[Exposed=Window, LegacyWindowAlias=A]
interface B {};
[Exposed=Window, LegacyWindowAlias=(C, D)]
interface E {};
""");
results = parser.finish();
harness.check(results[1].legacyWindowAliases, ["A"],
"Should support a single identifier")
harness.check(results[2].legacyWindowAliases, ["C", "D"],
"Should support an identifier list")
parser = parser.reset()
threw = False
try:
parser.parse("""
[LegacyWindowAlias]
interface A {};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should not allow [LegacyWindowAlias] with no value")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Exposed=Worker, LegacyWindowAlias=B]
interface A {};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should not allow [LegacyWindowAlias] without Window exposure")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global] interface Window {};
interface A {};
[Exposed=Window, LegacyWindowAlias=A]
interface B {};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should not allow [LegacyWindowAlias] to conflict with other identifiers")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global] interface Window {};
[Exposed=Window, LegacyWindowAlias=A]
interface B {};
interface A {};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should not allow [LegacyWindowAlias] to conflict with other identifiers")
parser = parser.reset()
threw = False
try:
parser.parse("""
[Global] interface Window {};
[Exposed=Window, LegacyWindowAlias=A]
interface B {};
[Exposed=Window, LegacyWindowAlias=A]
interface C {};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should not allow [LegacyWindowAlias] to conflict with other identifiers")

View file

@ -37,10 +37,10 @@ def WebIDLTest(parser, harness):
p.finish()
harness.ok(False,
prefix + " - Interface passed when should've failed")
except WebIDL.WebIDLError, e:
except WebIDL.WebIDLError as e:
harness.ok(True,
prefix + " - Interface failed as expected")
except Exception, e:
except Exception as e:
harness.ok(False,
prefix + " - Interface failed but not as a WebIDLError exception: %s" % e)

View file

@ -1,6 +1,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
def should_throw(parser, harness, message, code):
parser = parser.reset();

View file

@ -120,7 +120,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(not threw, "Should allow integer to float type corecion")
@ -133,7 +133,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should not allow [GetterThrows] on methods")
@ -146,7 +146,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should not allow [SetterThrows] on methods")
@ -159,7 +159,7 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should spell [Throws] correctly on methods")
@ -172,6 +172,85 @@ def WebIDLTest(parser, harness):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should not allow __noSuchMethod__ methods")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface A {
[Throws, LenientFloat]
void foo(float myFloat);
[Throws]
void foo();
};
""")
results = parser.finish()
except Exception as x:
threw = True
harness.ok(not threw, "Should allow LenientFloat to be only in a specific overload")
parser = parser.reset()
parser.parse("""
interface A {
[Throws]
void foo();
[Throws, LenientFloat]
void foo(float myFloat);
};
""")
results = parser.finish()
iface = results[0]
methods = iface.members
lenientFloat = methods[0].getExtendedAttribute("LenientFloat")
harness.ok(lenientFloat is not None, "LenientFloat in overloads must be added to the method")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface A {
[Throws, LenientFloat]
void foo(float myFloat);
[Throws]
void foo(float myFloat, float yourFloat);
};
""")
results = parser.finish()
except Exception as x:
threw = True
harness.ok(threw, "Should prevent overloads from getting different restricted float behavior")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface A {
[Throws]
void foo(float myFloat, float yourFloat);
[Throws, LenientFloat]
void foo(float myFloat);
};
""")
results = parser.finish()
except Exception as x:
threw = True
harness.ok(threw, "Should prevent overloads from getting different restricted float behavior (2)")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface A {
[Throws, LenientFloat]
void foo(float myFloat);
[Throws, LenientFloat]
void foo(short myShort);
};
""")
results = parser.finish()
except Exception as x:
threw = True
harness.ok(threw, "Should prevent overloads from getting redundant [LenientFloat]")

View file

@ -70,7 +70,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -85,7 +85,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -104,7 +104,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -123,7 +123,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -142,7 +142,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -161,7 +161,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -180,7 +180,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -199,7 +199,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -218,6 +218,6 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")

View file

@ -33,7 +33,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown because record can't have void as value type.")
@ -47,7 +47,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw,
"Should have thrown on dictionary containing itself via record.")

View file

@ -1,6 +1,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
def should_throw(parser, harness, message, code):
parser = parser.reset();

View file

@ -4,15 +4,15 @@ def WebIDLTest(parser, harness):
typedef long? mynullablelong;
interface Foo {
const mylong X = 5;
const mynullablelong Y = 7;
const mynullablelong Z = null;
void foo(mylong arg);
void foo(optional mynullablelong arg = 7);
void bar(optional mynullablelong arg = null);
void baz(mylong arg);
};
""")
results = parser.finish()
harness.check(results[2].members[1].type.name, "LongOrNull",
harness.check(results[2].members[1].signatures()[0][1][0].type.name, "LongOrNull",
"Should expand typedefs")
parser = parser.reset()

View file

@ -24,7 +24,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -39,7 +39,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")
@ -59,6 +59,6 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should have thrown.")

View file

@ -111,7 +111,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw,
"Should have thrown when shadowing unforgeable attribute on "
@ -130,7 +130,7 @@ def WebIDLTest(parser, harness):
""")
results = parser.finish()
except Exception,x:
except Exception as x:
threw = True
harness.ok(threw,
"Should have thrown when shadowing unforgeable operation on "

View file

@ -17,7 +17,7 @@ def combinations(iterable, r):
n = len(pool)
if r > n:
return
indices = range(r)
indices = list(range(r))
yield tuple(pool[i] for i in indices)
while True:
for i in reversed(range(r)):