dom/bindings/parser/tests/test_callback.py

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 interface TestCallback {
michael@0 6 attribute CallbackType? listener;
michael@0 7 };
michael@0 8
michael@0 9 callback CallbackType = boolean (unsigned long arg);
michael@0 10 """)
michael@0 11
michael@0 12 results = parser.finish()
michael@0 13
michael@0 14 harness.ok(True, "TestCallback interface parsed without error.")
michael@0 15 harness.check(len(results), 2, "Should be two productions.")
michael@0 16 iface = results[0]
michael@0 17 harness.ok(isinstance(iface, WebIDL.IDLInterface),
michael@0 18 "Should be an IDLInterface")
michael@0 19 harness.check(iface.identifier.QName(), "::TestCallback", "Interface has the right QName")
michael@0 20 harness.check(iface.identifier.name, "TestCallback", "Interface has the right name")
michael@0 21 harness.check(len(iface.members), 1, "Expect %s members" % 1)
michael@0 22
michael@0 23 attr = iface.members[0]
michael@0 24 harness.ok(isinstance(attr, WebIDL.IDLAttribute),
michael@0 25 "Should be an IDLAttribute")
michael@0 26 harness.ok(attr.isAttr(), "Should be an attribute")
michael@0 27 harness.ok(not attr.isMethod(), "Attr is not an method")
michael@0 28 harness.ok(not attr.isConst(), "Attr is not a const")
michael@0 29 harness.check(attr.identifier.QName(), "::TestCallback::listener", "Attr has the right QName")
michael@0 30 harness.check(attr.identifier.name, "listener", "Attr has the right name")
michael@0 31 t = attr.type
michael@0 32 harness.ok(not isinstance(t, WebIDL.IDLWrapperType), "Attr has the right type")
michael@0 33 harness.ok(isinstance(t, WebIDL.IDLNullableType), "Attr has the right type")
michael@0 34 harness.ok(t.isCallback(), "Attr has the right type")

mercurial