michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: * michael@0: * The origin of this IDL file is michael@0: * http://dom.spec.whatwg.org/#promises michael@0: */ michael@0: michael@0: // TODO We use object instead Function. There is an open issue on WebIDL to michael@0: // have different types for "platform-provided function" and "user-provided michael@0: // function"; for now, we just use "object". michael@0: callback PromiseInit = void (object resolve, object reject); michael@0: michael@0: [TreatNonCallableAsNull] michael@0: callback AnyCallback = any (any value); michael@0: michael@0: // REMOVE THE RELEVANT ENTRY FROM test_interfaces.html WHEN THIS IS IMPLEMENTED IN JS. michael@0: [Constructor(PromiseInit init)] michael@0: interface Promise { michael@0: // TODO bug 875289 - static Promise fulfill(any value); michael@0: michael@0: // Disable the static methods when the interface object is supposed to be michael@0: // disabled, just in case some code decides to walk over to .constructor from michael@0: // the proto of a promise object or someone screws up and manages to create a michael@0: // Promise object in this scope without having resolved the interface object michael@0: // first. michael@0: [NewObject, Throws] michael@0: static Promise resolve(optional any value); michael@0: [NewObject, Throws] michael@0: static Promise reject(optional any value); michael@0: michael@0: // The [TreatNonCallableAsNull] annotation is required since then() should do michael@0: // nothing instead of throwing errors when non-callable arguments are passed. michael@0: [NewObject] michael@0: Promise then([TreatNonCallableAsNull] optional AnyCallback? fulfillCallback = null, michael@0: [TreatNonCallableAsNull] optional AnyCallback? rejectCallback = null); michael@0: michael@0: [NewObject] michael@0: Promise catch([TreatNonCallableAsNull] optional AnyCallback? rejectCallback = null); michael@0: michael@0: [NewObject, Throws] michael@0: static Promise all(sequence iterable); michael@0: michael@0: [NewObject, Throws] michael@0: static Promise race(sequence iterable); michael@0: };