mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
unregister components while exiting
This commit is contained in:
parent
c9229f3f99
commit
5600a1dca1
5 changed files with 44 additions and 0 deletions
|
@ -105,3 +105,30 @@ fn test_hang_monitoring() {
|
|||
// Still no new alerts because the hang monitor has shut-down already.
|
||||
assert!(background_hang_monitor_receiver.try_recv().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hang_monitoring_unregister() {
|
||||
let (background_hang_monitor_ipc_sender, background_hang_monitor_receiver) =
|
||||
ipc::channel().expect("ipc channel failure");
|
||||
|
||||
let background_hang_monitor_register =
|
||||
HangMonitorRegister::init(background_hang_monitor_ipc_sender.clone());
|
||||
let background_hang_monitor = background_hang_monitor_register.register_component(
|
||||
MonitoredComponentId(TEST_PIPELINE_ID, MonitoredComponentType::Script),
|
||||
Duration::from_millis(10),
|
||||
Duration::from_millis(1000),
|
||||
);
|
||||
|
||||
// Start an activity.
|
||||
let hang_annotation = HangAnnotation::Script(ScriptHangAnnotation::AttachLayout);
|
||||
background_hang_monitor.notify_activity(hang_annotation);
|
||||
|
||||
// Unregister the component.
|
||||
background_hang_monitor.unregister();
|
||||
|
||||
// Sleep until the "transient" timeout has been reached.
|
||||
thread::sleep(Duration::from_millis(10));
|
||||
|
||||
// No new alert yet
|
||||
assert!(background_hang_monitor_receiver.try_recv().is_err());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue