-
Notifications
You must be signed in to change notification settings - Fork 16.2k
feat: extend navigationHistory API #42014
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
Conversation
e90a424
to
6235bee
Compare
@alicelovescake would you be able to help review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a high level, without taking a deeper look at the implementation details, I think these methods will be useful. I'll try to more thoroughly review sometime soon, but we'll need to add some tests for these changes regardless!
3ec3bf4
to
1d8afbc
Compare
309b8b1
to
d6b8cb3
Compare
Sorry for my late reply. I now work for a different company, and I no longer have access to the building infrastructure. On the topic of the replaceHistory method, I agree with @alicelovescake. Chromium internal implementation of navigation entry is more complicated and contains many properties. But we are setting only title and url, leaving other properties at default values. Here is the constructor of the NavigationEntryImpl: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/navigation_entry_impl.cc;l=392 So my suggestion would be to remove the replace method here, so I don't block this pull request. Maybe someone will come up with a better way to recreate NavigationEntries. What do you think @samuelmaddock ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments about aligning naming with existing APIs. Following these changes, happy to give this a lgtm!
So my suggestion would be to remove the replace method here, so I don't block this pull request.
I think this is a reasonable approach. What's proposed in this PR is not far off, so I'd welcome finding a new design in a future PR. 👍
Yeah agreed that this PR looks great after removing the replace method. We need a way to construct Chromium's definition of a NavigationEntry before can pass a correct argument to @vitekcerny Do you mind adding tests to the existing test suite for navigationHistory? |
aa9c902
to
2d50cf7
Compare
I renamed the methods to be consistent with the rest of the webContents API. But I need help with tests. I don't have much experience with javascript unit testing (I’m a C++ guy). Would you mind writing those tests @alicelovescake ? Or if you refer me to the documentation, I will try to write them myself. |
Sure! Here are tests that you can add based on the existing format:
If you have e tools, run |
Adding a |
Here is my error log. But I believe this error is only in my environment. If you try to run the tests yourself, or if you run them in CI, they should pass.
|
3979309
to
c1ea71c
Compare
I managed to run the tests. I just had to comment out a few lines that were causing the errors above (irrelevant for this pr). Anyway, the tests are passing, so I thing this pull request is ready for review @samuelmaddock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
It sounds like we're skipping the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for the effort to see this through!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
@vitekcerny this repo requires commits to be signed. Once that's done, i think we can get this merged :) |
bd33864
to
4f1a2f2
Compare
4f1a2f2
to
d9304e2
Compare
The commits are now signed and the release notes are edited @codebytere |
Congrats on merging your first pull request! 🎉🎉🎉 |
Release Notes Persisted
|
* 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
Description of Change
This PR builds on #41577 and adds 2 more functions to
webContents.navigationHistory
.The motivation is to provide an API for developers of browser-type applications.
New API:
navigationHistory.removeEntryAtIndex(index)
- Removes the navigation entry at the given index.navigationHistory.getAllEntries()
- Returns webContents complete history.This enables browser-type applications to save (
getAllEntries
) browsing sessions.Also partially resolves these feature requests: #33899 #41250
Checklist
npm test
passesRelease Notes
Notes: Extended
navigationHistory
API with 2 new functions for better history management.