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