Skip to content

Commit

Permalink
Chrome 111 compatibility hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
przedmiot committed Mar 13, 2023
1 parent 5ed5c6d commit df726e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/ChromeDevtoolsProtocol/Instance/Instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(string $host, int $port, ?ClientInterface $httpClien

public function tabs(ContextInterface $ctx): array
{
$response = $this->httpClient->request("POST", "http://{$this->host}:{$this->port}/json/list", [
$response = $this->httpClient->request("GET", "http://{$this->host}:{$this->port}/json/list", [
"timeout" => $ctx->getDeadline() !== null ? $ctx->deadlineFromNow() : 0,
]);

Expand All @@ -73,7 +73,7 @@ public function tabs(ContextInterface $ctx): array
public function open(ContextInterface $ctx, ?string $url = null): Tab
{
$response = $this->httpClient->request(
"POST",
"PUT",
"http://{$this->host}:{$this->port}/json/new" . ($url !== null ? "?" . urlencode($url) : ""),
[
"timeout" => $ctx->getDeadline() !== null ? $ctx->deadlineFromNow() : 0,
Expand All @@ -84,7 +84,7 @@ public function open(ContextInterface $ctx, ?string $url = null): Tab

public function version(ContextInterface $ctx): Version
{
$response = $this->httpClient->request("POST", "http://{$this->host}:{$this->port}/json/version", [
$response = $this->httpClient->request("GET", "http://{$this->host}:{$this->port}/json/version", [
"timeout" => $ctx->getDeadline() !== null ? $ctx->deadlineFromNow() : 0,
]);
return Version::fromJson(json_decode($response->getBody()->getContents()));
Expand Down Expand Up @@ -160,7 +160,7 @@ public function createSession(ContextInterface $ctx, string $url = "about:blank"
*/
public function activateTabById(ContextInterface $ctx, string $id): void
{
$this->httpClient->request("POST", "http://{$this->host}:{$this->port}/json/activate/{$id}", [
$this->httpClient->request("GET", "http://{$this->host}:{$this->port}/json/activate/{$id}", [
"timeout" => $ctx->getDeadline() !== null ? $ctx->deadlineFromNow() : 0,
]);
}
Expand All @@ -170,7 +170,7 @@ public function activateTabById(ContextInterface $ctx, string $id): void
*/
public function closeTabById(ContextInterface $ctx, string $id): void
{
$this->httpClient->request("POST", "http://{$this->host}:{$this->port}/json/close/{$id}", [
$this->httpClient->request("GET", "http://{$this->host}:{$this->port}/json/close/{$id}", [
"timeout" => $ctx->getDeadline() !== null ? $ctx->deadlineFromNow() : 0,
]);
}
Expand Down
7 changes: 4 additions & 3 deletions src/ChromeDevtoolsProtocol/Instance/Launcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class Launcher
const DEFAULT_LINUX_EXECUTABLE = "google-chrome";
const DEFAULT_WINDOWS_EXECUTABLE = "chrome";

public static $defaultArgs = [
"--headless",
];
public static $defaultArgs = [
"--headless",
"--remote-allow-origins=http://127.0.0.1"
];

/** @var string */
private $executable;
Expand Down

0 comments on commit df726e9

Please sign in to comment.