Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 import WebIDL
3 def WebIDLTest(parser, harness):
4 def checkArgument(argument, QName, name, type, optional, variadic):
5 harness.ok(isinstance(argument, WebIDL.IDLArgument),
6 "Should be an IDLArgument")
7 harness.check(argument.identifier.QName(), QName, "Argument has the right QName")
8 harness.check(argument.identifier.name, name, "Argument has the right name")
9 harness.check(str(argument.type), type, "Argument has the right return type")
10 harness.check(argument.optional, optional, "Argument has the right optional value")
11 harness.check(argument.variadic, variadic, "Argument has the right variadic value")
13 def checkMethod(method, QName, name, signatures,
14 static=True, getter=False, setter=False, creator=False,
15 deleter=False, legacycaller=False, stringifier=False,
16 chromeOnly=False):
17 harness.ok(isinstance(method, WebIDL.IDLMethod),
18 "Should be an IDLMethod")
19 harness.ok(method.isMethod(), "Method is a method")
20 harness.ok(not method.isAttr(), "Method is not an attr")
21 harness.ok(not method.isConst(), "Method is not a const")
22 harness.check(method.identifier.QName(), QName, "Method has the right QName")
23 harness.check(method.identifier.name, name, "Method has the right name")
24 harness.check(method.isStatic(), static, "Method has the correct static value")
25 harness.check(method.isGetter(), getter, "Method has the correct getter value")
26 harness.check(method.isSetter(), setter, "Method has the correct setter value")
27 harness.check(method.isCreator(), creator, "Method has the correct creator value")
28 harness.check(method.isDeleter(), deleter, "Method has the correct deleter value")
29 harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value")
30 harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value")
31 harness.check(method.getExtendedAttribute("ChromeOnly") is not None, chromeOnly, "Method has the correct value for ChromeOnly")
32 harness.check(len(method.signatures()), len(signatures), "Method has the correct number of signatures")
34 sigpairs = zip(method.signatures(), signatures)
35 for (gotSignature, expectedSignature) in sigpairs:
36 (gotRetType, gotArgs) = gotSignature
37 (expectedRetType, expectedArgs) = expectedSignature
39 harness.check(str(gotRetType), expectedRetType,
40 "Method has the expected return type.")
42 for i in range(0, len(gotArgs)):
43 (QName, name, type, optional, variadic) = expectedArgs[i]
44 checkArgument(gotArgs[i], QName, name, type, optional, variadic)
46 parser.parse("""
47 [Constructor]
48 interface TestConstructorNoArgs {
49 };
51 [Constructor(DOMString name)]
52 interface TestConstructorWithArgs {
53 };
55 [Constructor(object foo), Constructor(boolean bar)]
56 interface TestConstructorOverloads {
57 };
58 """)
59 results = parser.finish()
60 harness.check(len(results), 3, "Should be three productions")
61 harness.ok(isinstance(results[0], WebIDL.IDLInterface),
62 "Should be an IDLInterface")
63 harness.ok(isinstance(results[1], WebIDL.IDLInterface),
64 "Should be an IDLInterface")
65 harness.ok(isinstance(results[2], WebIDL.IDLInterface),
66 "Should be an IDLInterface")
68 checkMethod(results[0].ctor(), "::TestConstructorNoArgs::constructor",
69 "constructor", [("TestConstructorNoArgs (Wrapper)", [])])
70 checkMethod(results[1].ctor(), "::TestConstructorWithArgs::constructor",
71 "constructor",
72 [("TestConstructorWithArgs (Wrapper)",
73 [("::TestConstructorWithArgs::constructor::name", "name", "String", False, False)])])
74 checkMethod(results[2].ctor(), "::TestConstructorOverloads::constructor",
75 "constructor",
76 [("TestConstructorOverloads (Wrapper)",
77 [("::TestConstructorOverloads::constructor::foo", "foo", "Object", False, False)]),
78 ("TestConstructorOverloads (Wrapper)",
79 [("::TestConstructorOverloads::constructor::bar", "bar", "Boolean", False, False)])])
81 parser = parser.reset()
82 parser.parse("""
83 [ChromeConstructor()]
84 interface TestChromeConstructor {
85 };
86 """)
87 results = parser.finish()
88 harness.check(len(results), 1, "Should be one production")
89 harness.ok(isinstance(results[0], WebIDL.IDLInterface),
90 "Should be an IDLInterface")
92 checkMethod(results[0].ctor(), "::TestChromeConstructor::constructor",
93 "constructor", [("TestChromeConstructor (Wrapper)", [])],
94 chromeOnly=True)
96 parser = parser.reset()
97 threw = False
98 try:
99 parser.parse("""
100 [Constructor(),
101 ChromeConstructor(DOMString a)]
102 interface TestChromeConstructor {
103 };
104 """)
105 results = parser.finish()
106 except:
107 threw = True
109 harness.ok(threw, "Can't have both a Constructor and a ChromeConstructor")