dom/webidl/Promise.webidl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 4 * You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 5 *
michael@0 6 * The origin of this IDL file is
michael@0 7 * http://dom.spec.whatwg.org/#promises
michael@0 8 */
michael@0 9
michael@0 10 // TODO We use object instead Function. There is an open issue on WebIDL to
michael@0 11 // have different types for "platform-provided function" and "user-provided
michael@0 12 // function"; for now, we just use "object".
michael@0 13 callback PromiseInit = void (object resolve, object reject);
michael@0 14
michael@0 15 [TreatNonCallableAsNull]
michael@0 16 callback AnyCallback = any (any value);
michael@0 17
michael@0 18 // REMOVE THE RELEVANT ENTRY FROM test_interfaces.html WHEN THIS IS IMPLEMENTED IN JS.
michael@0 19 [Constructor(PromiseInit init)]
michael@0 20 interface Promise {
michael@0 21 // TODO bug 875289 - static Promise fulfill(any value);
michael@0 22
michael@0 23 // Disable the static methods when the interface object is supposed to be
michael@0 24 // disabled, just in case some code decides to walk over to .constructor from
michael@0 25 // the proto of a promise object or someone screws up and manages to create a
michael@0 26 // Promise object in this scope without having resolved the interface object
michael@0 27 // first.
michael@0 28 [NewObject, Throws]
michael@0 29 static Promise resolve(optional any value);
michael@0 30 [NewObject, Throws]
michael@0 31 static Promise reject(optional any value);
michael@0 32
michael@0 33 // The [TreatNonCallableAsNull] annotation is required since then() should do
michael@0 34 // nothing instead of throwing errors when non-callable arguments are passed.
michael@0 35 [NewObject]
michael@0 36 Promise then([TreatNonCallableAsNull] optional AnyCallback? fulfillCallback = null,
michael@0 37 [TreatNonCallableAsNull] optional AnyCallback? rejectCallback = null);
michael@0 38
michael@0 39 [NewObject]
michael@0 40 Promise catch([TreatNonCallableAsNull] optional AnyCallback? rejectCallback = null);
michael@0 41
michael@0 42 [NewObject, Throws]
michael@0 43 static Promise all(sequence<any> iterable);
michael@0 44
michael@0 45 [NewObject, Throws]
michael@0 46 static Promise race(sequence<any> iterable);
michael@0 47 };

mercurial