4 def WebIDLTest(parser
, harness
):
8 interface TestSecureContextOnInterface {
9 const octet TEST_CONSTANT = 0;
10 readonly attribute byte testAttribute;
11 undefined testMethod(byte foo);
13 partial interface TestSecureContextOnInterface {
14 const octet TEST_CONSTANT_2 = 0;
15 readonly attribute byte testAttribute2;
16 undefined testMethod2(byte foo);
20 results
= parser
.finish()
22 len(results
[0].members
),
24 "TestSecureContextOnInterface should have six members",
27 results
[0].getExtendedAttribute("SecureContext"),
28 "Interface should have [SecureContext] extended attribute",
31 results
[0].members
[0].getExtendedAttribute("SecureContext"),
32 "[SecureContext] should propagate from interface to constant members",
35 results
[0].members
[1].getExtendedAttribute("SecureContext"),
36 "[SecureContext] should propagate from interface to attribute members",
39 results
[0].members
[2].getExtendedAttribute("SecureContext"),
40 "[SecureContext] should propagate from interface to method members",
43 results
[0].members
[3].getExtendedAttribute("SecureContext"),
45 "[SecureContext] should propagate from interface to "
46 "constant members from partial interface"
50 results
[0].members
[4].getExtendedAttribute("SecureContext"),
52 "[SecureContext] should propagate from interface to "
53 "attribute members from partial interface"
57 results
[0].members
[5].getExtendedAttribute("SecureContext"),
58 "[SecureContext] should propagate from interface to method members from partial interface",
61 # Same thing, but with the partial interface specified first:
62 parser
= parser
.reset()
65 partial interface TestSecureContextOnInterfaceAfterPartialInterface {
66 const octet TEST_CONSTANT_2 = 0;
67 readonly attribute byte testAttribute2;
68 undefined testMethod2(byte foo);
71 interface TestSecureContextOnInterfaceAfterPartialInterface {
72 const octet TEST_CONSTANT = 0;
73 readonly attribute byte testAttribute;
74 undefined testMethod(byte foo);
78 results
= parser
.finish()
80 len(results
[1].members
),
82 "TestSecureContextOnInterfaceAfterPartialInterface should have six members",
85 results
[1].getExtendedAttribute("SecureContext"),
86 "Interface should have [SecureContext] extended attribute",
89 results
[1].members
[0].getExtendedAttribute("SecureContext"),
90 "[SecureContext] should propagate from interface to constant members",
93 results
[1].members
[1].getExtendedAttribute("SecureContext"),
94 "[SecureContext] should propagate from interface to attribute members",
97 results
[1].members
[2].getExtendedAttribute("SecureContext"),
98 "[SecureContext] should propagate from interface to method members",
101 results
[1].members
[3].getExtendedAttribute("SecureContext"),
103 "[SecureContext] should propagate from interface to constant members from "
108 results
[1].members
[4].getExtendedAttribute("SecureContext"),
110 "[SecureContext] should propagate from interface to attribute members from "
115 results
[1].members
[5].getExtendedAttribute("SecureContext"),
117 "[SecureContext] should propagate from interface to method members from partial "
122 parser
= parser
.reset()
125 interface TestSecureContextOnPartialInterface {
126 const octet TEST_CONSTANT = 0;
127 readonly attribute byte testAttribute;
128 undefined testMethod(byte foo);
131 partial interface TestSecureContextOnPartialInterface {
132 const octet TEST_CONSTANT_2 = 0;
133 readonly attribute byte testAttribute2;
134 undefined testMethod2(byte foo);
138 results
= parser
.finish()
140 len(results
[0].members
),
142 "TestSecureContextOnPartialInterface should have six members",
145 results
[0].getExtendedAttribute("SecureContext") is None,
146 "[SecureContext] should not propagate from a partial interface to the interface",
149 results
[0].members
[0].getExtendedAttribute("SecureContext") is None,
151 "[SecureContext] should not propagate from a partial interface to the interface's "
156 results
[0].members
[1].getExtendedAttribute("SecureContext") is None,
158 "[SecureContext] should not propagate from a partial interface to the interface's "
163 results
[0].members
[2].getExtendedAttribute("SecureContext") is None,
165 "[SecureContext] should not propagate from a partial interface to the interface's "
170 results
[0].members
[3].getExtendedAttribute("SecureContext"),
171 "Constant members from [SecureContext] partial interface should be [SecureContext]",
174 results
[0].members
[4].getExtendedAttribute("SecureContext"),
175 "Attribute members from [SecureContext] partial interface should be [SecureContext]",
178 results
[0].members
[5].getExtendedAttribute("SecureContext"),
179 "Method members from [SecureContext] partial interface should be [SecureContext]",
182 parser
= parser
.reset()
185 interface TestSecureContextOnInterfaceMembers {
186 const octet TEST_NON_SECURE_CONSTANT_1 = 0;
188 const octet TEST_SECURE_CONSTANT = 1;
189 const octet TEST_NON_SECURE_CONSTANT_2 = 2;
190 readonly attribute byte testNonSecureAttribute1;
192 readonly attribute byte testSecureAttribute;
193 readonly attribute byte testNonSecureAttribute2;
194 undefined testNonSecureMethod1(byte foo);
196 undefined testSecureMethod(byte foo);
197 undefined testNonSecureMethod2(byte foo);
201 results
= parser
.finish()
203 len(results
[0].members
),
205 "TestSecureContextOnInterfaceMembers should have nine members",
208 results
[0].getExtendedAttribute("SecureContext") is None,
209 "[SecureContext] on members should not propagate up to the interface",
212 results
[0].members
[0].getExtendedAttribute("SecureContext") is None,
213 "Constant should not have [SecureContext] extended attribute",
216 results
[0].members
[1].getExtendedAttribute("SecureContext"),
217 "Constant should have [SecureContext] extended attribute",
220 results
[0].members
[2].getExtendedAttribute("SecureContext") is None,
221 "Constant should not have [SecureContext] extended attribute",
224 results
[0].members
[3].getExtendedAttribute("SecureContext") is None,
225 "Attribute should not have [SecureContext] extended attribute",
228 results
[0].members
[4].getExtendedAttribute("SecureContext"),
229 "Attribute should have [SecureContext] extended attribute",
232 results
[0].members
[5].getExtendedAttribute("SecureContext") is None,
233 "Attribute should not have [SecureContext] extended attribute",
236 results
[0].members
[6].getExtendedAttribute("SecureContext") is None,
237 "Method should not have [SecureContext] extended attribute",
240 results
[0].members
[7].getExtendedAttribute("SecureContext"),
241 "Method should have [SecureContext] extended attribute",
244 results
[0].members
[8].getExtendedAttribute("SecureContext") is None,
245 "Method should not have [SecureContext] extended attribute",
248 parser
= parser
.reset()
251 interface TestSecureContextOnPartialInterfaceMembers {
253 partial interface TestSecureContextOnPartialInterfaceMembers {
254 const octet TEST_NON_SECURE_CONSTANT_1 = 0;
256 const octet TEST_SECURE_CONSTANT = 1;
257 const octet TEST_NON_SECURE_CONSTANT_2 = 2;
258 readonly attribute byte testNonSecureAttribute1;
260 readonly attribute byte testSecureAttribute;
261 readonly attribute byte testNonSecureAttribute2;
262 undefined testNonSecureMethod1(byte foo);
264 undefined testSecureMethod(byte foo);
265 undefined testNonSecureMethod2(byte foo);
269 results
= parser
.finish()
271 len(results
[0].members
),
273 "TestSecureContextOnPartialInterfaceMembers should have nine members",
276 results
[0].members
[0].getExtendedAttribute("SecureContext") is None,
277 "Constant from partial interface should not have [SecureContext] extended attribute",
280 results
[0].members
[1].getExtendedAttribute("SecureContext"),
281 "Constant from partial interface should have [SecureContext] extended attribute",
284 results
[0].members
[2].getExtendedAttribute("SecureContext") is None,
285 "Constant from partial interface should not have [SecureContext] extended attribute",
288 results
[0].members
[3].getExtendedAttribute("SecureContext") is None,
289 "Attribute from partial interface should not have [SecureContext] extended attribute",
292 results
[0].members
[4].getExtendedAttribute("SecureContext"),
293 "Attribute from partial interface should have [SecureContext] extended attribute",
296 results
[0].members
[5].getExtendedAttribute("SecureContext") is None,
297 "Attribute from partial interface should not have [SecureContext] extended attribute",
300 results
[0].members
[6].getExtendedAttribute("SecureContext") is None,
301 "Method from partial interface should not have [SecureContext] extended attribute",
304 results
[0].members
[7].getExtendedAttribute("SecureContext"),
305 "Method from partial interface should have [SecureContext] extended attribute",
308 results
[0].members
[8].getExtendedAttribute("SecureContext") is None,
309 "Method from partial interface should not have [SecureContext] extended attribute",
312 parser
= parser
.reset()
317 [SecureContext=something]
318 interface TestSecureContextTakesNoValue1 {
319 const octet TEST_SECURE_CONSTANT = 0;
323 results
= parser
.finish()
324 except WebIDL
.WebIDLError
:
326 harness
.ok(threw
, "[SecureContext] must take no arguments (testing on interface)")
328 parser
= parser
.reset()
333 interface TestSecureContextForOverloads1 {
335 undefined testSecureMethod(byte foo);
337 partial interface TestSecureContextForOverloads1 {
338 undefined testSecureMethod(byte foo, byte bar);
342 results
= parser
.finish()
343 except WebIDL
.WebIDLError
:
348 "If [SecureContext] appears on an overloaded operation, then it MUST appear on all "
353 parser
= parser
.reset()
358 interface TestSecureContextForOverloads2 {
360 undefined testSecureMethod(byte foo);
362 partial interface TestSecureContextForOverloads2 {
364 undefined testSecureMethod(byte foo, byte bar);
368 results
= parser
.finish()
369 except WebIDL
.WebIDLError
:
373 "[SecureContext] can appear on an overloaded operation if it appears on all overloads",
376 parser
= parser
.reset()
382 interface TestSecureContextOnInterfaceAndMember {
384 undefined testSecureMethod(byte foo);
388 results
= parser
.finish()
389 except WebIDL
.WebIDLError
:
392 threw
, "[SecureContext] must not appear on an interface and interface member"
395 parser
= parser
.reset()
400 interface TestSecureContextOnPartialInterfaceAndMember {
403 partial interface TestSecureContextOnPartialInterfaceAndMember {
405 undefined testSecureMethod(byte foo);
409 results
= parser
.finish()
410 except WebIDL
.WebIDLError
:
415 "[SecureContext] must not appear on a partial interface and one of the partial "
416 "interface's member's"
420 parser
= parser
.reset()
426 interface TestSecureContextOnInterfaceAndPartialInterfaceMember {
428 partial interface TestSecureContextOnInterfaceAndPartialInterfaceMember {
430 undefined testSecureMethod(byte foo);
434 results
= parser
.finish()
435 except WebIDL
.WebIDLError
:
440 "[SecureContext] must not appear on an interface and one of its partial interface's "
445 parser
= parser
.reset()
451 interface TestSecureContextOnInheritedInterface {
453 interface TestSecureContextNotOnInheritingInterface : TestSecureContextOnInheritedInterface {
454 undefined testSecureMethod(byte foo);
458 results
= parser
.finish()
459 except WebIDL
.WebIDLError
:
464 "[SecureContext] must appear on interfaces that inherit from another [SecureContext] "
470 parser
= parser
.reset()
474 namespace TestSecureContextOnNamespace {
475 const octet TEST_CONSTANT = 0;
476 readonly attribute byte testAttribute;
477 undefined testMethod(byte foo);
479 partial namespace TestSecureContextOnNamespace {
480 const octet TEST_CONSTANT_2 = 0;
481 readonly attribute byte testAttribute2;
482 undefined testMethod2(byte foo);
486 results
= parser
.finish()
488 len(results
[0].members
),
490 "TestSecureContextOnNamespace should have six members",
493 results
[0].getExtendedAttribute("SecureContext"),
494 "Namespace should have [SecureContext] extended attribute",
497 results
[0].members
[0].getExtendedAttribute("SecureContext"),
498 "[SecureContext] should propagate from namespace to constant members",
501 results
[0].members
[1].getExtendedAttribute("SecureContext"),
502 "[SecureContext] should propagate from namespace to attribute members",
505 results
[0].members
[2].getExtendedAttribute("SecureContext"),
506 "[SecureContext] should propagate from namespace to method members",
509 results
[0].members
[3].getExtendedAttribute("SecureContext"),
511 "[SecureContext] should propagate from namespace to "
512 "constant members from partial namespace"
516 results
[0].members
[4].getExtendedAttribute("SecureContext"),
518 "[SecureContext] should propagate from namespace to "
519 "attribute members from partial namespace"
523 results
[0].members
[5].getExtendedAttribute("SecureContext"),
524 "[SecureContext] should propagate from namespace to method members from partial namespace",
527 parser
= parser
.reset()
530 namespace TestSecureContextOnNamespace {
531 const octet TEST_CONSTANT = 0;
532 readonly attribute byte testAttribute;
533 undefined testMethod(byte foo);
536 partial namespace TestSecureContextOnNamespace {
537 const octet TEST_CONSTANT_2 = 0;
538 readonly attribute byte testAttribute2;
539 undefined testMethod2(byte foo);
543 results
= parser
.finish()
545 len(results
[0].members
),
547 "TestSecureContextOnNamespace should have six members",
550 results
[0].getExtendedAttribute("SecureContext") is None,
551 "Namespace should not have [SecureContext] extended attribute",
554 results
[0].members
[0].getExtendedAttribute("SecureContext") is None,
556 "[SecureContext] should not propagate from a partial namespace to the namespace's "
561 results
[0].members
[1].getExtendedAttribute("SecureContext") is None,
563 "[SecureContext] should not propagate from a partial namespace to the namespace's "
568 results
[0].members
[2].getExtendedAttribute("SecureContext") is None,
570 "[SecureContext] should not propagate from a partial namespace to the namespace's "
575 results
[0].members
[3].getExtendedAttribute("SecureContext"),
576 "Constant members from [SecureContext] partial namespace should be [SecureContext]",
579 results
[0].members
[4].getExtendedAttribute("SecureContext"),
580 "Attribute members from [SecureContext] partial namespace should be [SecureContext]",
583 results
[0].members
[5].getExtendedAttribute("SecureContext"),
584 "Method members from [SecureContext] partial namespace should be [SecureContext]",
588 parser
= parser
.reset()
592 interface TestSecureContextInterfaceThatIncludesNonSecureContextMixin {
593 const octet TEST_CONSTANT = 0;
595 interface mixin TestNonSecureContextMixin {
596 const octet TEST_CONSTANT_2 = 0;
597 readonly attribute byte testAttribute2;
598 undefined testMethod2(byte foo);
600 TestSecureContextInterfaceThatIncludesNonSecureContextMixin includes TestNonSecureContextMixin;
603 results
= parser
.finish()
605 len(results
[0].members
),
608 "TestSecureContextInterfaceThatImplementsNonSecureContextInterface should have four "
613 results
[0].getExtendedAttribute("SecureContext"),
614 "Interface should have [SecureContext] extended attribute",
617 results
[0].members
[0].getExtendedAttribute("SecureContext"),
619 "[SecureContext] should propagate from interface to constant members even when other "
620 "members are copied from a non-[SecureContext] interface"
624 results
[0].members
[1].getExtendedAttribute("SecureContext") is None,
625 "Constants copied from non-[SecureContext] mixin should not be [SecureContext]",
628 results
[0].members
[2].getExtendedAttribute("SecureContext") is None,
629 "Attributes copied from non-[SecureContext] mixin should not be [SecureContext]",
632 results
[0].members
[3].getExtendedAttribute("SecureContext") is None,
633 "Methods copied from non-[SecureContext] mixin should not be [SecureContext]",
636 parser
= parser
.reset()
639 interface TestSecureContextInterfaceThatIncludesNonSecureContextMixin {
640 const octet TEST_CONSTANT = 0;
643 interface mixin TestNonSecureContextMixin {
644 const octet TEST_CONSTANT_2 = 0;
645 readonly attribute byte testAttribute2;
646 undefined testMethod2(byte foo);
648 TestSecureContextInterfaceThatIncludesNonSecureContextMixin includes TestNonSecureContextMixin;
651 results
= parser
.finish()
653 len(results
[0].members
),
656 "TestSecureContextInterfaceThatImplementsNonSecureContextInterface should have four "
661 results
[0].getExtendedAttribute("SecureContext") is None,
662 "Interface should not have [SecureContext] extended attribute",
665 results
[0].members
[0].getExtendedAttribute("SecureContext") is None,
667 "[SecureContext] should not propagate from interface to constant members when other "
668 "members are copied from a [SecureContext] mixin"
672 results
[0].members
[1].getExtendedAttribute("SecureContext"),
673 "Constants copied from [SecureContext] mixin should be [SecureContext]",
676 results
[0].members
[2].getExtendedAttribute("SecureContext"),
677 "Attributes copied from [SecureContext] mixin should be [SecureContext]",
680 results
[0].members
[3].getExtendedAttribute("SecureContext"),
681 "Methods copied from [SecureContext] mixin should be [SecureContext]",
684 # Test SecureContext and LegacyNoInterfaceObject
685 parser
= parser
.reset()
688 [LegacyNoInterfaceObject, SecureContext]
689 interface TestSecureContextLegacyNoInterfaceObject {
690 undefined testSecureMethod(byte foo);
694 results
= parser
.finish()
696 len(results
[0].members
),
698 "TestSecureContextLegacyNoInterfaceObject should have only one member",
701 results
[0].getExtendedAttribute("SecureContext"),
702 "Interface should have [SecureContext] extended attribute",
705 results
[0].members
[0].getExtendedAttribute("SecureContext"),
706 "Interface member should have [SecureContext] extended attribute",