mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-29 10:08:38 +00:00
604a6d61ce
- Bug 1123516 - Implement maplike/setlike in WebIDL parser; r=bz (5d62bcd93) - Bug 1140324 - Remove __noSuchMethod__ handling from WebIDL parser and throw an exception instead. r=peterv (f7ea99339) - Bug 1123516 - Implement maplike/setlike in WebIDL Codegen; r=b (0ca39b335) - Bug 1183604, add some more assertions to help implementing new cycle collectable classes, r=mccr8 (1e66d29fe) - Bug 1178665 - Part 1: Make Promise::DispatchToMicroTask public. r=khuey (b962e6006) - Bug 1178665 - Part 2 - Adapt to latest Animation.finish procedure changes. r=bbirtles (33219fc0d) - Bug 1178665 - Part 3: Make finish notifications asynchronously in most cases. r=bbirtles, r=smaug (144c0944a) - Bug1180770part 1. Remove the unused ThrowNotEnoughArgsError. r=peterv (8bc1690f5) - Bug1180770part 2. Remove the unused ifaceName/memberName arguments of ThrowMethodFailedWithDetails and rename it to ThrowMethodFailed. r=peterv (ee4900547) - Bug 1135961. Implement subclassing of DOM objects. r=peterv (8e7e67b88) - Bug 1170691 - part 1 - add the generating script's directory to sys.path in file_generate.py; r=glandium (dd1520952) - Bug 1168409 - part 1 - avoid importing buildconfig in histogram_tools.py; r=gfritzsche (6a46dce23) - Bug 1168409 - part 2 - avoiding importing usecounters in histogram_tools.py; r=gfritzsche (21a468303) - Bug 1144397. Disallow using fill when dedent would do. r=peterv (544d4978d) - Bug 1158806. Don't try to include stuff for a generated hasInstance hook if we have no interface object, since in that case we don't need the include. r=peterv (d280a1608) - missing bit of Bug 1161627 - part 2 - machine-convert TemporaryRef<T> to already_AddRefed<T> (c51384311) - Bug 1166910 followup: Add missing 'override' keyword to HTMLImageElement method GetImageReferrerPolicy. rs=ehsan (9e3dc8e6d) - Bug 1174913 - remove unnecessary attribute parsing. r=bz (fdb769eda) - Bug 1170680 - Do not add non-animated images to the visible list in response to UNLOCKED_DRAW. r=tn (a594883e8) - Bug 1174923 - Stop delaying the document load event until images are decoded. r=tn a=kwierso (caee1b25f) - Bug 968923 - part 3b - propagating use counters from SVG images into owning/parent documents; r=seth (234a41484) - Bug 968923 - part 3a - add core DOM use counter functionality; r=smaug (98bb77358) - Bug 968923 - part 3c - miscellaneous telemetry changes for use counters; r=gfritzsche (83adec291) - Bug 968923 - part 4 - hook up use counters to WebIDL bindings; r=bz (8545e9a9b) - Bug 771367 - Update test_animations_omta.html to support testing pseudo-elements. r=dbaron (4b2e5481b) - Bug 1177563 - Test that we share agent rule processors across different documents. r=dbaron (d64146359) - Bug 1181450 - Make GENERATED_FILES more visible during the build by printing their name when they are being generated. r=gps (b0c2166e8) - Bug 1215526 - part 1 - pass dependencies file to file_generate.py; r=glandium (a14ea304a) - Bug 1215526 - part 2 - write dependencies to file_generate.py's depfile; r=glandium (dc49ad380)
529 lines
19 KiB
Python
529 lines
19 KiB
Python
import WebIDL
|
|
import traceback
|
|
def WebIDLTest(parser, harness):
|
|
|
|
def shouldPass(prefix, iface, expectedMembers, numProductions=1):
|
|
p = parser.reset()
|
|
p.parse(iface)
|
|
results = p.finish()
|
|
harness.check(len(results), numProductions,
|
|
"%s - Should have production count %d" % (prefix, numProductions))
|
|
harness.ok(isinstance(results[0], WebIDL.IDLInterface),
|
|
"%s - Should be an IDLInterface" % (prefix))
|
|
harness.check(len(results[0].members), len(expectedMembers),
|
|
"%s - Should be %d members" % (prefix,
|
|
len(expectedMembers)))
|
|
for m in results[0].members:
|
|
name = m.identifier.name
|
|
if (name, type(m)) in expectedMembers:
|
|
harness.ok(True, "%s - %s - Should be a %s" % (prefix, name,
|
|
type(m)))
|
|
elif isinstance(m, WebIDL.IDLMaplikeOrSetlike):
|
|
harness.ok(True, "%s - %s - Should be a MaplikeOrSetlike" %
|
|
(prefix, name))
|
|
else:
|
|
harness.ok(False, "%s - %s - Unknown symbol of type %s" %
|
|
(prefix, name, type(m)))
|
|
return results
|
|
|
|
def shouldFail(prefix, iface):
|
|
try:
|
|
p = parser.reset()
|
|
p.parse(iface)
|
|
p.finish()
|
|
harness.ok(False,
|
|
prefix + " - Interface passed when should've failed")
|
|
except WebIDL.WebIDLError, e:
|
|
harness.ok(True,
|
|
prefix + " - Interface failed as expected")
|
|
except Exception, e:
|
|
harness.ok(False,
|
|
prefix + " - Interface failed but not as a WebIDLError exception")
|
|
|
|
iterableMembers = [(x, WebIDL.IDLMethod) for x in ["entries", "keys",
|
|
"values", "forEach"]]
|
|
iterableMembers.extend([("size", WebIDL.IDLAttribute)])
|
|
setROMembers = ([(x, WebIDL.IDLMethod) for x in ["has"]] +
|
|
[("__setlike", WebIDL.IDLMaplikeOrSetlike)] +
|
|
iterableMembers)
|
|
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)] +
|
|
iterableMembers)
|
|
mapRWMembers = ([(x, WebIDL.IDLMethod) for x in ["set",
|
|
"clear",
|
|
"delete"]] + mapROMembers)
|
|
mapRWChromeMembers = ([(x, WebIDL.IDLMethod) for x in ["__set",
|
|
"__clear",
|
|
"__delete"]] +
|
|
mapRWMembers)
|
|
|
|
disallowedMemberNames = ["keys", "entries", "values", "forEach", "has",
|
|
"size"]
|
|
mapDisallowedMemberNames = ["get"] + disallowedMemberNames
|
|
disallowedNonMethodNames = ["clear", "delete"]
|
|
mapDisallowedNonMethodNames = ["set"] + disallowedNonMethodNames
|
|
setDisallowedNonMethodNames = ["add"] + disallowedNonMethodNames
|
|
|
|
#
|
|
# Simple Usage Tests
|
|
#
|
|
|
|
shouldPass("Maplike (readwrite)",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
""", mapRWMembers)
|
|
|
|
shouldPass("Maplike (readonly)",
|
|
"""
|
|
interface Foo1 {
|
|
readonly maplike<long, long>;
|
|
};
|
|
""", mapROMembers)
|
|
|
|
shouldPass("Setlike (readwrite)",
|
|
"""
|
|
interface Foo1 {
|
|
setlike<long>;
|
|
};
|
|
""", setRWMembers)
|
|
|
|
shouldPass("Setlike (readonly)",
|
|
"""
|
|
interface Foo1 {
|
|
readonly setlike<long>;
|
|
};
|
|
""", setROMembers)
|
|
|
|
shouldPass("Inheritance of maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
};
|
|
""", mapRWMembers, numProductions=2)
|
|
|
|
shouldPass("Implements with maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 {
|
|
};
|
|
Foo2 implements Foo1;
|
|
""", mapRWMembers, numProductions=3)
|
|
|
|
shouldPass("JS Implemented maplike interface",
|
|
"""
|
|
[JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1",
|
|
Constructor()]
|
|
interface Foo1 {
|
|
setlike<long>;
|
|
};
|
|
""", setRWChromeMembers)
|
|
|
|
shouldPass("JS Implemented maplike interface",
|
|
"""
|
|
[JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1",
|
|
Constructor()]
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
""", mapRWChromeMembers)
|
|
|
|
#
|
|
# Multiple maplike/setlike tests
|
|
#
|
|
|
|
shouldFail("Two maplike/setlikes on same interface",
|
|
"""
|
|
interface Foo1 {
|
|
setlike<long>;
|
|
maplike<long, long>;
|
|
};
|
|
""")
|
|
|
|
shouldFail("Two maplike/setlikes in partials",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
partial interface Foo1 {
|
|
setlike<long>;
|
|
};
|
|
""")
|
|
|
|
shouldFail("Conflicting maplike/setlikes across inheritance",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
setlike<long>;
|
|
};
|
|
""")
|
|
|
|
shouldFail("Conflicting maplike/setlikes across multistep inheritance",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
};
|
|
interface Foo3 : Foo2 {
|
|
setlike<long>;
|
|
};
|
|
""")
|
|
|
|
shouldFail("Consequential interface with conflicting maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 {
|
|
setlike<long>;
|
|
};
|
|
Foo2 implements Foo1;
|
|
""")
|
|
|
|
shouldFail("Consequential interfaces with conflicting maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 {
|
|
setlike<long>;
|
|
};
|
|
interface Foo3 {
|
|
};
|
|
Foo3 implements Foo1;
|
|
Foo3 implements Foo2;
|
|
""")
|
|
|
|
#
|
|
# Member name collision tests
|
|
#
|
|
|
|
def testConflictingMembers(likeMember, conflictName, expectedMembers, methodPasses):
|
|
"""
|
|
Tests for maplike/setlike member generation against conflicting member
|
|
names. If methodPasses is True, this means we expect the interface to
|
|
pass in the case of method shadowing, and expectedMembers should be the
|
|
list of interface members to check against on the passing interface.
|
|
|
|
"""
|
|
if methodPasses:
|
|
shouldPass("Conflicting method: %s and %s" % (likeMember, conflictName),
|
|
"""
|
|
interface Foo1 {
|
|
%s;
|
|
[Throws]
|
|
void %s(long test1, double test2, double test3);
|
|
};
|
|
""" % (likeMember, conflictName), expectedMembers)
|
|
else:
|
|
shouldFail("Conflicting method: %s and %s" % (likeMember, conflictName),
|
|
"""
|
|
interface Foo1 {
|
|
%s;
|
|
[Throws]
|
|
void %s(long test1, double test2, double test3);
|
|
};
|
|
""" % (likeMember, conflictName))
|
|
# Inherited conflicting methods should ALWAYS fail
|
|
shouldFail("Conflicting inherited method: %s and %s" % (likeMember, conflictName),
|
|
"""
|
|
interface Foo1 {
|
|
void %s(long test1, double test2, double test3);
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
%s;
|
|
};
|
|
""" % (conflictName, likeMember))
|
|
shouldFail("Conflicting static method: %s and %s" % (likeMember, conflictName),
|
|
"""
|
|
interface Foo1 {
|
|
%s;
|
|
static void %s(long test1, double test2, double test3);
|
|
};
|
|
""" % (likeMember, conflictName))
|
|
shouldFail("Conflicting attribute: %s and %s" % (likeMember, conflictName),
|
|
"""
|
|
interface Foo1 {
|
|
%s
|
|
attribute double %s;
|
|
};
|
|
""" % (likeMember, conflictName))
|
|
shouldFail("Conflicting const: %s and %s" % (likeMember, conflictName),
|
|
"""
|
|
interface Foo1 {
|
|
%s;
|
|
const double %s = 0;
|
|
};
|
|
""" % (likeMember, conflictName))
|
|
shouldFail("Conflicting static attribute: %s and %s" % (likeMember, conflictName),
|
|
"""
|
|
interface Foo1 {
|
|
%s;
|
|
static attribute long %s;
|
|
};
|
|
""" % (likeMember, conflictName))
|
|
|
|
for member in mapDisallowedMemberNames:
|
|
testConflictingMembers("maplike<long, long>", member, mapRWMembers, False)
|
|
for member in disallowedMemberNames:
|
|
testConflictingMembers("setlike<long>", member, setRWMembers, False)
|
|
for member in mapDisallowedNonMethodNames:
|
|
testConflictingMembers("maplike<long, long>", member, mapRWMembers, True)
|
|
for member in setDisallowedNonMethodNames:
|
|
testConflictingMembers("setlike<long>", member, setRWMembers, True)
|
|
|
|
shouldPass("Inheritance of maplike/setlike with child member collision",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
void entries();
|
|
};
|
|
""", mapRWMembers, numProductions=2)
|
|
|
|
shouldPass("Inheritance of multi-level maplike/setlike with child member collision",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
};
|
|
interface Foo3 : Foo2 {
|
|
void entries();
|
|
};
|
|
""", mapRWMembers, numProductions=3)
|
|
|
|
shouldFail("Interface with consequential maplike/setlike interface member collision",
|
|
"""
|
|
interface Foo1 {
|
|
void entries();
|
|
};
|
|
interface Foo2 {
|
|
maplike<long, long>;
|
|
};
|
|
Foo1 implements Foo2;
|
|
""")
|
|
|
|
shouldFail("Maplike interface with consequential interface member collision",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 {
|
|
void entries();
|
|
};
|
|
Foo1 implements Foo2;
|
|
""")
|
|
|
|
shouldPass("Consequential Maplike interface with inherited interface member collision",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 {
|
|
void entries();
|
|
};
|
|
interface Foo3 : Foo2 {
|
|
};
|
|
Foo3 implements Foo1;
|
|
""", mapRWMembers, numProductions=4)
|
|
|
|
shouldPass("Inherited Maplike interface with consequential interface member collision",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 {
|
|
void entries();
|
|
};
|
|
interface Foo3 : Foo1 {
|
|
};
|
|
Foo3 implements Foo2;
|
|
""", mapRWMembers, numProductions=4)
|
|
|
|
shouldFail("Inheritance of name collision with child maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
void entries();
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
""")
|
|
|
|
shouldFail("Inheritance of multi-level name collision with child maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
void entries();
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
};
|
|
interface Foo3 : Foo2 {
|
|
maplike<long, long>;
|
|
};
|
|
""")
|
|
|
|
shouldPass("Inheritance of attribute collision with parent maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
attribute double size;
|
|
};
|
|
""", mapRWMembers, numProductions=2)
|
|
|
|
shouldPass("Inheritance of multi-level attribute collision with parent maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
};
|
|
interface Foo3 : Foo2 {
|
|
attribute double size;
|
|
};
|
|
""", mapRWMembers, numProductions=3)
|
|
|
|
shouldFail("Inheritance of attribute collision with child maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
attribute double size;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
""")
|
|
|
|
shouldFail("Inheritance of multi-level attribute collision with child maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
attribute double size;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
};
|
|
interface Foo3 : Foo2 {
|
|
maplike<long, long>;
|
|
};
|
|
""")
|
|
|
|
shouldFail("Inheritance of attribute/rw function collision with child maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
attribute double set;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
""")
|
|
|
|
shouldFail("Inheritance of const/rw function collision with child maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
const double set = 0;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
""")
|
|
|
|
shouldPass("Inheritance of rw function with same name in child maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
void clear();
|
|
};
|
|
""", mapRWMembers, numProductions=2)
|
|
|
|
shouldFail("Inheritance of unforgeable attribute collision with child maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
[Unforgeable]
|
|
attribute double size;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
maplike<long, long>;
|
|
};
|
|
""")
|
|
|
|
shouldFail("Inheritance of multi-level unforgeable attribute collision with child maplike/setlike",
|
|
"""
|
|
interface Foo1 {
|
|
[Unforgeable]
|
|
attribute double size;
|
|
};
|
|
interface Foo2 : Foo1 {
|
|
};
|
|
interface Foo3 : Foo2 {
|
|
maplike<long, long>;
|
|
};
|
|
""")
|
|
|
|
shouldPass("Implemented interface with readonly allowable overrides",
|
|
"""
|
|
interface Foo1 {
|
|
readonly setlike<long>;
|
|
readonly attribute boolean clear;
|
|
};
|
|
""", setROMembers + [("clear", WebIDL.IDLAttribute)])
|
|
|
|
shouldPass("JS Implemented read-only interface with readonly allowable overrides",
|
|
"""
|
|
[JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1",
|
|
Constructor()]
|
|
interface Foo1 {
|
|
readonly setlike<long>;
|
|
readonly attribute boolean clear;
|
|
};
|
|
""", setROChromeMembers + [("clear", WebIDL.IDLAttribute)])
|
|
|
|
shouldFail("JS Implemented read-write interface with non-readwrite allowable overrides",
|
|
"""
|
|
[JSImplementation="@mozilla.org/dom/test-interface-js-maplike;1",
|
|
Constructor()]
|
|
interface Foo1 {
|
|
setlike<long>;
|
|
readonly attribute boolean clear;
|
|
};
|
|
""")
|
|
|
|
r = shouldPass("Check proper override of clear/delete/set",
|
|
"""
|
|
interface Foo1 {
|
|
maplike<long, long>;
|
|
long clear(long a, long b, double c, double d);
|
|
long set(long a, long b, double c, double d);
|
|
long delete(long a, long b, double c, double d);
|
|
};
|
|
""", mapRWMembers)
|
|
|
|
for m in r[0].members:
|
|
if m.identifier.name in ["clear", "set", "delete"]:
|
|
harness.ok(m.isMethod(), "%s should be a method" % m.identifier.name)
|
|
harness.check(m.maxArgCount, 4, "%s should have 4 arguments" % m.identifier.name)
|
|
harness.ok(not m.isMaplikeOrSetlikeMethod(),
|
|
"%s should not be a maplike/setlike function" % m.identifier.name)
|