Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/cmd/wrapper/snapshot_start_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func prepareSnapshotStartPage(ctx context.Context, internalPort string) (retErr
return err
}
navCtx, cancel := context.WithTimeout(ctx, 20*time.Second)
navErr := cdpclient.DispatchStartURLAndWait(navCtx, devtoolsURL, snapshotStartPageURL)
navErr := cdpclient.DispatchStartURLAndWait(navCtx, devtoolsURL, "chrome://newtab/", snapshotStartPageURL)
cancel()

cleanupErr := cleanupSeedEnvoyIfStarted(seedEnvoyStarted)
Expand Down
10 changes: 5 additions & 5 deletions server/lib/cdpclient/cdpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ func DispatchStartURL(ctx context.Context, devtoolsURL, url string) error {
return nil
}

// DispatchStartURLAndWait navigates the user-facing page and waits until the
// destination has loaded without resolving to Chrome's network error page.
func DispatchStartURLAndWait(ctx context.Context, devtoolsURL, destination string) error {
if err := DispatchStartURL(ctx, devtoolsURL, destination); err != nil {
// DispatchStartURLAndWait navigates through navigationURL and waits for
// destination to load without resolving to Chrome's network error page.
func DispatchStartURLAndWait(ctx context.Context, devtoolsURL, navigationURL, destination string) error {
if err := DispatchStartURL(ctx, devtoolsURL, navigationURL); err != nil {
return err
}

Expand Down Expand Up @@ -369,7 +369,7 @@ func DispatchStartURLAndWait(ctx context.Context, devtoolsURL, destination strin
return nil
}
if strings.HasPrefix(lastState.URL, "chrome-error://") && time.Since(lastNavigate) >= 250*time.Millisecond {
_, _ = c.send(ctx, "Page.navigate", map[string]any{"url": destination}, attach.SessionID)
_, _ = c.send(ctx, "Page.navigate", map[string]any{"url": navigationURL}, attach.SessionID)
lastNavigate = time.Now()
}
}
Expand Down
9 changes: 5 additions & 4 deletions server/lib/cdpclient/cdpclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ func TestDispatchStartURLAndWait(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
err := DispatchStartURLAndWait(ctx, url, "https://start.duckduckgo.com/")
err := DispatchStartURLAndWait(ctx, url, "chrome://newtab/", "https://start.duckduckgo.com/")
require.NoError(t, err)
assert.True(t, f.navigateCalled)
assert.Equal(t, "https://start.duckduckgo.com/", f.navigateURL)
assert.Equal(t, "chrome://newtab/", f.navigateURL)
})

t.Run("retries a failed initial navigation", func(t *testing.T) {
Expand All @@ -274,9 +274,10 @@ func TestDispatchStartURLAndWait(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
err := DispatchStartURLAndWait(ctx, url, "https://start.duckduckgo.com/")
err := DispatchStartURLAndWait(ctx, url, "chrome://newtab/", "https://start.duckduckgo.com/")
require.NoError(t, err)
assert.GreaterOrEqual(t, f.navigateCalls, 2)
assert.Equal(t, "chrome://newtab/", f.navigateURL)
})

t.Run("times out on Chrome error page", func(t *testing.T) {
Expand All @@ -289,7 +290,7 @@ func TestDispatchStartURLAndWait(t *testing.T) {

ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
err := DispatchStartURLAndWait(ctx, url, "https://start.duckduckgo.com/")
err := DispatchStartURLAndWait(ctx, url, "chrome://newtab/", "https://start.duckduckgo.com/")
require.Error(t, err)
assert.Contains(t, err.Error(), "chrome-error://chromewebdata/")
})
Expand Down
Loading