added JSPrincipal bindings

This commit is contained in:
ddh 2017-04-17 20:33:33 +01:00
parent dc594face8
commit ef053dbfa0
3 changed files with 32 additions and 3 deletions

View file

@ -18,6 +18,7 @@ use js;
use js::JS_CALLEE;
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
use js::glue::{GetCrossCompartmentWrapper, WrapperNew};
use js::glue::getPrincipalOrigin;
use js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO, RUST_JSID_IS_INT, RUST_JSID_IS_STRING};
use js::glue::{RUST_JSID_TO_INT, RUST_JSID_TO_STRING, UnwrapObject};
use js::jsapi::{CallArgs, DOMCallbacks, GetGlobalForObjectCrossCompartment};
@ -29,9 +30,11 @@ use js::jsapi::{JS_GetProperty, JS_GetPrototype, JS_GetReservedSlot, JS_HasPrope
use js::jsapi::{JS_HasPropertyById, JS_IsExceptionPending, JS_IsGlobalObject};
use js::jsapi::{JS_ResolveStandardClass, JS_SetProperty, ToWindowProxyIfWindow};
use js::jsapi::{JS_StringHasLatin1Chars, MutableHandleValue, ObjectOpResult};
use js::jsapi::JSPrincipals;
use js::jsval::{JSVal, UndefinedValue};
use js::rust::{GCMethods, ToString, get_object_class, is_dom_class};
use libc;
use servo_url::MutableOrigin;
use std::ffi::CString;
use std::os::raw::{c_char, c_void};
use std::ptr;
@ -47,6 +50,15 @@ impl HeapSizeOf for WindowProxyHandler {
}
}
struct ServoJSPrincipal(*mut JSPrincipals);
impl ServoJSPrincipal {
pub unsafe fn origin(&self) -> MutableOrigin {
let origin = getPrincipalOrigin(self.0) as *mut MutableOrigin;
(*origin).clone()
}
}
#[derive(JSTraceable, HeapSizeOf)]
/// Static data associated with a global object.
pub struct GlobalStaticData {