Skip to content

Commit

Permalink
Flush localstorage (temporarily merge #22 for our fork)
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit fd1a98b
Author: acoulton <[email protected]>
Date:   Tue May 17 10:13:25 2022 +0100

    Natively flush Chrome localstorage for the domain

    Now that the driver always starts on about:blank, it's not
    possible to use javascript to flush localstorage from a
    hook because it's not on the right domain.

    Fortunately devtools protocol exposes a command for this.
  • Loading branch information
acoulton committed Oct 17, 2024
1 parent 369451a commit 0411bf5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changelog
## 2.9.4.2 (CUSTOM INGENERATOR RELEASE) (2024-10-17)

* Some minor connection enhancements #19
* Support flushing localstorage for domain #22

## 2.9.4.1 (CUSTOM INGENERATOR RELEASE) (2024-09-30)

Expand Down
11 changes: 11 additions & 0 deletions src/ChromeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1743,4 +1743,15 @@ public function captureScreenshot($filename, $options = [])

file_put_contents($filename, $imageData);
}

public function clearLocalStorageForOrigin(string $origin): void
{
$this->page->send(
'Storage.clearDataForOrigin',
[
'origin' => $origin,
'storageTypes' => 'local_storage',
]
);
}
}

0 comments on commit 0411bf5

Please sign in to comment.