@@ -16,7 +16,7 @@ pub use crate::util::{inner_u32, inner_u64};
16
16
#[ cfg( not( all( target_arch = "wasm32" , any( target_os = "unknown" , target_os = "none" ) ) ) ) ]
17
17
compile_error ! ( "`wasm_js` backend can be enabled only for OS-less WASM targets!" ) ;
18
18
19
- use js_sys:: { JsString , Object , SharedArrayBuffer , Uint8Array , WebAssembly :: Memory } ;
19
+ use js_sys:: { JsString , Object , Uint8Array , WebAssembly :: Memory } ;
20
20
use wasm_bindgen:: { prelude:: wasm_bindgen, JsCast , JsValue } ;
21
21
22
22
// Size of our temporary Uint8Array buffer used with WebCrypto methods
@@ -43,19 +43,10 @@ pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
43
43
// `SharedArrayBuffer` is only available with COOP & COEP. But even without its
44
44
// possible to create a shared `WebAssembly.Memory`, so we check for that via
45
45
// the constructor name.
46
- //
47
- // Keep in mind that `crossOriginIsolated` is not available on Node.js, in
48
- // which case we can still use `instanceof` because `SharedArrayBuffer` is
49
- // always available.
50
- let shared = match CROSS_ORIGIN_ISOLATED . with ( Option :: clone) {
51
- Some ( true ) | None => buffer. is_instance_of :: < SharedArrayBuffer > ( ) ,
52
- Some ( false ) => {
53
- let constructor_name = Object :: from ( buffer) . constructor ( ) . name ( ) ;
54
- SHARED_ARRAY_BUFFER_NAME . with ( |name| & constructor_name == name)
55
- }
56
- } ;
57
-
58
- let val = if shared {
46
+ let constructor_name = Object :: from ( buffer) . constructor ( ) . name ( ) ;
47
+ let val = if SHARED_ARRAY_BUFFER_NAME
48
+ . with ( |sab_name| & constructor_name == sab_name)
49
+ {
59
50
MEMORY_KIND_SHARED
60
51
} else {
61
52
MEMORY_KIND_NOT_SHARED
@@ -115,9 +106,6 @@ extern "C" {
115
106
fn get_random_values ( this : & Crypto , buf : & Uint8Array ) -> Result < ( ) , JsValue > ;
116
107
#[ wasm_bindgen( method, js_name = getRandomValues, catch) ]
117
108
fn get_random_values_ref ( this : & Crypto , buf : & mut [ u8 ] ) -> Result < ( ) , JsValue > ;
118
- // Returns the [`crossOriginIsolated`](https://developer.mozilla.org/en-US/docs/Web/API/crossOriginIsolated) global property.
119
- #[ wasm_bindgen( thread_local_v2, js_namespace = globalThis, js_name = crossOriginIsolated) ]
120
- static CROSS_ORIGIN_ISOLATED : Option < bool > ;
121
109
#[ wasm_bindgen( thread_local_v2, static_string) ]
122
110
static SHARED_ARRAY_BUFFER_NAME : JsString = "SharedArrayBuffer" ;
123
111
}
0 commit comments