feat: extend navigationHistory API (#42014)

* feat: extend navigationHistory API

* refactor: simplify index checking

* refactor: rename 'getHistory' and 'replaceHistory' methods of navigationHistory

* refactor: rename delete*() methods to remove*()

* feat: remove navigationHistory.replaceHistory()

* tests: add tests for removeEntryAtIndex and getAllEntries
This commit is contained in:
Vít Černý 2024-08-19 21:46:04 +02:00 committed by GitHub
parent 4c3014944c
commit 189675575c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 105 additions and 6 deletions

View file

@ -35,10 +35,7 @@ Returns `Integer` - The index of the current page, from which we would go back/f
* `index` Integer
Returns `Object`:
* `url` string - The URL of the navigation entry at the given index.
* `title` string - The page title of the navigation entry at the given index.
Returns [`NavigationEntry`](structures/navigation-entry.md) - Navigation entry at the given index.
If index is out of bounds (greater than history length or less than 0), null will be returned.
@ -65,3 +62,15 @@ Navigates to the specified offset from the current entry.
#### `navigationHistory.length()`
Returns `Integer` - History length.
#### `navigationHistory.removeEntryAtIndex(index)`
* `index` Integer
Removes the navigation entry at the given index. Can't remove entry at the "current active index".
Returns `boolean` - Whether the navigation entry was removed from the webContents history.
#### `navigationHistory.getAllEntries()`
Returns [`NavigationEntry[]`](structures/navigation-entry.md) - WebContents complete history.

View file

@ -0,0 +1,4 @@
# NavigationEntry Object
* `url` string
* `title` string