mirror of
https://github.com/MontFerret/ferret.git
synced 2025-06-23 00:28:10 +02:00
Added Context to HTML methods (#235)
* Added Context to HTML methods * Fixed unit tests * Updated timeout * Fixed WAIT_CLASS timeout
This commit is contained in:
@ -2,7 +2,6 @@ package html
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/MontFerret/ferret/pkg/drivers"
|
||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||||
@ -18,7 +17,7 @@ import (
|
||||
// Otherwise timeout.
|
||||
// @param timeout (Int, optional) - If document is passed, this param must represent timeout.
|
||||
// Otherwise not passed.
|
||||
func WaitClass(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
func WaitClass(ctx context.Context, args ...core.Value) (core.Value, error) {
|
||||
err := core.ValidateArgs(args, 2, 4)
|
||||
|
||||
if err != nil {
|
||||
@ -72,7 +71,10 @@ func WaitClass(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
timeout = args[3].(values.Int)
|
||||
}
|
||||
|
||||
return values.None, doc.WaitForClassBySelector(selector, class, timeout)
|
||||
ctx, fn := waitTimeout(ctx, timeout)
|
||||
defer fn()
|
||||
|
||||
return values.None, doc.WaitForClassBySelector(ctx, selector, class)
|
||||
}
|
||||
|
||||
el := arg1.(drivers.HTMLElement)
|
||||
@ -88,5 +90,8 @@ func WaitClass(_ context.Context, args ...core.Value) (core.Value, error) {
|
||||
timeout = args[2].(values.Int)
|
||||
}
|
||||
|
||||
return values.None, el.WaitForClass(class, timeout)
|
||||
ctx, fn := waitTimeout(ctx, timeout)
|
||||
defer fn()
|
||||
|
||||
return values.None, el.WaitForClass(ctx, class)
|
||||
}
|
||||
|
Reference in New Issue
Block a user