Retire inactive windows without invoking stopped runtimes
Verify Tessera GUI / verify (push) Failing after 7m31s
Verify Tessera GUI / verify (push) Failing after 7m31s
This commit is contained in:
@@ -622,6 +622,17 @@ impl ReplSession {
|
||||
result
|
||||
}
|
||||
|
||||
pub fn retire_window(&mut self, id: u64) -> Result<()> {
|
||||
// This path is exclusively host cleanup after the domain has stopped.
|
||||
// No language functions, layout, paint or lifecycle hooks may run here.
|
||||
self.faulted = true;
|
||||
self.bridge.retire_window(&mut self.candidate.vm, id)?;
|
||||
self.documents.remove(&id);
|
||||
let _ = self.take_window_commands()?;
|
||||
self.bridge
|
||||
.reclaim(&mut self.candidate.vm, &mut self.candidate.roots)
|
||||
}
|
||||
|
||||
pub fn accepts_window(&self, id: u64) -> bool {
|
||||
self.bridge.accepts_window(id)
|
||||
}
|
||||
@@ -938,6 +949,86 @@ mod tests {
|
||||
const EXAMPLE: &str = include_str!("../examples/hello.endor");
|
||||
const PAGE: &str = include_str!("../examples/page.endor");
|
||||
|
||||
#[test]
|
||||
fn stopped_window_teardown_detaches_mounts_without_running_source_hooks() {
|
||||
let source = r#"class WatchedPage: Page {
|
||||
marker: Object
|
||||
function onUnmount(self: WatchedPage, mount: Mount): Unit { self.marker.increment() }
|
||||
}
|
||||
class Failure {
|
||||
function run(self: Failure, event: Event): Unit { ui.window().resize(0,600) }
|
||||
}
|
||||
marker=ui.state(0)
|
||||
mainPage=Page()
|
||||
mainPage.render(TextBlock("main"))
|
||||
other=Window()
|
||||
button=Button("fail")
|
||||
failure=Failure()
|
||||
connection=button.on("click",failure.run)
|
||||
page=WatchedPage(marker)
|
||||
page.render(button)
|
||||
page.open(other)"#;
|
||||
let (mut session, initial) = ReplSession::load(source, "app.main", 1, 140).unwrap();
|
||||
session
|
||||
.execute("held=button.mounts().at(0)", "app.main")
|
||||
.unwrap();
|
||||
let globals = session.candidate.globals.unwrap();
|
||||
let lookup = |session: &ReplSession, name: &str| match session
|
||||
.candidate
|
||||
.vm
|
||||
.dict_get(globals, &Value::Text(name.into()))
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
{
|
||||
Value::Object(object) => object,
|
||||
_ => panic!("object"),
|
||||
};
|
||||
let held = lookup(&session, "held");
|
||||
let window = lookup(&session, "other");
|
||||
let marker = lookup(&session, "marker");
|
||||
let mount = session
|
||||
.candidate
|
||||
.vm
|
||||
.payload::<crate::mount::Mount>(held, "Mount")
|
||||
.unwrap()
|
||||
.geometry
|
||||
.id;
|
||||
assert!(
|
||||
session
|
||||
.dispatch(&crate::events::Input {
|
||||
window: 2,
|
||||
session: 140,
|
||||
layout_version: initial.windows[&2].frame.layout_version,
|
||||
mount,
|
||||
kind: "click".into(),
|
||||
point: None,
|
||||
press_point: None
|
||||
})
|
||||
.is_err()
|
||||
);
|
||||
assert!(session.is_faulted());
|
||||
session.retire_window(2).unwrap();
|
||||
assert!(!session.accepts_window(2));
|
||||
assert!(
|
||||
!session
|
||||
.candidate
|
||||
.vm
|
||||
.payload::<crate::mount::Mount>(held, "Mount")
|
||||
.unwrap()
|
||||
.mounted
|
||||
);
|
||||
assert!(
|
||||
crate::window::pages(session.candidate.vm.object_store(), window)
|
||||
.unwrap()
|
||||
.is_empty()
|
||||
);
|
||||
assert_eq!(
|
||||
session.candidate.vm.get_attr(marker, "value").unwrap(),
|
||||
Value::Number(0.into())
|
||||
);
|
||||
assert!(session.execute("42", "app.main").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn native_windows_share_business_state_move_pages_and_release_closed_contexts() {
|
||||
let (mut session, initial) = ReplSession::load(
|
||||
|
||||
Reference in New Issue
Block a user