summaryrefslogtreecommitdiffstats
path: root/dom/bindings/parser/tests/test_distinguishability.py
diff options
context:
space:
mode:
Diffstat (limited to 'dom/bindings/parser/tests/test_distinguishability.py')
-rw-r--r--dom/bindings/parser/tests/test_distinguishability.py97
1 files changed, 69 insertions, 28 deletions
diff --git a/dom/bindings/parser/tests/test_distinguishability.py b/dom/bindings/parser/tests/test_distinguishability.py
index 8497490b1f..caf726c16b 100644
--- a/dom/bindings/parser/tests/test_distinguishability.py
+++ b/dom/bindings/parser/tests/test_distinguishability.py
@@ -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?"]
@@ -265,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"])
@@ -282,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.
@@ -327,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>?", [])
@@ -358,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):
@@ -377,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; };