Add a simple API to reject promises with DOM error values.

This commit is contained in:
Josh Matthews 2016-09-06 19:58:26 -04:00
parent ae81ab3972
commit 27d44c8d10
5 changed files with 35 additions and 2 deletions

View file

@ -20,7 +20,7 @@ use dom::bindings::codegen::UnionTypes::{EventOrUSVString, HTMLElementOrLong, Lo
use dom::bindings::codegen::UnionTypes::{HTMLElementOrUnsignedLongOrStringOrBoolean, LongSequenceOrBoolean};
use dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence, StringSequenceOrUnsignedLong};
use dom::bindings::codegen::UnionTypes::{StringOrUnsignedLong, StringOrBoolean, UnsignedLongOrBoolean};
use dom::bindings::error::Fallible;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::global::{GlobalRef, global_root_from_context};
use dom::bindings::js::Root;
use dom::bindings::mozmap::MozMap;
@ -668,6 +668,10 @@ impl TestBindingMethods for TestBinding {
p.maybe_reject(cx, v);
}
fn PromiseRejectWithTypeError(&self, p: &Promise, s: USVString) {
p.maybe_reject_error(self.global().r().get_cx(), Error::Type(s.0));
}
#[allow(unrooted_must_root)]
fn PromiseNativeHandler(&self,
resolve: Option<Rc<SimpleCallback>>,