Don't build testbinding-related code by default (#37034)

Disabling the TestBinding-related bindings and implementations saves 2mb
in a release build. Also, we lost the related test preferences when we
turned the layout-2020 tests on, so the tests have all been failing for
a long time.

Testing: Existing tests in CI.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-05-17 10:14:19 +02:00 committed by GitHub
parent 2eab9c6df1
commit a028291466
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 72 additions and 149 deletions

View file

@ -18,6 +18,7 @@ crown = ['js/crown']
debugmozjs = ['js/debugmozjs']
jitspew = ['js/jitspew']
profilemozjs = ['js/profilemozjs']
testbinding = ["script_bindings/testbinding"]
tracing = ["dep:tracing", "script_bindings/tracing"]
webgl_backtrace = ["canvas_traits/webgl_backtrace"]
js_backtrace = []

View file

@ -549,17 +549,29 @@ pub(crate) mod svgelement;
pub(crate) mod svggraphicselement;
pub(crate) mod svgimageelement;
pub(crate) mod svgsvgelement;
#[cfg(feature = "testbinding")]
pub(crate) mod testbinding;
#[cfg(feature = "testbinding")]
pub(crate) mod testbindingiterable;
#[cfg(feature = "testbinding")]
pub(crate) mod testbindingmaplikewithinterface;
#[cfg(feature = "testbinding")]
pub(crate) mod testbindingmaplikewithprimitive;
#[cfg(feature = "testbinding")]
pub(crate) mod testbindingpairiterable;
#[cfg(feature = "testbinding")]
pub(crate) mod testbindingproxy;
#[cfg(feature = "testbinding")]
pub(crate) mod testbindingsetlikewithinterface;
#[cfg(feature = "testbinding")]
pub(crate) mod testbindingsetlikewithprimitive;
#[cfg(feature = "testbinding")]
pub(crate) mod testns;
#[cfg(feature = "testbinding")]
pub(crate) mod testutils;
#[cfg(feature = "testbinding")]
pub(crate) mod testworklet;
#[cfg(feature = "testbinding")]
pub(crate) mod testworkletglobalscope;
pub(crate) mod text;
pub(crate) mod textcontrol;

View file

@ -43,6 +43,7 @@ use crate::dom::bindings::str::USVString;
use crate::dom::bindings::trace::{CustomTraceable, JSTraceable, RootedTraceableBox};
use crate::dom::globalscope::GlobalScope;
use crate::dom::promise::Promise;
#[cfg(feature = "testbinding")]
use crate::dom::testworkletglobalscope::TestWorkletTask;
use crate::dom::window::Window;
use crate::dom::workletglobalscope::{
@ -354,6 +355,7 @@ impl WorkletThreadPool {
}
/// For testing.
#[cfg(feature = "testbinding")]
pub(crate) fn test_worklet_lookup(&self, id: WorkletId, key: String) -> Option<String> {
let (sender, receiver) = unbounded();
let msg = WorkletData::Task(id, WorkletTask::Test(TestWorkletTask::Lookup(key, sender)));

View file

@ -26,6 +26,7 @@ use crate::dom::bindings::trace::CustomTraceable;
use crate::dom::bindings::utils::define_all_exposed_interfaces;
use crate::dom::globalscope::GlobalScope;
use crate::dom::paintworkletglobalscope::{PaintWorkletGlobalScope, PaintWorkletTask};
#[cfg(feature = "testbinding")]
use crate::dom::testworkletglobalscope::{TestWorkletGlobalScope, TestWorkletTask};
#[cfg(feature = "webgpu")]
use crate::dom::webgpu::identityhub::IdentityHub;
@ -60,6 +61,7 @@ impl WorkletGlobalScope {
init: &WorkletGlobalScopeInit,
) -> DomRoot<WorkletGlobalScope> {
let scope: DomRoot<WorkletGlobalScope> = match scope_type {
#[cfg(feature = "testbinding")]
WorkletGlobalScopeType::Test => DomRoot::upcast(TestWorkletGlobalScope::new(
runtime,
pipeline_id,
@ -163,6 +165,7 @@ impl WorkletGlobalScope {
/// Perform a worklet task
pub(crate) fn perform_a_worklet_task(&self, task: WorkletTask) {
match task {
#[cfg(feature = "testbinding")]
WorkletTask::Test(task) => match self.downcast::<TestWorkletGlobalScope>() {
Some(global) => global.perform_a_worklet_task(task),
None => warn!("This is not a test worklet."),
@ -203,6 +206,7 @@ pub(crate) struct WorkletGlobalScopeInit {
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf)]
pub(crate) enum WorkletGlobalScopeType {
/// A servo-specific testing worklet
#[cfg(feature = "testbinding")]
Test,
/// A paint worklet
Paint,
@ -210,6 +214,7 @@ pub(crate) enum WorkletGlobalScopeType {
/// A task which can be performed in the context of a worklet global.
pub(crate) enum WorkletTask {
#[cfg(feature = "testbinding")]
Test(TestWorkletTask),
Paint(PaintWorkletTask),
}

View file

@ -27,6 +27,7 @@ use crate::dom::bindings::str::DOMString;
use crate::dom::document::{FakeRequestAnimationFrameCallback, RefreshRedirectDue};
use crate::dom::eventsource::EventSourceTimeoutCallback;
use crate::dom::globalscope::GlobalScope;
#[cfg(feature = "testbinding")]
use crate::dom::testbinding::TestBindingCallback;
use crate::dom::types::{Window, WorkerGlobalScope};
use crate::dom::xmlhttprequest::XHRTimeoutCallback;
@ -78,6 +79,7 @@ pub(crate) enum OneshotTimerCallback {
XhrTimeout(XHRTimeoutCallback),
EventSourceTimeout(EventSourceTimeoutCallback),
JsTimer(JsTimerTask),
#[cfg(feature = "testbinding")]
TestBindingCallback(TestBindingCallback),
FakeRequestAnimationFrame(FakeRequestAnimationFrameCallback),
RefreshRedirectDue(RefreshRedirectDue),
@ -89,6 +91,7 @@ impl OneshotTimerCallback {
OneshotTimerCallback::XhrTimeout(callback) => callback.invoke(can_gc),
OneshotTimerCallback::EventSourceTimeout(callback) => callback.invoke(),
OneshotTimerCallback::JsTimer(task) => task.invoke(this, js_timers, can_gc),
#[cfg(feature = "testbinding")]
OneshotTimerCallback::TestBindingCallback(callback) => callback.invoke(),
OneshotTimerCallback::FakeRequestAnimationFrame(callback) => callback.invoke(can_gc),
OneshotTimerCallback::RefreshRedirectDue(callback) => callback.invoke(can_gc),

View file

@ -52,6 +52,7 @@ serde_json = { workspace = true }
[features]
bluetooth = []
testbinding = []
tracing = ["dep:tracing"]
webgpu = []
webxr = ["webxr-api"]

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

View file

@ -1,6 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
/*
* This IDL file was created to test the special operations (see
* https://heycam.github.io/webidl/#idl-special-operations) without converting

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// https://testutils.spec.whatwg.org/
[Exposed=(Window,Worker), Pref="dom_testutils_enabled"]

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// skip-unless CARGO_FEATURE_TESTBINDING
// This interface is entirely internal to Servo, and should not be accessible to
// web pages.

View file

@ -34,6 +34,7 @@ no-wgl = ["mozangle/egl", "mozangle/build_dlls", "surfman/sm-angle-default", "co
dynamic_freetype = ["webrender/dynamic_freetype"]
profilemozjs = ["script/profilemozjs"]
refcell_backtrace = ["script/refcell_backtrace"]
testbinding = ["script/testbinding"]
tracing = [
"dep:tracing",
"compositing/tracing",