1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-08-15 20:02:56 +02:00

fixes race condition when EventLoad listener isn't removed prior to the next page loading (#281)

This commit is contained in:
Adam Argo
2019-05-10 10:14:38 -07:00
committed by Tim Voronov
parent 101da6323a
commit 65b6981a8e

View File

@@ -704,8 +704,11 @@ func (doc *HTMLDocument) WaitForClassBySelectorAll(ctx context.Context, selector
func (doc *HTMLDocument) WaitForNavigation(ctx context.Context) error {
onEvent := make(chan struct{})
var once sync.Once
listener := func(_ context.Context, _ interface{}) {
once.Do(func() {
close(onEvent)
})
}
defer doc.events.RemoveEventListener(events.EventLoad, listener)