Implement binding support for returning and accepting Promises in WebIDL.

This commit is contained in:
Josh Matthews 2016-06-21 19:35:36 -04:00
parent 73b2963509
commit a1091772ec
12 changed files with 217 additions and 20 deletions

View file

@ -18,6 +18,7 @@ use dom::window::{self, ScriptHelpers};
use dom::workerglobalscope::WorkerGlobalScope;
use ipc_channel::ipc::IpcSender;
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
use js::glue::{IsWrapper, UnwrapObject};
use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment};
use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue};
use js::jsapi::HandleValue;
@ -356,3 +357,13 @@ pub unsafe fn global_root_from_context(cx: *mut JSContext) -> GlobalRoot {
let global = CurrentGlobalOrNull(cx);
global_root_from_global(global)
}
/// Returns the global object of the realm that the given JS object was created in,
/// after unwrapping any wrappers.
pub unsafe fn global_root_from_object_maybe_wrapped(mut obj: *mut JSObject) -> GlobalRoot {
if IsWrapper(obj) {
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
assert!(!obj.is_null());
}
global_root_from_object(obj)
}