Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial round of stability fixes updated from the old spike branch #19

Open
wants to merge 4 commits into
base: upstream-main
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions src/ChromeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public function start()
}

if (isset($this->options['validateCertificate']) && $this->options['validateCertificate'] === false) {
$this->page->send('Security.enable');
$this->page->send('Security.setIgnoreCertificateErrors', ['ignore' => true]);
}
}
Expand Down Expand Up @@ -239,8 +238,10 @@ public function reset()
}
$this->switchToWindow($this->main_window);
$this->page->reset();
$this->request_headers = [];
$this->sendRequestHeaders();
if ($this->request_headers !== []) {
$this->request_headers = [];
$this->sendRequestHeaders();
}
}

/**
Expand Down
15 changes: 0 additions & 15 deletions src/ChromePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function connect($url = null): void
$this->send('Page.enable');
$this->send('DOM.enable');
$this->send('Network.enable');
$this->send('Animation.enable');
$this->send('Animation.setPlaybackRate', ['playbackRate' => 100000]);
$this->send('Console.enable');
}
Expand Down Expand Up @@ -232,20 +231,6 @@ protected function processResponse(array $data): bool
break;
case 'Inspector.targetCrashed':
throw new DriverException('Browser crashed');
case 'Animation.animationStarted':
if (!empty($data['params']['source']['duration'])) {
usleep($data['params']['source']['duration'] * 10);
}
break;
case 'Security.certificateError':
if (isset($data['params']['eventId'])) {
$this->send(
'Security.handleCertificateError',
['eventId' => $data['params']['eventId'], 'action' => 'continue']
);
$this->page_ready = false;
}
break;
case 'Console.messageAdded':
$this->console_messages[] = $data['params']['message'];
break;
Expand Down
7 changes: 6 additions & 1 deletion src/DevToolsConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ protected function waitFor(callable $is_ready)
}

if (is_null($response)) {
return null;
// There seems to be no valid case where we could actually get an explicit `null` value from the
// underlying websocket, other than perhaps the socket being closed by Chrome. Certainly, calling code
// (which does not generally check the response) should not blindly continue at this point.
throw new DriverException(
'Received unexpected NULL payload from Chrome websocket'
);
}

if ($data = json_decode($response, true)) {
Expand Down
Loading