interface ExampleInterface { void exampleMethod(); readonly attribute USVString url; };
The ExampleInterface or the ExampleInterface.exampleMethod()
Or like this: exampleMethod - which uses data-link-for
This fake spec tried to exercise all aspects of WebIDL so as to do regression testing in this complex piece of code.
CUSTOM PARAGRAPH
dictionary Foo { record<DOMString, USVString> pass; };
[Constructor(sequence<DOMString> methodData), SecureContext] interface LinkingTest { readonly attribute DOMString? aBoolAttribute; Promise<void> returnsPromise(unsigned long long argument); };
TestInterface interface TestCBInterface interface TestDictionary dictionary TestEnum enum TestMixin mixin interface TestCallBack callback TestTypedef typedef
interface ParenthesisTest { void basic(); void noParens(); [Something] void ext(); unsigned long long ull(short s); unsigned long long ull(long s); getter float withName (); setter void named (); void dataLtOverride(); void fullyQualified(); void fullyQualifiedNoParens(); void doTheFoo(); };
// makes sure that types and identifiers are not confused interface SimilarlyNamed { attribute TestInterface testInterface; attribute TestCBInterface testCBInterface; attribute TestDictionary testDictionary; attribute TestEnum testEnum; attribute TestTypedef testTypedef; readonly maplike<SimilarlyNamed, SimilarlyNamed>; }; TestInterface includes TestMixin; interface TestInterface {}; callback interface TestCBInterface {}; typedef (TestInterface or TestCBInterface) TestTypedef; callback TestCallBack = TestCallBack (); dictionary TestDictionary {}; enum TestEnum { "value" }; interface mixin TestMixin { attribute Bar bar; }; interface Bar {};
testInterface attribute; testCBInterface attribute; testDictionary attribute; testEnum attribute; testTypedef attribute;
bar attribute of TestMixin
ull() is a method. Its overloaded form returns a SuperStar/
dataLtOverride()
ParenthesisTest
basic()...
ext()...
paramed()...
withName()...
named()...
dfnDoesNotLinkToAnything()...
noParens...
ParenthesisTest.fullyQualified()...
ParenthesisTest.fullyQualifiedNoParens ...
1 basic
2 basic()
3 basic
4 basic
ParenthesisTest.fullyQualifiedNoParens
ParenthesisTest.fullyQualifiedNoParens()
The following aspects of WebIDL are not currently supported and are not yet tested for:
_
in the IDL must drop the leading _
for
their real name.
Support for these features will likely be added later.
The following features are supposedly supported but actually buggy:
Things that still need to be done:
Basic interface.
interface SuperStar {};
Interface with extended attribute.
[Something, Constructor()] interface SuperStar {};
Interface with extended attribute and RHS identifier list.
[Global=Window, Exposed=(Window,Worker)] interface SuperStar {};
Interface with inheritance.
interface SuperStar : HyperStar {};
Partial interface .
partial interface SuperStar {};
Callback interface .
callback interface SuperStar {};
Interface mixin .
interface mixin SuperStar {};
partial interface mixin SuperStar {};
interface DocInterface {}; interface DocIsNotCaseSensitive {}; interface UndocInterface {}; namespace Afterglow {};
DocInterface is an interface and so is DoCiSnOtCaSeSeNsItIvE. Afterglow is a namespace.
Constructors on interfaces
[Something, Constructor, Constructor(boolean bar, sequence<double> foo, Promise<double> blah)] interface SuperStar {};
[Constructor] interface SuperStar {};
NamedConstructors on interfaces
[Something, NamedConstructor=Sun(), NamedConstructor=Sun(boolean bar, Date foo)] interface SuperStar {};
All constants and some type testing
interface ConstTest { // 1 const boolean test = true; // 2 const byte bite = 8; // 3 const octet eight = 7; // 4 const short small = 42; // 5 const unsigned short shortish = 250; // 6 const long notSoLong = 99999; // 7 const unsigned long somewhatLong = 9999999; // 8 const long long veryLong = 9999999999999; // 9 const unsigned long long soLong = 99999999999999999; // 10 const float ationDevice = 4.2; // 11 const unrestricted float buoy = 4.2222222222; // 12 const double twice = 4.222222222; // 13 const unrestricted double rambaldi = 47.0; // 14 const boolean? why = false; // 15 const boolean? notSo = null; // 16 const short inf = Infinity; // 17 const short mininf = -Infinity; // 18 const short cheese = NaN; // 19 [Something] const short extAttr = NaN; };
rambaldi is a constant and so are why and this other thing.
Basic attributes testing.
The Performance
interface.
The performance attribute.
interface AttrBasic { // 1 attribute DOMString regular; // 2 readonly attribute DOMString ro; // 2.2 readonly attribute DOMString _readonly; // 2.5 inherit attribute DOMString in; // 2.7 stringifier attribute DOMString st; // 3 [Something] readonly attribute DOMString ext; // 3.10.31 attribute FrozenArray<DOMString> alist; // 4.0 attribute Promise<DOMString> operation; // 5.0 readonly attribute Performance performance; };
readonly and regular are attributes.
Basic operations testing.
interface StringifierTest { stringifier StringPass (); stringifier StringNamedPass named (); };
interface GetterTest { getter GetterPass (); getter GetterNamedPass named (); };
interface SetterTest { setter SetterPass (); setter SetterNamedPass named (); };
performance() method.
interface MethBasic { // 1 void basic(); // 2 [Something] void ext(); // 3 unsigned long long ull(short s, short n); // 3.5 SuperStar? ull(); // 5 getter float (); // 6 getter float withName (); // 7 setter void (); // 8 setter void named (); // 9 static Promise<RTCCertificate> generateCertificate(AlgorithmIdentifier keygenAlgorithm); // 10 stringifier DOMString identifier(); // 11 stringifier DOMString (); // 12 stringifier; Promise<void> complete(optional PaymentComplete result = "unknown"); Promise<void> another(optional /*trivia*/ PaymentComplete result = "unknown"); Performance performance(); };
ull is a method. Its overloaded form returns a SuperStar/
interface Yukina { iterable<DOMString>; }; interface Sayo { iterable<DOMString, DOMString>; }; interface Kasumi { maplike<DOMString, DOMString>; }; interface Arisa { setlike<DOMString>; };
interface MapLikeInterface { maplike<MapLikeInterface, MapLikeInterface>; }; interface ReadOnlyMapLike { readonly maplike<ReadOnlyMapLike, ReadOnlyMapLike>; }; interface SetLikeInterface { setlike<SetLikeInterface>; }; interface ReadOnlySetLike { readonly setlike<ReadOnlySetLike>; };
Yukina interface Sayo interface Kasumi interface Arisa interface MapLikeInterface interface ReadOnlyMapLike interface SetLikeInterface interface ReadOnlySetLike interface
interface SuperStar { // This is a comment // over two lines. /* This one has three. */ };
Basic dictionary.
dictionary SuperStar {};
Inheriting dictionary.
dictionary SuperStar : HyperStar {};
Data in dictionary.
dictionary SuperStar { // 1 DOMString value; // 2 DOMString? nullable; // 3 [Something]float ext; // 4 unsigned long long longLong; // 5 boolean test = true; // 6 byte little = 2; // 7 byte big = Infinity; // 8 byte cheese = NaN; // 9 DOMString blah = "blah blah"; };
dictionary SuperStar { required DOMString value; DOMString optValue; };
dictionary DictDocTest { DOMString dictDocField; DOMString? otherField; long undocField; };
dictionary OneThing { int x; }; partial dictionary AnotherThing { int y; };
DictDocTest contains dictDocField and otherField
Basic enumeration.
enum EnumBasic { // 1 "one", // 2 "two" // 3 , "three", // 4 "white space" };
EnumBasic
one is first.
one is referenced with a [link-for]
attribute.
EnumBasic.one may also be referenced with fully-qualified name.
white space
enum EmptyEnum { "", "not empty" };
EmptyEnum
""
...not empty...
enum Test1 { "enum" }; enum Test2 { "enum" };
enum enum
Basic callback.
callback SuperStar = void();
Less basic callback.
callback CbLessBasic = unsigned long long?(optional any value);
Callback with multiple arguments.
callback SortCallback = void (any a, any b);
CbLessBasic
Basic typedef.
typedef DOMString string;
Less basic typedef.
typedef unsigned long long? tdLessBasic;
tdLessBasic
Typedef with an extended attribute.
typedef ([Clamp] unsigned long or ConstrainULongRange) ConstrainULong;
Typedef with an extended attribute on union type.
typedef [Clamp] (unsigned long or ConstrainULongRange) ConstrainULong2;
/* test1 */ typedef /* test2 */ [Clamp] /* test3 */ (/* test4 */ unsigned long /* test5 */ or /* test6 */ ConstrainULongRange /* test7 */ ) /* test8 */ ConstrainULong3 /* test9 */;
Basic includes.
Window includes Breakable;
Less basic includes.
[Something]Window includes Breakable;
interface Documented { attribute DOMString docString; attribute DOMString notDefined; attribute DOMString definedElsewhere; };
docString is defined in a note.
Testing [link-for]
:
Some generic term isn't IDL.
Some generic term also isn't part of Documented.
docString is.
notDefined is too, but isn't defined elsewhere.
Documented.definedElsewhere is defined by writing its fully-qualified name. Documented.docString is linked by writing its fully-qualified name.
We had a bug where Documented got a [dfn-for] attribute, which broke links to it without [link-for].
interface NotTested {};
interface AutoLinkToIDLSpec { [Default] object toJSON(); };
interface DefinedToJson { readonly attribute DOMString country; [Default] object toJSON(); void toWhatever(); };
When toJSON() is called, run [[!WEBIDL]]'s default toJSON operation.
[Constructor(X x, optional Y y, /*trivia*/ Z y)] interface Foo { void foo(X x, optional Y y, /*trivia*/ optional Z z); }; callback CallBack = Z? (X x, optional Y y, /*trivia*/ optional Z z);
interface CodedThings { attribute DOMString definedElsewhere; attribute Bar barBar; void doTheFoo(); };doTheFoo() barBar
interface InterfaceType { readonly attribute DOMString attributeType; void operationType(); }; dictionary DictionaryType { DOMString fieldType; }; enum EnumType { "enumValueType" };
InterfaceType attributeType operationType DictionaryType fieldType EnumType enumValueType