fix regression when using Run twice on the first ctx
We don't want to always set c.first, as that can change the field from true to false.
This commit is contained in:
parent
c41ed01b6a
commit
b977e305d2
|
@ -114,13 +114,13 @@ func Run(ctx context.Context, actions ...Action) error {
|
|||
if c == nil || c.Allocator == nil {
|
||||
return ErrInvalidContext
|
||||
}
|
||||
c.first = c.Browser == nil
|
||||
if c.first {
|
||||
if c.Browser == nil {
|
||||
browser, err := c.Allocator.Allocate(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.Browser = browser
|
||||
c.first = true
|
||||
}
|
||||
if c.Target == nil {
|
||||
if err := c.newSession(ctx); err != nil {
|
||||
|
|
|
@ -41,4 +41,10 @@ func TestTargets(t *testing.T) {
|
|||
// Cancelling the second context should close the second tab alone.
|
||||
cancel2()
|
||||
wantTargets(ctx1, 1)
|
||||
|
||||
// We used to have a bug where Run would reset the first context as if
|
||||
// it weren't the first, breaking its cancellation.
|
||||
if err := Run(ctx1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user