From 0511225e6784654510a3a5be0fa59ba1e684ad19 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 31 Jul 2014 23:50:30 -0400 Subject: [PATCH] Bug 1045743. Add support for the Promise syntax to Web IDL bindings. r=khuey --- dom/bindings/parser/WebIDL.py | 32 ++++++++- dom/bindings/parser/tests/test_promise.py | 18 ++--- dom/webidl/BluetoothAdapter2.webidl | 18 ++--- dom/webidl/BluetoothDevice2.webidl | 3 +- dom/webidl/BluetoothPairingHandle.webidl | 6 +- dom/webidl/DataStore.webidl | 23 +++--- dom/webidl/DataStoreImpl.webidl | 23 +++--- dom/webidl/DeviceStorage.webidl | 3 +- dom/webidl/Directory.webidl | 15 ++-- dom/webidl/Downloads.webidl | 13 ++-- dom/webidl/HTMLMediaElement.webidl | 4 +- dom/webidl/InputMethod.webidl | 18 ++--- dom/webidl/InstallPhaseEvent.webidl | 2 +- dom/webidl/MediaKeySession.webidl | 16 ++--- dom/webidl/MediaKeys.webidl | 13 ++-- dom/webidl/MozSelfSupport.webidl | 2 +- dom/webidl/Navigator.webidl | 8 ++- dom/webidl/Notification.webidl | 2 +- dom/webidl/Promise.webidl | 17 ++--- dom/webidl/PromiseDebugging.webidl | 2 +- dom/webidl/ResourceStatsManager.webidl | 32 +++++---- dom/webidl/ServiceWorkerContainer.webidl | 14 ++-- dom/webidl/SubtleCrypto.webidl | 86 +++++++++++------------ dom/webidl/Telephony.webidl | 6 +- 24 files changed, 188 insertions(+), 188 deletions(-) diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index 8418a6d67090..a314ca7a1abf 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -1540,8 +1540,9 @@ class IDLUnresolvedType(IDLType): Unresolved types are interface types """ - def __init__(self, location, name): + def __init__(self, location, name, promiseInnerType=None): IDLType.__init__(self, location, name) + self._promiseInnerType = promiseInnerType def isComplete(self): return False @@ -1562,8 +1563,11 @@ class IDLUnresolvedType(IDLType): obj = obj.complete(scope) return obj + if self._promiseInnerType and not self._promiseInnerType.isComplete(): + self._promiseInnerType = self._promiseInnerType.complete(scope) + name = self.name.resolve(scope, None) - return IDLWrapperType(self.location, obj) + return IDLWrapperType(self.location, obj, self._promiseInnerType) def isDistinguishableFrom(self, other): raise TypeError("Can't tell whether an unresolved type is or is not " @@ -2157,11 +2161,13 @@ class IDLTypedefType(IDLType, IDLObjectWithIdentifier): return self.inner._getDependentObjects() class IDLWrapperType(IDLType): - def __init__(self, location, inner): + def __init__(self, location, inner, promiseInnerType=None): IDLType.__init__(self, location, inner.identifier.name) self.inner = inner self._identifier = inner.identifier self.builtin = False + assert not promiseInnerType or inner.identifier.name == "Promise" + self._promiseInnerType = promiseInnerType def __eq__(self, other): return isinstance(other, IDLWrapperType) and \ @@ -3873,6 +3879,7 @@ class Tokenizer(object): "object": "OBJECT", "octet": "OCTET", "optional": "OPTIONAL", + "Promise": "PROMISE", "sequence": "SEQUENCE", "MozMap": "MOZMAP", "short": "SHORT", @@ -4893,6 +4900,20 @@ class Parser(Tokenizer): type = IDLNullableType(self.getLocation(p, 5), type) p[0] = type + # Note: Promise is allowed, so we want to parametrize on + # ReturnType, not Type. Also, we want this to end up picking up + # the Promise interface for now, hence the games with IDLUnresolvedType. + def p_NonAnyTypePromiseType(self, p): + """ + NonAnyType : PROMISE LT ReturnType GT Null + """ + innerType = p[3] + promiseIdent = IDLUnresolvedIdentifier(self.getLocation(p, 1), "Promise") + type = IDLUnresolvedType(self.getLocation(p, 1), promiseIdent, p[3]) + if p[5]: + type = IDLNullableType(self.getLocation(p, 5), type) + p[0] = type + def p_NonAnyTypeMozMapType(self, p): """ NonAnyType : MOZMAP LT Type GT Null @@ -4909,6 +4930,11 @@ class Parser(Tokenizer): """ assert isinstance(p[1], IDLUnresolvedIdentifier) + if p[1].name == "Promise": + raise WebIDLError("Promise used without saying what it's " + "parametrized over", + [self.getLocation(p, 1)]) + type = None try: diff --git a/dom/bindings/parser/tests/test_promise.py b/dom/bindings/parser/tests/test_promise.py index 4a6058a93286..55bc07680921 100644 --- a/dom/bindings/parser/tests/test_promise.py +++ b/dom/bindings/parser/tests/test_promise.py @@ -2,9 +2,9 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - interface Promise {}; + interface _Promise {}; interface A { - legacycaller Promise foo(); + legacycaller Promise foo(); }; """) results = parser.finish() @@ -18,9 +18,9 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - interface Promise {}; + interface _Promise {}; interface A { - Promise foo(); + Promise foo(); long foo(long arg); }; """) @@ -35,10 +35,10 @@ def WebIDLTest(parser, harness): threw = False try: parser.parse(""" - interface Promise {}; + interface _Promise {}; interface A { long foo(long arg); - Promise foo(); + Promise foo(); }; """) results = parser.finish(); @@ -50,10 +50,10 @@ def WebIDLTest(parser, harness): parser = parser.reset() parser.parse(""" - interface Promise {}; + interface _Promise {}; interface A { - Promise foo(); - Promise foo(long arg); + Promise foo(); + Promise foo(long arg); }; """) results = parser.finish(); diff --git a/dom/webidl/BluetoothAdapter2.webidl b/dom/webidl/BluetoothAdapter2.webidl index 197ca6f9ad61..b03d3e6f824c 100644 --- a/dom/webidl/BluetoothAdapter2.webidl +++ b/dom/webidl/BluetoothAdapter2.webidl @@ -84,26 +84,20 @@ interface BluetoothAdapter : EventTarget { * request, and the last one would indicate adapter.state becomes * enabled/disabled. */ - // Promise [NewObject, Throws] - Promise enable(); - // Promise + Promise enable(); [NewObject, Throws] - Promise disable(); + Promise disable(); - // Promise [NewObject, Throws] - Promise setName(DOMString aName); - // Promise + Promise setName(DOMString aName); [NewObject, Throws] - Promise setDiscoverable(boolean aDiscoverable); + Promise setDiscoverable(boolean aDiscoverable); - // Promise [NewObject, Throws] - Promise startDiscovery(); - // Promise + Promise startDiscovery(); [NewObject, Throws] - Promise stopDiscovery(); + Promise stopDiscovery(); [NewObject, Throws] DOMRequest pair(DOMString deviceAddress); diff --git a/dom/webidl/BluetoothDevice2.webidl b/dom/webidl/BluetoothDevice2.webidl index c56fc9e494c2..98b1fc88e2dd 100644 --- a/dom/webidl/BluetoothDevice2.webidl +++ b/dom/webidl/BluetoothDevice2.webidl @@ -39,7 +39,6 @@ interface BluetoothDevice : EventTarget * If the operation succeeds, the promise will be resolved with up-to-date * UUID list which is identical to attribute uuids. */ - // Promise> [NewObject, Throws] - Promise fetchUuids(); + Promise> fetchUuids(); }; diff --git a/dom/webidl/BluetoothPairingHandle.webidl b/dom/webidl/BluetoothPairingHandle.webidl index 383b8ee183a4..8a850b911b16 100644 --- a/dom/webidl/BluetoothPairingHandle.webidl +++ b/dom/webidl/BluetoothPairingHandle.webidl @@ -13,10 +13,8 @@ interface BluetoothPairingHandle */ readonly attribute DOMString passkey; - // Promise [NewObject, Throws] - Promise setPinCode(DOMString aPinCode); - // Promise + Promise setPinCode(DOMString aPinCode); [NewObject, Throws] - Promise setPairingConfirmation(boolean aConfirm); + Promise setPairingConfirmation(boolean aConfirm); }; diff --git a/dom/webidl/DataStore.webidl b/dom/webidl/DataStore.webidl index 9694371833be..e992b65ab77d 100644 --- a/dom/webidl/DataStore.webidl +++ b/dom/webidl/DataStore.webidl @@ -27,35 +27,29 @@ interface DataStore : EventTarget { [GetterThrows] readonly attribute boolean readOnly; - // Promise [Throws] - Promise get(DataStoreKey... id); + Promise get(DataStoreKey... id); - // Promise [Throws] - Promise put(any obj, DataStoreKey id, optional DOMString revisionId = ""); + Promise put(any obj, DataStoreKey id, optional DOMString revisionId = ""); - // Promise [Throws] - Promise add(any obj, optional DataStoreKey id, - optional DOMString revisionId = ""); + Promise add(any obj, optional DataStoreKey id, + optional DOMString revisionId = ""); - // Promise [Throws] - Promise remove(DataStoreKey id, optional DOMString revisionId = ""); + Promise remove(DataStoreKey id, optional DOMString revisionId = ""); - // Promise [Throws] - Promise clear(optional DOMString revisionId = ""); + Promise clear(optional DOMString revisionId = ""); [GetterThrows] readonly attribute DOMString revisionId; attribute EventHandler onchange; - // Promise [Throws] - Promise getLength(); + Promise getLength(); [NewObject, Throws] DataStoreCursor sync(optional DOMString revisionId = ""); @@ -78,9 +72,8 @@ interface DataStoreCursor { [GetterThrows] readonly attribute DataStore store; - // Promise [Throws] - Promise next(); + Promise next(); [Throws] void close(); diff --git a/dom/webidl/DataStoreImpl.webidl b/dom/webidl/DataStoreImpl.webidl index 7cc634e75948..564f4ff99771 100644 --- a/dom/webidl/DataStoreImpl.webidl +++ b/dom/webidl/DataStoreImpl.webidl @@ -24,26 +24,20 @@ interface DataStoreImpl { // is readOnly a F(current_app, datastore) function? yes readonly attribute boolean readOnly; - // Promise - Promise get(DataStoreKey... id); + Promise get(DataStoreKey... id); - // Promise - Promise put(any obj, DataStoreKey id, optional DOMString revisionId = ""); + Promise put(any obj, DataStoreKey id, optional DOMString revisionId = ""); - // Promise - Promise add(any obj, optional DataStoreKey id, - optional DOMString revisionId = ""); + Promise add(any obj, optional DataStoreKey id, + optional DOMString revisionId = ""); - // Promise - Promise remove(DataStoreKey id, optional DOMString revisionId = ""); + Promise remove(DataStoreKey id, optional DOMString revisionId = ""); - // Promise - Promise clear(optional DOMString revisionId = ""); + Promise clear(optional DOMString revisionId = ""); readonly attribute DOMString revisionId; - // Promise - Promise getLength(); + Promise getLength(); [NewObject] DataStoreCursor sync(optional DOMString revisionId = ""); @@ -61,8 +55,7 @@ interface DataStoreCursorImpl { // the DataStore readonly attribute DataStore store; - // Promise - Promise next(); + Promise next(); void close(); }; diff --git a/dom/webidl/DeviceStorage.webidl b/dom/webidl/DeviceStorage.webidl index 7a8a98fa73b6..4c4c32afa61d 100644 --- a/dom/webidl/DeviceStorage.webidl +++ b/dom/webidl/DeviceStorage.webidl @@ -83,5 +83,6 @@ interface DeviceStorage : EventTarget { readonly attribute boolean default; [NewObject, Throws] - Promise getRoot(); + // XXXbz what type does this really return? + Promise getRoot(); }; diff --git a/dom/webidl/Directory.webidl b/dom/webidl/Directory.webidl index ea5bd31c5c9d..eef3d5005f7b 100644 --- a/dom/webidl/Directory.webidl +++ b/dom/webidl/Directory.webidl @@ -38,8 +38,7 @@ interface Directory { * File object. Otherwise, rejected with a DOM error. */ [NewObject, Throws] - // Promise - Promise createFile(DOMString path, optional CreateFileOptions options); + Promise createFile(DOMString path, optional CreateFileOptions options); /* * Creates a descendent directory. This method will create any intermediate @@ -51,8 +50,7 @@ interface Directory { * Directory object. Otherwise, rejected with a DOM error. */ [NewObject, Throws] - // Promise - Promise createDirectory(DOMString path); + Promise createDirectory(DOMString path); /* * Gets a descendent file or directory with the given path. @@ -63,8 +61,7 @@ interface Directory { * rejected with a DOM error. */ [NewObject, Throws] - // Promise<(File or Directory)> - Promise get(DOMString path); + Promise<(File or Directory)> get(DOMString path); /* * Deletes a file or an empty directory. The target must be a descendent of @@ -78,8 +75,7 @@ interface Directory { * and was successfully deleted, the promise is resolved with boolean true. */ [NewObject, Throws] - // Promise - Promise remove((DOMString or File or Directory) path); + Promise remove((DOMString or File or Directory) path); /* * Deletes a file or a directory recursively. The target should be a @@ -93,8 +89,7 @@ interface Directory { * deleted, the promise is resolved with boolean true. */ [NewObject, Throws] - // Promise - Promise removeDeep((DOMString or File or Directory) path); + Promise removeDeep((DOMString or File or Directory) path); }; enum CreateIfExistsMode { "replace", "fail" }; diff --git a/dom/webidl/Downloads.webidl b/dom/webidl/Downloads.webidl index 306f1e30c57a..bedb76c4131e 100644 --- a/dom/webidl/Downloads.webidl +++ b/dom/webidl/Downloads.webidl @@ -29,14 +29,15 @@ enum DownloadState { interface DOMDownloadManager : EventTarget { // This promise returns an array of downloads with all the current // download objects. - Promise getDownloads(); + Promise> getDownloads(); // Removes one download from the downloads set. Returns a promise resolved // with the finalized download. - Promise remove(DOMDownload download); + Promise remove(DOMDownload download); - // Removes all the completed downloads from the set. - Promise clearAllDone(); + // Removes all the completed downloads from the set. Returns an + // array of the completed downloads that were removed. + Promise> clearAllDone(); // Fires when a new download starts. attribute EventHandler ondownloadstart; @@ -84,11 +85,11 @@ interface DOMDownload : EventTarget { readonly attribute DOMError? error; // Pauses the download. - Promise pause(); + Promise pause(); // Resumes the download. This resolves only once the download has // succeeded. - Promise resume(); + Promise resume(); // This event is triggered anytime a property of the object changes: // - when the transfer progresses, updating currentBytes. diff --git a/dom/webidl/HTMLMediaElement.webidl b/dom/webidl/HTMLMediaElement.webidl index c4511bb5fa68..35923fdec2a7 100644 --- a/dom/webidl/HTMLMediaElement.webidl +++ b/dom/webidl/HTMLMediaElement.webidl @@ -150,9 +150,9 @@ partial interface HTMLMediaElement { [Pref="media.eme.enabled"] readonly attribute MediaKeys? mediaKeys; - // Promise + // void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457 [Pref="media.eme.enabled", Throws, NewObject] - Promise setMediaKeys(MediaKeys? mediaKeys); + Promise setMediaKeys(MediaKeys? mediaKeys); [Pref="media.eme.enabled"] attribute EventHandler onneedkey; diff --git a/dom/webidl/InputMethod.webidl b/dom/webidl/InputMethod.webidl index bb5b5aedec20..b18c082a700c 100644 --- a/dom/webidl/InputMethod.webidl +++ b/dom/webidl/InputMethod.webidl @@ -113,7 +113,7 @@ interface MozInputContext: EventTarget { * Get the whole text content of the input field. * @return DOMString */ - Promise getText(optional long offset, optional long length); + Promise getText(optional long offset, optional long length); // The start and stop position of the selection. readonly attribute long selectionStart; readonly attribute long selectionEnd; @@ -134,7 +134,7 @@ interface MozInputContext: EventTarget { * * @return boolean */ - Promise setSelectionRange(long start, long length); + Promise setSelectionRange(long start, long length); /* User moves the cursor, or changes the selection with other means. If the text around * cursor has changed, but the cursor has not been moved, the IME won't get notification. @@ -150,7 +150,7 @@ interface MozInputContext: EventTarget { * @param length The length of text to replace. Defaults to 0. * @return boolean */ - Promise replaceSurroundingText(DOMString text, optional long offset, optional long length); + Promise replaceSurroundingText(DOMString text, optional long offset, optional long length); /* * @@ -160,7 +160,7 @@ interface MozInputContext: EventTarget { * TODO: maybe updateSurroundingText(DOMString beforeText, DOMString afterText); ? * @return boolean */ - Promise deleteSurroundingText(long offset, long length); + Promise deleteSurroundingText(long offset, long length); /* * Notifies when the text around the cursor is changed, due to either text @@ -187,7 +187,7 @@ interface MozInputContext: EventTarget { * parameter repeat to true and invoke sendKey n-1 times, and then set * repeat to false in the last invoke. */ - Promise sendKey(long keyCode, long charCode, long modifiers, optional boolean repeat); + Promise sendKey(long keyCode, long charCode, long modifiers, optional boolean repeat); /* * Set current composing text. This method will start composition or update @@ -216,8 +216,9 @@ interface MozInputContext: EventTarget { * To finish composition and commit text to current input field, an IME * should call |endComposition|. */ - Promise setComposition(DOMString text, optional long cursor, - optional sequence clauses); + // XXXbz what is this promise resolved with? + Promise setComposition(DOMString text, optional long cursor, + optional sequence clauses); /* * End composition, clear the composing text and commit given text to @@ -232,7 +233,8 @@ interface MozInputContext: EventTarget { * |replaceSurroundingText|, |deleteSurroundingText|, user moving the * cursor, changing the focus, etc. */ - Promise endComposition(optional DOMString text); + // XXXbz what is this promise resolved with? + Promise endComposition(optional DOMString text); }; enum CompositionClauseSelectionType { diff --git a/dom/webidl/InstallPhaseEvent.webidl b/dom/webidl/InstallPhaseEvent.webidl index 04337749eba3..f79aafe3c4dd 100644 --- a/dom/webidl/InstallPhaseEvent.webidl +++ b/dom/webidl/InstallPhaseEvent.webidl @@ -13,5 +13,5 @@ Func="mozilla::dom::workers::ServiceWorkerEventsVisible"] interface InstallPhaseEvent : Event { // https://github.com/slightlyoff/ServiceWorker/issues/261 - void waitUntil(Promise p); + void waitUntil(Promise p); }; diff --git a/dom/webidl/MediaKeySession.webidl b/dom/webidl/MediaKeySession.webidl index 03c25243e6c7..ba4016c324ad 100644 --- a/dom/webidl/MediaKeySession.webidl +++ b/dom/webidl/MediaKeySession.webidl @@ -25,19 +25,19 @@ interface MediaKeySession : EventTarget { readonly attribute unrestricted double expiration; - // Promise - readonly attribute Promise closed; + // void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457 + readonly attribute Promise closed; // session operations - //Promise + // void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457 [NewObject, Throws] - Promise update(Uint8Array response); + Promise update(Uint8Array response); - // Promise + // void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457 [NewObject, Throws] - Promise close(); + Promise close(); - // Promise + // void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457 [NewObject, Throws] - Promise remove(); + Promise remove(); }; diff --git a/dom/webidl/MediaKeys.webidl b/dom/webidl/MediaKeys.webidl index d1cb0e656c35..79cb3dcce249 100644 --- a/dom/webidl/MediaKeys.webidl +++ b/dom/webidl/MediaKeys.webidl @@ -17,21 +17,18 @@ enum SessionType { "temporary", "persistent" }; interface MediaKeys { readonly attribute DOMString keySystem; - // Promise [NewObject, Throws] - Promise createSession(DOMString initDataType, Uint8Array initData, optional SessionType sessionType = "temporary"); + Promise createSession(DOMString initDataType, Uint8Array initData, optional SessionType sessionType = "temporary"); - // Promise [NewObject, Throws] - Promise loadSession(DOMString sessionId); + Promise loadSession(DOMString sessionId); - // Promise + // void, not any: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26457 [NewObject, Throws] - Promise setServerCertificate(Uint8Array serverCertificate); + Promise setServerCertificate(Uint8Array serverCertificate); - // Promise [Throws,NewObject] - static Promise create(DOMString keySystem); + static Promise create(DOMString keySystem); static IsTypeSupportedResult isTypeSupported(DOMString keySystem, optional DOMString initDataType, optional DOMString contentType, optional DOMString capability); }; diff --git a/dom/webidl/MozSelfSupport.webidl b/dom/webidl/MozSelfSupport.webidl index ab89958cb1fe..406c5cbf3eff 100644 --- a/dom/webidl/MozSelfSupport.webidl +++ b/dom/webidl/MozSelfSupport.webidl @@ -37,5 +37,5 @@ interface MozSelfSupportImpl * @return Promise * Resolved when the FHR payload data has been collected. */ - Promise getHealthReportPayload(); + Promise getHealthReportPayload(); }; diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index c3322db96725..99e0c7abf285 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -84,7 +84,7 @@ interface NavigatorStorageUtils { [NoInterfaceObject] interface NavigatorFeatures { [CheckPermissions="feature-detection", Throws] - Promise getFeature(DOMString name); + Promise getFeature(DOMString name); }; // Things that definitely need to be in the spec and and are not for some @@ -123,7 +123,8 @@ Navigator implements NavigatorBattery; [NoInterfaceObject] interface NavigatorDataStore { [Throws, NewObject, Func="Navigator::HasDataStoreSupport"] - Promise getDataStores(DOMString name, optional DOMString? owner = null); + Promise> getDataStores(DOMString name, + optional DOMString? owner = null); }; Navigator implements NavigatorDataStore; @@ -161,8 +162,9 @@ interface NavigatorMobileId { // Ideally we would use [CheckPermissions] here, but the "mobileid" // permission is set to PROMPT_ACTION and [CheckPermissions] only checks // for ALLOW_ACTION. + // XXXbz what is this promise resolved with? [Throws, NewObject, Func="Navigator::HasMobileIdSupport"] - Promise getMobileIdAssertion(optional MobileIdOptions options); + Promise getMobileIdAssertion(optional MobileIdOptions options); }; Navigator implements NavigatorMobileId; #endif // MOZ_B2G diff --git a/dom/webidl/Notification.webidl b/dom/webidl/Notification.webidl index 628fb9e5878b..e5c071fbb110 100644 --- a/dom/webidl/Notification.webidl +++ b/dom/webidl/Notification.webidl @@ -21,7 +21,7 @@ interface Notification : EventTarget { static void requestPermission(optional NotificationPermissionCallback permissionCallback); [Throws] - static Promise get(optional GetNotificationOptions filter); + static Promise> get(optional GetNotificationOptions filter); attribute EventHandler onclick; diff --git a/dom/webidl/Promise.webidl b/dom/webidl/Promise.webidl index df7109b90084..0786ba2bd166 100644 --- a/dom/webidl/Promise.webidl +++ b/dom/webidl/Promise.webidl @@ -17,7 +17,8 @@ callback AnyCallback = any (any value); // REMOVE THE RELEVANT ENTRY FROM test_interfaces.html WHEN THIS IS IMPLEMENTED IN JS. [Constructor(PromiseInit init)] -interface Promise { +// Need to escape "Promise" so it's treated as an identifier. +interface _Promise { // TODO bug 875289 - static Promise fulfill(any value); // Disable the static methods when the interface object is supposed to be @@ -26,22 +27,22 @@ interface Promise { // Promise object in this scope without having resolved the interface object // first. [NewObject, Throws] - static Promise resolve(optional any value); + static Promise resolve(optional any value); [NewObject, Throws] - static Promise reject(optional any value); + static Promise reject(optional any value); // The [TreatNonCallableAsNull] annotation is required since then() should do // nothing instead of throwing errors when non-callable arguments are passed. [NewObject, Throws] - Promise then([TreatNonCallableAsNull] optional AnyCallback? fulfillCallback = null, - [TreatNonCallableAsNull] optional AnyCallback? rejectCallback = null); + Promise then([TreatNonCallableAsNull] optional AnyCallback? fulfillCallback = null, + [TreatNonCallableAsNull] optional AnyCallback? rejectCallback = null); [NewObject, Throws] - Promise catch([TreatNonCallableAsNull] optional AnyCallback? rejectCallback = null); + Promise catch([TreatNonCallableAsNull] optional AnyCallback? rejectCallback = null); [NewObject, Throws] - static Promise all(sequence iterable); + static Promise all(sequence iterable); [NewObject, Throws] - static Promise race(sequence iterable); + static Promise race(sequence iterable); }; diff --git a/dom/webidl/PromiseDebugging.webidl b/dom/webidl/PromiseDebugging.webidl index 0de6e30fa43d..7dc6110d631e 100644 --- a/dom/webidl/PromiseDebugging.webidl +++ b/dom/webidl/PromiseDebugging.webidl @@ -16,5 +16,5 @@ enum PromiseDebuggingState { "pending", "fulfilled", "rejected" }; [ChromeOnly] interface PromiseDebugging { - static PromiseDebuggingStateHolder getState(Promise p); + static PromiseDebuggingStateHolder getState(Promise p); }; diff --git a/dom/webidl/ResourceStatsManager.webidl b/dom/webidl/ResourceStatsManager.webidl index 394aa3a7dfb6..d7facef475a1 100644 --- a/dom/webidl/ResourceStatsManager.webidl +++ b/dom/webidl/ResourceStatsManager.webidl @@ -132,9 +132,9 @@ interface ResourceStatsManager * * If success, the fulfillment value is a ResourceStats object. */ - Promise getStats(optional ResourceStatsOptions statsOptions, - [EnforceRange] optional DOMTimeStamp? start = null, - [EnforceRange] optional DOMTimeStamp? end = null); + Promise getStats(optional ResourceStatsOptions statsOptions, + [EnforceRange] optional DOMTimeStamp? start = null, + [EnforceRange] optional DOMTimeStamp? end = null); /** * Clear resource statistics stored in database. @@ -145,14 +145,16 @@ interface ResourceStatsManager * If |start| is null or undefined, delete the stats since measurements. * If |end| is null or undefined. delete the stats until the current time. */ - Promise clearStats(optional ResourceStatsOptions statsOptions, - [EnforceRange] optional DOMTimeStamp? start = null, - [EnforceRange] optional DOMTimeStamp? end = null); + // XXXbz What is this promise resolved with? + Promise clearStats(optional ResourceStatsOptions statsOptions, + [EnforceRange] optional DOMTimeStamp? start = null, + [EnforceRange] optional DOMTimeStamp? end = null); /** * Clear all resource statistics stored in database. */ - Promise clearAllStats(); + // XXXbz What is this promise resolved with? + Promise clearAllStats(); /** * Install an alarm to monitor resource usage. @@ -167,9 +169,9 @@ interface ResourceStatsManager * * If success, the fulfillment value is an alarm ID. */ - Promise addAlarm([EnforceRange] unsigned long long threshold, - optional ResourceStatsOptions statsOptions, - optional ResourceStatsAlarmOptions alarmOptions); + Promise addAlarm([EnforceRange] unsigned long long threshold, + optional ResourceStatsOptions statsOptions, + optional ResourceStatsAlarmOptions alarmOptions); /** * Obtain alarms. @@ -180,26 +182,28 @@ interface ResourceStatsManager * * If success, the fulfillment value is an array of ResourceStatsAlarm. */ - Promise getAlarms(optional ResourceStatsOptions statsOptions); + Promise> getAlarms(optional ResourceStatsOptions statsOptions); /** * Remove the specified alarm. * * |alarmId| specifies the alarm to be removed. */ - Promise removeAlarm([EnforceRange] unsigned long alarmId); + // XXXbz What is this promise resolved with? + Promise removeAlarm([EnforceRange] unsigned long alarmId); /** * Remove all alarms. */ - Promise removeAllAlarms(); + // XXXbz What is this promise resolved with? + Promise removeAllAlarms(); /** * Enumerate components that have stored statistics in database. * * If success, the fulfillment value is an array of DOMString. */ - Promise getAvailableComponents(); + Promise> getAvailableComponents(); /** * Return supporting resource statistics, i.e. ["Network", "Power"] diff --git a/dom/webidl/ServiceWorkerContainer.webidl b/dom/webidl/ServiceWorkerContainer.webidl index e99bdce472de..dd8dd7f439e2 100644 --- a/dom/webidl/ServiceWorkerContainer.webidl +++ b/dom/webidl/ServiceWorkerContainer.webidl @@ -18,21 +18,17 @@ interface ServiceWorkerContainer { [Unforgeable] readonly attribute ServiceWorker? active; [Unforgeable] readonly attribute ServiceWorker? controller; - // Promise [Throws] - readonly attribute Promise ready; + readonly attribute Promise ready; - // Promise?> [Throws] - Promise getAll(); + Promise getAll(); - // Promise [Throws] - Promise register(DOMString url, optional RegistrationOptionList options); + Promise register(DOMString url, optional RegistrationOptionList options); - // Promise [Throws] - Promise unregister(DOMString? scope); + Promise unregister(DOMString? scope); attribute EventHandler onupdatefound; attribute EventHandler oncontrollerchange; @@ -44,7 +40,7 @@ interface ServiceWorkerContainer { [ChromeOnly, Pref="dom.serviceWorkers.testing.enabled"] partial interface ServiceWorkerContainer { [Throws] - Promise clearAllServiceWorkerData(); + Promise clearAllServiceWorkerData(); [Throws] DOMString getScopeForUrl(DOMString url); diff --git a/dom/webidl/SubtleCrypto.webidl b/dom/webidl/SubtleCrypto.webidl index 3b2d27e89166..9e9804520de6 100644 --- a/dom/webidl/SubtleCrypto.webidl +++ b/dom/webidl/SubtleCrypto.webidl @@ -169,63 +169,63 @@ typedef (object or DOMString) AlgorithmIdentifier; [Pref="dom.webcrypto.enabled"] interface SubtleCrypto { [Throws] - Promise encrypt(AlgorithmIdentifier algorithm, - CryptoKey key, - CryptoOperationData data); + Promise encrypt(AlgorithmIdentifier algorithm, + CryptoKey key, + CryptoOperationData data); [Throws] - Promise decrypt(AlgorithmIdentifier algorithm, - CryptoKey key, - CryptoOperationData data); + Promise decrypt(AlgorithmIdentifier algorithm, + CryptoKey key, + CryptoOperationData data); [Throws] - Promise sign(AlgorithmIdentifier algorithm, - CryptoKey key, - CryptoOperationData data); + Promise sign(AlgorithmIdentifier algorithm, + CryptoKey key, + CryptoOperationData data); [Throws] - Promise verify(AlgorithmIdentifier algorithm, - CryptoKey key, - CryptoOperationData signature, - CryptoOperationData data); + Promise verify(AlgorithmIdentifier algorithm, + CryptoKey key, + CryptoOperationData signature, + CryptoOperationData data); [Throws] - Promise digest(AlgorithmIdentifier algorithm, - CryptoOperationData data); + Promise digest(AlgorithmIdentifier algorithm, + CryptoOperationData data); [Throws] - Promise generateKey(AlgorithmIdentifier algorithm, - boolean extractable, - sequence keyUsages ); + Promise generateKey(AlgorithmIdentifier algorithm, + boolean extractable, + sequence keyUsages ); [Throws] - Promise deriveKey(AlgorithmIdentifier algorithm, - CryptoKey baseKey, - AlgorithmIdentifier derivedKeyType, - boolean extractable, - sequence keyUsages ); + Promise deriveKey(AlgorithmIdentifier algorithm, + CryptoKey baseKey, + AlgorithmIdentifier derivedKeyType, + boolean extractable, + sequence keyUsages ); [Throws] - Promise deriveBits(AlgorithmIdentifier algorithm, - CryptoKey baseKey, - unsigned long length); + Promise deriveBits(AlgorithmIdentifier algorithm, + CryptoKey baseKey, + unsigned long length); [Throws] - Promise importKey(KeyFormat format, - object keyData, - AlgorithmIdentifier algorithm, - boolean extractable, - sequence keyUsages ); + Promise importKey(KeyFormat format, + object keyData, + AlgorithmIdentifier algorithm, + boolean extractable, + sequence keyUsages ); [Throws] - Promise exportKey(KeyFormat format, CryptoKey key); + Promise exportKey(KeyFormat format, CryptoKey key); [Throws] - Promise wrapKey(KeyFormat format, - CryptoKey key, - CryptoKey wrappingKey, - AlgorithmIdentifier wrapAlgorithm); + Promise wrapKey(KeyFormat format, + CryptoKey key, + CryptoKey wrappingKey, + AlgorithmIdentifier wrapAlgorithm); [Throws] - Promise unwrapKey(KeyFormat format, - CryptoOperationData wrappedKey, - CryptoKey unwrappingKey, - AlgorithmIdentifier unwrapAlgorithm, - AlgorithmIdentifier unwrappedKeyAlgorithm, - boolean extractable, - sequence keyUsages ); + Promise unwrapKey(KeyFormat format, + CryptoOperationData wrappedKey, + CryptoKey unwrappingKey, + AlgorithmIdentifier unwrapAlgorithm, + AlgorithmIdentifier unwrappedKeyAlgorithm, + boolean extractable, + sequence keyUsages ); }; diff --git a/dom/webidl/Telephony.webidl b/dom/webidl/Telephony.webidl index 008f2b7cee84..034dc86639cd 100644 --- a/dom/webidl/Telephony.webidl +++ b/dom/webidl/Telephony.webidl @@ -16,13 +16,11 @@ interface Telephony : EventTarget { * |navigator.mozMobileConnections.length|. */ - // Promise [Throws] - Promise dial(DOMString number, optional unsigned long serviceId); + Promise dial(DOMString number, optional unsigned long serviceId); - // Promise [Throws] - Promise dialEmergency(DOMString number, optional unsigned long serviceId); + Promise dialEmergency(DOMString number, optional unsigned long serviceId); [Throws] void startTone(DOMString tone, optional unsigned long serviceId);