Release retired document sources outside the cache lock
This commit is contained in:
1 parent
b4896a2eb4
commit
228271b43b
3 files changed
+124
-13
No files matched your search
@@ -390,6 +390,7 @@ waitReload:
|
||||
if !activated {
|
||||
t.Fatal("captured link action did not update the page")
|
||||
}
|
||||
testNativeBrowserDocumentEviction(t, adapter)
|
||||
testNativeBrowserBackgroundLoad(t, adapter)
|
||||
return
|
||||
}
|
||||
@@ -481,3 +482,34 @@ func testNativeBrowserBackgroundLoad(t *testing.T, adapter *Adapter) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// More loads than the retained-slot limit force disposal of old native objects.
|
||||
// libatspi can synchronously deliver defunct callbacks during that disposal.
|
||||
func testNativeBrowserDocumentEviction(t *testing.T, adapter *Adapter) {
|
||||
t.Helper()
|
||||
for index := 0; index < maxStashedDocuments+2; index++ {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
if out, err := exec.CommandContext(ctx, "xdotool", "key", "--clearmodifiers", "ctrl+r").CombinedOutput(); err != nil {
|
||||
cancel()
|
||||
t.Fatalf("reload %d: %v %s", index, err, out)
|
||||
}
|
||||
var loaded ObjectID
|
||||
for !loaded.Valid() {
|
||||
select {
|
||||
case event := <-adapter.Events():
|
||||
if event.Type == DocumentLoadCompleteEvent && event.Source.Name == "Cthulhu Browser Probe" {
|
||||
loaded = event.Source.ID()
|
||||
}
|
||||
case <-ctx.Done():
|
||||
cancel()
|
||||
t.Fatalf("reload %d: load completion missing", index)
|
||||
}
|
||||
}
|
||||
tree, err := adapter.CaptureDocument(ctx, loaded)
|
||||
cancel()
|
||||
if err != nil {
|
||||
t.Fatalf("capture after reload %d: %v", index, err)
|
||||
}
|
||||
findNamedReference(t, tree, "Browser foundation")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user