Skip to content

Commit df726e9

Browse files
committed
Chrome 111 compatibility hotfix
1 parent 5ed5c6d commit df726e9

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/ChromeDevtoolsProtocol/Instance/Instance.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(string $host, int $port, ?ClientInterface $httpClien
5858

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

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

8585
public function version(ContextInterface $ctx): Version
8686
{
87-
$response = $this->httpClient->request("POST", "http://{$this->host}:{$this->port}/json/version", [
87+
$response = $this->httpClient->request("GET", "http://{$this->host}:{$this->port}/json/version", [
8888
"timeout" => $ctx->getDeadline() !== null ? $ctx->deadlineFromNow() : 0,
8989
]);
9090
return Version::fromJson(json_decode($response->getBody()->getContents()));
@@ -160,7 +160,7 @@ public function createSession(ContextInterface $ctx, string $url = "about:blank"
160160
*/
161161
public function activateTabById(ContextInterface $ctx, string $id): void
162162
{
163-
$this->httpClient->request("POST", "http://{$this->host}:{$this->port}/json/activate/{$id}", [
163+
$this->httpClient->request("GET", "http://{$this->host}:{$this->port}/json/activate/{$id}", [
164164
"timeout" => $ctx->getDeadline() !== null ? $ctx->deadlineFromNow() : 0,
165165
]);
166166
}
@@ -170,7 +170,7 @@ public function activateTabById(ContextInterface $ctx, string $id): void
170170
*/
171171
public function closeTabById(ContextInterface $ctx, string $id): void
172172
{
173-
$this->httpClient->request("POST", "http://{$this->host}:{$this->port}/json/close/{$id}", [
173+
$this->httpClient->request("GET", "http://{$this->host}:{$this->port}/json/close/{$id}", [
174174
"timeout" => $ctx->getDeadline() !== null ? $ctx->deadlineFromNow() : 0,
175175
]);
176176
}

src/ChromeDevtoolsProtocol/Instance/Launcher.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ class Launcher
2020
const DEFAULT_LINUX_EXECUTABLE = "google-chrome";
2121
const DEFAULT_WINDOWS_EXECUTABLE = "chrome";
2222

23-
public static $defaultArgs = [
24-
"--headless",
25-
];
23+
public static $defaultArgs = [
24+
"--headless",
25+
"--remote-allow-origins=http://127.0.0.1"
26+
];
2627

2728
/** @var string */
2829
private $executable;

0 commit comments

Comments
 (0)