Move unsafe to the wrap method for global objects (#38896)

The method now doesn't need unsafe in its signature because it no longer
accepts unsafe pointers as arguments. We move the unsafe marker to the
method itself.

Testing: I opened the browser and went to google.com; I ran some WPT
(IndexedDB) tests.
Fixes: #38361

---------

Signed-off-by: criskell <96352451+criskell@users.noreply.github.com>
This commit is contained in:
criskell 2025-08-25 19:02:55 -03:00 committed by GitHub
parent b9dc228e51
commit 9082217272
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 41 additions and 75 deletions

View file

@ -12,7 +12,6 @@ use embedder_traits::JavaScriptEvaluationError;
use embedder_traits::resources::{self, Resource};
use ipc_channel::ipc::IpcSender;
use js::jsval::UndefinedValue;
use js::rust::Runtime;
use js::rust::wrappers::JS_DefineDebuggerObject;
use net_traits::ResourceThreads;
use profile_traits::{mem, time};
@ -61,7 +60,6 @@ impl DebuggerGlobalScope {
/// those threads cant generate pipeline ids, and they only contain one debuggee from one pipeline
#[allow(unsafe_code, clippy::too_many_arguments)]
pub(crate) fn new(
runtime: &Runtime,
debugger_pipeline_id: PipelineId,
script_to_devtools_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
devtools_to_script_sender: IpcSender<DevtoolScriptControlMsg>,
@ -93,12 +91,8 @@ impl DebuggerGlobalScope {
devtools_to_script_sender,
get_possible_breakpoints_result_sender: RefCell::new(None),
});
let global = unsafe {
DebuggerGlobalScopeBinding::Wrap::<crate::DomTypeHolder>(
JSContext::from_ptr(runtime.cx()),
global,
)
};
let global =
DebuggerGlobalScopeBinding::Wrap::<crate::DomTypeHolder>(GlobalScope::get_cx(), global);
let realm = enter_realm(&*global);
define_all_exposed_interfaces(global.upcast(), InRealm::entered(&realm), can_gc);