1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Example WebIDL compatible schema for testing API definition features.
// This will be added to as support for each features is implemented.
// This comment is an example of a top level API description, which will be
// extracted and added to the processed python dictionary as a description.
//
// Note: All comment lines preceding the thing they are attached to will be part
// of the description, until a blank new line or non-comment is reached.
interface TestWebIdl {
static undefined returnsUndefined();
static boolean returnsBoolean();
static double returnsDouble();
static long returnsLong();
static DOMString returnsDOMString();
static sequence<DOMString> returnsDOMStringSequence();
static sequence<ExampleType> returnsCustomTypeSequence();
static undefined takesNoArguments();
static undefined takesDOMString(DOMString stringArgument);
static undefined takesOptionalBoolean(optional boolean optionalBoolean);
static undefined takesMultipleArguments(
DOMString argument1, optional double argument2);
static undefined takesOptionalInnerArgument(
DOMString first, optional DOMString optionalInner, DOMString last);
static undefined takesSequenceArgument(sequence<boolean> sequenceArgument);
static undefined takesOptionalSequenceArgument(
optional sequence<boolean> optionalSequenceArgument);
static ExampleType returnsCustomType();
static undefined takesCustomType(ExampleType customTypeArgument);
static undefined takesOptionalCustomType(
optional ExampleType optionalCustomTypeArgument);
static Promise<DOMString> stringPromiseReturn();
static Promise<DOMString?> nullablePromiseReturn();
static Promise<ExampleType> customTypePromiseReturn();
static Promise<undefined> undefinedPromiseReturn();
static Promise<sequence<long>> longSequencePromiseReturn();
static Promise<sequence<ExampleType>> customTypeSequencePromiseReturn();
// Items for testing the processing of IDL comments to schema descriptions:
static undefined noDescription();
// One line description.
static undefined oneLineDescription();
// Multi line description.
// Split over.
// Multiple lines.
static undefined multiLineDescription();
// Paragraphed description.
//
// With blank comment line for paragraph tags.
static undefined paragraphedDescription();
// This function has parameter comments.
//
// |arg1|: This comment about the argument
// is split across multiple lines
// and contains <em>HTML tags</em>.
// |arg2|: This second argument uses a custom type.
static undefined parameterComments(boolean arg1, ExampleType arg2);
// Comment that acts as a description for onTestOne. Parameter specific
// comments are down below before the associated callback definition.
static attribute OnTestOneEvent onTestOne;
// Comment for onTestTwo.
static attribute OnTestTwoEvent onTestTwo;
// Promise returning function, with a comment that provides the name and
// description of the value the promise resolves to.
// |arg1|: This is a normal argument comment.
// |PromiseValue|: returnValueName: A description for the value the promise
// resolves to: with an extra colon for good measure.
static Promise<ExampleType> namedPromiseReturn(boolean arg1);
};
// Comment for parameter descriptions on the onTestOne event. The first part of
// this comment is actually disregarded and all that is consumed is the
// parameter comments below.
// |argument1|: Parameter description for argument1.
// |argument2|: Another description, this time for argment2.
callback OnTestOneListener = undefined (
DOMString argument1, optional double argument2);
// Callback listener for onTestTwo.
// |customType|: An ExampleType passed to the event listener.
callback OnTestTwoListener = undefined (ExampleType customType);
interface OnTestOneEvent : ExtensionEvent {
static void addListener(OnTestOneListener listener);
static void removeListener(OnTestOneListener listener);
static void hasListener(OnTestOneListener listener);
};
interface OnTestTwoEvent : ExtensionEvent {
static void addListener(OnTestTwoListener listener);
static void removeListener(OnTestTwoListener listener);
static void hasListener(OnTestTwoListener listener);
};
dictionary ExampleType {
// Attribute comment attached to ExampleType.someString.
DOMString someString;
// Comment where <var>someNumber</var> has some markup.
double someNumber;
// Comment with HTML comment. <!-- Which should get through -->
boolean? optionalBoolean;
// Comment on sequence type.
sequence<boolean> booleanSequence;
};
partial interface Browser {
static attribute TestWebIdl testWebIdl;
};
|