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 | # -*- coding: UTF-8 -*- |
michael@0 | 2 | |
michael@0 | 3 | import WebIDL |
michael@0 | 4 | |
michael@0 | 5 | def WebIDLTest(parser, harness): |
michael@0 | 6 | parser.parse(""" |
michael@0 | 7 | interface TestByteString { |
michael@0 | 8 | attribute ByteString bs; |
michael@0 | 9 | attribute DOMString ds; |
michael@0 | 10 | }; |
michael@0 | 11 | """) |
michael@0 | 12 | |
michael@0 | 13 | results = parser.finish(); |
michael@0 | 14 | |
michael@0 | 15 | harness.ok(True, "TestByteString interface parsed without error.") |
michael@0 | 16 | |
michael@0 | 17 | harness.check(len(results), 1, "Should be one production") |
michael@0 | 18 | harness.ok(isinstance(results[0], WebIDL.IDLInterface), |
michael@0 | 19 | "Should be an IDLInterface") |
michael@0 | 20 | iface = results[0] |
michael@0 | 21 | harness.check(iface.identifier.QName(), "::TestByteString", "Interface has the right QName") |
michael@0 | 22 | harness.check(iface.identifier.name, "TestByteString", "Interface has the right name") |
michael@0 | 23 | harness.check(iface.parent, None, "Interface has no parent") |
michael@0 | 24 | |
michael@0 | 25 | members = iface.members |
michael@0 | 26 | harness.check(len(members), 2, "Should be two productions") |
michael@0 | 27 | |
michael@0 | 28 | attr = members[0] |
michael@0 | 29 | harness.ok(isinstance(attr, WebIDL.IDLAttribute), "Should be an IDLAttribute") |
michael@0 | 30 | harness.check(attr.identifier.QName(), "::TestByteString::bs", "Attr has correct QName") |
michael@0 | 31 | harness.check(attr.identifier.name, "bs", "Attr has correct name") |
michael@0 | 32 | harness.check(str(attr.type), "ByteString", "Attr type is the correct name") |
michael@0 | 33 | harness.ok(attr.type.isByteString(), "Should be ByteString type") |
michael@0 | 34 | harness.ok(attr.type.isString(), "Should be String collective type") |
michael@0 | 35 | harness.ok(not attr.type.isDOMString(), "Should be not be DOMString type") |
michael@0 | 36 | |
michael@0 | 37 | # now check we haven't broken DOMStrings in the process. |
michael@0 | 38 | attr = members[1] |
michael@0 | 39 | harness.ok(isinstance(attr, WebIDL.IDLAttribute), "Should be an IDLAttribute") |
michael@0 | 40 | harness.check(attr.identifier.QName(), "::TestByteString::ds", "Attr has correct QName") |
michael@0 | 41 | harness.check(attr.identifier.name, "ds", "Attr has correct name") |
michael@0 | 42 | harness.check(str(attr.type), "String", "Attr type is the correct name") |
michael@0 | 43 | harness.ok(attr.type.isDOMString(), "Should be DOMString type") |
michael@0 | 44 | harness.ok(attr.type.isString(), "Should be String collective type") |
michael@0 | 45 | harness.ok(not attr.type.isByteString(), "Should be not be ByteString type") |
michael@0 | 46 | |
michael@0 | 47 | # Cannot represent constant ByteString in IDL. |
michael@0 | 48 | threw = False |
michael@0 | 49 | try: |
michael@0 | 50 | parser.parse(""" |
michael@0 | 51 | interface ConstByteString { |
michael@0 | 52 | const ByteString foo = "hello" |
michael@0 | 53 | }; |
michael@0 | 54 | """) |
michael@0 | 55 | except WebIDL.WebIDLError: |
michael@0 | 56 | threw = True |
michael@0 | 57 | harness.ok(threw, "Should have thrown a WebIDL error") |
michael@0 | 58 | |
michael@0 | 59 | # Cannot have optional ByteStrings with default values |
michael@0 | 60 | threw = False |
michael@0 | 61 | try: |
michael@0 | 62 | parser.parse(""" |
michael@0 | 63 | interface OptionalByteString { |
michael@0 | 64 | void passByteString(optional ByteString arg = "hello"); |
michael@0 | 65 | }; |
michael@0 | 66 | """) |
michael@0 | 67 | results2 = parser.finish(); |
michael@0 | 68 | except WebIDL.WebIDLError: |
michael@0 | 69 | threw = True |
michael@0 | 70 | |
michael@0 | 71 | harness.ok(threw, "Should have thrown a WebIDL error") |
michael@0 | 72 |