Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync WebIDL.py with gecko #23748

Merged
merged 2 commits into from Jul 12, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Sync WebIDL.py with gecko

  • Loading branch information
saschanaz committed Jul 12, 2019
commit 56f31c85ef9cc79140f375641302310c6680ded4

Large diffs are not rendered by default.

@@ -1,12 +1,12 @@
--- WebIDL.py
+++ WebIDL.py
@@ -1786,7 +1786,8 @@ class IDLInterface(IDLInterfaceOrNamespace):
identifier == "ProbablyShortLivingWrapper" or
@@ -1768,7 +1768,8 @@ class IDLInterface(IDLInterfaceOrNamespace):
identifier == "LegacyUnenumerableNamedProperties" or
identifier == "RunConstructorInCallerCompartment" or
- identifier == "WantsEventListenerHooks"):
+ identifier == "WantsEventListenerHooks" or
identifier == "WantsEventListenerHooks" or
- identifier == "Serializable"):
+ identifier == "Serializable" or
+ identifier == "Abstract"):
# Known extended attributes that do not take values
if not attr.noArguments():
raise WebIDLError("[%s] must take no arguments" % identifier,
raise WebIDLError("[%s] must take no arguments" % identifier,
@@ -1,15 +1,15 @@
--- WebIDL.py
+++ WebIDL.py
@@ -2275,7 +2275,7 @@ class IDLUnresolvedType(IDLType):
return typedefType.complete(scope)
@@ -2283,7 +2283,7 @@ class IDLUnresolvedType(IDLType):
return typedefType.complete(scope).withExtendedAttributes(self.extraTypeAttributes)
elif obj.isCallback() and not obj.isInterface():
assert self.name.name == obj.identifier.name
- return IDLCallbackType(self.location, obj)
+ return IDLCallbackType(obj.location, obj)

name = self.name.resolve(scope, None)
return IDLWrapperType(self.location, obj)
@@ -6688,7 +6688,7 @@ class Parser(Tokenizer):
@@ -6854,7 +6854,7 @@ class Parser(Tokenizer):
type = IDLTypedefType(self.getLocation(p, 1), obj.innerType,
obj.identifier.name)
elif obj.isCallback() and not obj.isInterface():
@@ -1,6 +1,6 @@
--- WebIDL.py
+++ WebIDL.py
@@ -6959,7 +6959,8 @@ class Parser(Tokenizer):
@@ -7123,7 +7123,8 @@ class Parser(Tokenizer):
self.parser = yacc.yacc(module=self,
outputdir=outputdir,
tabmodule='webidlyacc',
@@ -1,9 +1,9 @@
--- WebIDL.py
+++ WebIDL.py
@@ -1787,7 +1787,8 @@ class IDLInterface(IDLInterfaceOrNamespace):
identifier == "LegacyUnenumerableNamedProperties" or
@@ -1769,7 +1769,8 @@ class IDLInterface(IDLInterfaceOrNamespace):
identifier == "RunConstructorInCallerCompartment" or
identifier == "WantsEventListenerHooks" or
identifier == "Serializable" or
- identifier == "Abstract"):
+ identifier == "Abstract" or
+ identifier == "Inline"):

This file was deleted.

@@ -62,7 +62,7 @@ def run_tests(tests, verbose):
harness.start()
try:
_test.WebIDLTest.__call__(WebIDL.Parser(), harness)
except Exception, ex:
except Exception as ex:
print("TEST-UNEXPECTED-FAIL | Unhandled exception in test %s: %s" % (testpath, ex))
traceback.print_exc()
finally:
@@ -133,7 +133,7 @@ def checkAttr(attr, QName, name, type, readonly):
};
""")
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 checkAttr(attr, QName, name, type, readonly):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(threw, "Should spell [Throws] correctly")

@@ -159,7 +159,7 @@ def checkAttr(attr, QName, name, type, readonly):
};
""")
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 checkAttr(attr, QName, name, type, readonly):
};
""")
results = parser.finish()
except Exception, x:
except Exception as x:
threw = True
harness.ok(not threw, "Should allow [SameObject] on attributes of interface type")
@@ -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")
@@ -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")
@@ -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

@@ -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).")
@@ -12,9 +12,6 @@
("::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.")
@@ -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.")
@@ -13,6 +13,7 @@ def WebIDLTest(parser, harness):

harness.ok(threw, "Should have thrown.")

parser = parser.reset()
threw = False
try:
parser.parse("""
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.