script: Remove some proprietary Servo-only testing methods from Window (#42728)

These three methods date back from the very early history of Servo and
are no longer necessary:

1. `Window.debug`: `console.log` is a better replacement for this method
   now. A manual test that tests the very basics of JavaScript used
   this. This test is removed as well.
2. `Window.gc`: This can be replaced with `TestUtils.gc`, which is part
    of a W3C specification.
3. `Window.js_backtrace`: This method is moved to `ServoTestUtils`.

Testing: Tests are updated to reflect these changes.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson
2026-02-20 18:32:34 +01:00
committed by GitHub
parent f69ee078d2
commit e7ee1171d8
15 changed files with 41 additions and 82 deletions

View File

@@ -15,7 +15,6 @@ use std::sync::Arc;
use std::time::{Duration, Instant};
use app_units::Au;
use backtrace::Backtrace;
use base::cross_process_instant::CrossProcessInstant;
use base::generic_channel::{self, GenericCallback, GenericSender};
use base::id::{BrowsingContextId, PipelineId, WebViewId};
@@ -942,6 +941,13 @@ impl Window {
}),
}
}
#[expect(unsafe_code)]
pub(crate) fn gc(&self) {
unsafe {
JS_GC(*self.get_cx(), GCReason::API);
}
}
}
#[derive(Debug)]
@@ -1771,27 +1777,6 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
}
// check-tidy: no specs after this line
fn Debug(&self, message: DOMString) {
debug!("{}", message);
}
#[expect(unsafe_code)]
fn Gc(&self) {
unsafe {
JS_GC(*self.get_cx(), GCReason::API);
}
}
#[expect(unsafe_code)]
fn Js_backtrace(&self) {
unsafe {
println!("Current JS stack:");
dump_js_stack(*self.get_cx());
let rust_stack = Backtrace::new();
println!("Current Rust stack:\n{:?}", rust_stack);
}
}
fn WebdriverCallback(&self, realm: &mut CurrentRealm, value: HandleValue) {
let webdriver_script_sender = self.webdriver_script_chan.borrow_mut().take();
if let Some(webdriver_script_sender) = webdriver_script_sender {
@@ -3358,7 +3343,7 @@ impl Window {
// GC any unreachable objects generated by user script,
// or unattached DOM nodes. Attached DOM nodes can't be GCd yet,
// as the document might be reactivated later.
self.Gc();
self.gc();
}
pub(crate) fn resume(&self, can_gc: CanGc) {