-
Notifications
You must be signed in to change notification settings - Fork 0
feat(core): revalidate current browser context origin #118
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
Merged
seonghobae
merged 9 commits into
feat/browser-protocol-runtime-adapter-version-binding
from
feat/browser-context-origin-revalidation
Aug 26, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
05c8834
test(core): require current browser context origin
seonghobae dae6566
test(core): apply canonical origin revalidation formatting
seonghobae 61485d0
feat(core): revalidate current browser context origin
seonghobae 1eae129
style(core): apply canonical context-origin formatting
seonghobae 67e82ca
merge: align browser context origin revalidation with current binding
seonghobae 9419430
merge: preserve browser retirement in origin revalidation
seonghobae c9e6319
merge: align origin revalidation with current origin binding
seonghobae 6996e6f
docs: record context origin revalidation
seonghobae 734210a
Merge remote-tracking branch 'origin/feat/browser-protocol-runtime-ad…
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
crates/originweave-core/tests/browser_context_origin_revalidation.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| use std::error::Error; | ||
| use std::io; | ||
|
|
||
| use originweave_core::{BrowserAuthorityRegistry, BrowserRegistryError, Origin}; | ||
|
|
||
| fn first_origin() -> Result<Origin, io::Error> { | ||
| Origin::parse("http://127.0.0.1:43127") | ||
| .map_err(|_error| io::Error::other("controlled first origin must be valid")) | ||
| } | ||
|
|
||
| fn second_origin() -> Result<Origin, io::Error> { | ||
| Origin::parse("http://localhost:43127") | ||
| .map_err(|_error| io::Error::other("controlled second origin must be valid")) | ||
| } | ||
|
|
||
| #[test] | ||
| fn current_context_origin_must_be_bound_before_revalidation() -> Result<(), Box<dyn Error>> { | ||
| let mut registry = BrowserAuthorityRegistry::new(); | ||
| let session = registry.register_session("webdriver-session")?; | ||
| let context = registry.register_context(session, "top-level-context")?; | ||
| let origin = first_origin()?; | ||
|
|
||
| assert_eq!( | ||
| registry.require_context_origin(session, context, &origin), | ||
| Err(BrowserRegistryError::ContextOriginNotBound) | ||
| ); | ||
|
|
||
| let epoch = registry.bind_context_origin(session, context, &origin)?; | ||
| assert_eq!( | ||
| registry.require_context_origin(session, context, &origin), | ||
| Ok(epoch) | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn current_context_origin_revalidation_fails_closed_on_mismatch() -> Result<(), Box<dyn Error>> { | ||
| let mut registry = BrowserAuthorityRegistry::new(); | ||
| let session = registry.register_session("webdriver-session")?; | ||
| let context = registry.register_context(session, "top-level-context")?; | ||
| let first = first_origin()?; | ||
| let second = second_origin()?; | ||
|
|
||
| registry.bind_context_origin(session, context, &first)?; | ||
| assert_eq!( | ||
| registry.require_context_origin(session, context, &second), | ||
| Err(BrowserRegistryError::OriginChangedWithoutDocumentAdvance) | ||
| ); | ||
| assert!( | ||
| registry | ||
| .require_context_origin(session, context, &first) | ||
| .is_ok() | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn document_rotation_requires_fresh_origin_binding() -> Result<(), Box<dyn Error>> { | ||
| let mut registry = BrowserAuthorityRegistry::new(); | ||
| let session = registry.register_session("webdriver-session")?; | ||
| let context = registry.register_context(session, "top-level-context")?; | ||
| let first = first_origin()?; | ||
| let second = second_origin()?; | ||
|
|
||
| registry.bind_context_origin(session, context, &first)?; | ||
| let next_epoch = registry.advance_document(context)?; | ||
| assert_eq!( | ||
| registry.require_context_origin(session, context, &first), | ||
| Err(BrowserRegistryError::ContextOriginNotBound) | ||
| ); | ||
|
|
||
| registry.bind_context_origin(session, context, &second)?; | ||
| assert_eq!( | ||
| registry.require_context_origin(session, context, &second), | ||
| Ok(next_epoch) | ||
| ); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[test] | ||
| fn context_origin_revalidation_preserves_session_ownership() -> Result<(), Box<dyn Error>> { | ||
| let mut registry = BrowserAuthorityRegistry::new(); | ||
| let owner = registry.register_session("owner-session")?; | ||
| let attacker = registry.register_session("attacker-session")?; | ||
| let context = registry.register_context(owner, "top-level-context")?; | ||
| let origin = first_origin()?; | ||
|
|
||
| registry.bind_context_origin(owner, context, &origin)?; | ||
| assert_eq!( | ||
| registry.require_context_origin(attacker, context, &origin), | ||
| Err(BrowserRegistryError::ContextSessionMismatch { | ||
| expected: owner, | ||
| actual: attacker, | ||
| }) | ||
| ); | ||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.