mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add an inCompartments config for bindings
This commit is contained in:
parent
2181872973
commit
7dbff6efb7
7 changed files with 37 additions and 10 deletions
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm};
|
||||
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm, JSContext};
|
||||
|
||||
pub struct AlreadyInCompartment(());
|
||||
|
||||
|
@ -15,6 +15,13 @@ impl AlreadyInCompartment {
|
|||
}
|
||||
AlreadyInCompartment(())
|
||||
}
|
||||
|
||||
pub fn assert_for_cx(cx: *mut JSContext) -> AlreadyInCompartment {
|
||||
unsafe {
|
||||
assert!(!GetCurrentRealmOrNull(cx).is_null());
|
||||
}
|
||||
AlreadyInCompartment(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue