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.
michael@0 | 1 | import WebIDL |
michael@0 | 2 | |
michael@0 | 3 | def WebIDLTest(parser, harness): |
michael@0 | 4 | parser.parse(""" |
michael@0 | 5 | enum TestEnum { |
michael@0 | 6 | "", |
michael@0 | 7 | "foo", |
michael@0 | 8 | "bar" |
michael@0 | 9 | }; |
michael@0 | 10 | |
michael@0 | 11 | interface TestEnumInterface { |
michael@0 | 12 | TestEnum doFoo(boolean arg); |
michael@0 | 13 | readonly attribute TestEnum foo; |
michael@0 | 14 | }; |
michael@0 | 15 | """) |
michael@0 | 16 | |
michael@0 | 17 | results = parser.finish() |
michael@0 | 18 | |
michael@0 | 19 | harness.ok(True, "TestEnumInterfaces interface parsed without error.") |
michael@0 | 20 | harness.check(len(results), 2, "Should be one production") |
michael@0 | 21 | harness.ok(isinstance(results[0], WebIDL.IDLEnum), |
michael@0 | 22 | "Should be an IDLEnum") |
michael@0 | 23 | harness.ok(isinstance(results[1], WebIDL.IDLInterface), |
michael@0 | 24 | "Should be an IDLInterface") |
michael@0 | 25 | |
michael@0 | 26 | enum = results[0] |
michael@0 | 27 | harness.check(enum.identifier.QName(), "::TestEnum", "Enum has the right QName") |
michael@0 | 28 | harness.check(enum.identifier.name, "TestEnum", "Enum has the right name") |
michael@0 | 29 | harness.check(enum.values(), ["", "foo", "bar"], "Enum has the right values") |
michael@0 | 30 | |
michael@0 | 31 | iface = results[1] |
michael@0 | 32 | |
michael@0 | 33 | harness.check(iface.identifier.QName(), "::TestEnumInterface", "Interface has the right QName") |
michael@0 | 34 | harness.check(iface.identifier.name, "TestEnumInterface", "Interface has the right name") |
michael@0 | 35 | harness.check(iface.parent, None, "Interface has no parent") |
michael@0 | 36 | |
michael@0 | 37 | members = iface.members |
michael@0 | 38 | harness.check(len(members), 2, "Should be one production") |
michael@0 | 39 | harness.ok(isinstance(members[0], WebIDL.IDLMethod), |
michael@0 | 40 | "Should be an IDLMethod") |
michael@0 | 41 | method = members[0] |
michael@0 | 42 | harness.check(method.identifier.QName(), "::TestEnumInterface::doFoo", |
michael@0 | 43 | "Method has correct QName") |
michael@0 | 44 | harness.check(method.identifier.name, "doFoo", "Method has correct name") |
michael@0 | 45 | |
michael@0 | 46 | signatures = method.signatures() |
michael@0 | 47 | harness.check(len(signatures), 1, "Expect one signature") |
michael@0 | 48 | |
michael@0 | 49 | (returnType, arguments) = signatures[0] |
michael@0 | 50 | harness.check(str(returnType), "TestEnum (Wrapper)", "Method type is the correct name") |
michael@0 | 51 | harness.check(len(arguments), 1, "Method has the right number of arguments") |
michael@0 | 52 | arg = arguments[0] |
michael@0 | 53 | harness.ok(isinstance(arg, WebIDL.IDLArgument), "Should be an IDLArgument") |
michael@0 | 54 | harness.check(str(arg.type), "Boolean", "Argument has the right type") |
michael@0 | 55 | |
michael@0 | 56 | attr = members[1] |
michael@0 | 57 | harness.check(attr.identifier.QName(), "::TestEnumInterface::foo", |
michael@0 | 58 | "Attr has correct QName") |
michael@0 | 59 | harness.check(attr.identifier.name, "foo", "Attr has correct name") |
michael@0 | 60 | |
michael@0 | 61 | harness.check(str(attr.type), "TestEnum (Wrapper)", "Attr type is the correct name") |
michael@0 | 62 | |
michael@0 | 63 | # Now reset our parser |
michael@0 | 64 | parser = parser.reset() |
michael@0 | 65 | threw = False |
michael@0 | 66 | try: |
michael@0 | 67 | parser.parse(""" |
michael@0 | 68 | enum Enum { |
michael@0 | 69 | "a", |
michael@0 | 70 | "b", |
michael@0 | 71 | "c" |
michael@0 | 72 | }; |
michael@0 | 73 | interface TestInterface { |
michael@0 | 74 | void foo(optional Enum e = "d"); |
michael@0 | 75 | }; |
michael@0 | 76 | """) |
michael@0 | 77 | results = parser.finish() |
michael@0 | 78 | except: |
michael@0 | 79 | threw = True |
michael@0 | 80 | |
michael@0 | 81 | harness.ok(threw, "Should not allow a bogus default value for an enum") |
michael@0 | 82 | |
michael@0 | 83 | # Now reset our parser |
michael@0 | 84 | parser = parser.reset() |
michael@0 | 85 | parser.parse(""" |
michael@0 | 86 | enum Enum { |
michael@0 | 87 | "a", |
michael@0 | 88 | "b", |
michael@0 | 89 | "c", |
michael@0 | 90 | }; |
michael@0 | 91 | """) |
michael@0 | 92 | results = parser.finish() |
michael@0 | 93 | harness.check(len(results), 1, "Should allow trailing comma in enum") |