-
Notifications
You must be signed in to change notification settings - Fork 0
test(mv3): prove bounded bookmark mutation compatibility #56
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
Draft
seonghobae
wants to merge
26
commits into
test/mv3-downloads
Choose a base branch
from
test/mv3-bookmark-mutation
base: test/mv3-downloads
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c9a4a80
test(mv3): require real bookmark mutation lifecycle
seonghobae 50111a8
test(mv3): exercise bounded bookmark mutation
seonghobae e1099e3
test(mv3): align bookmarks compatibility contract with mutation lifec…
seonghobae 495ea67
merge: align MV3 bookmark mutation with current prerequisite
seonghobae 5d93647
merge: align MV3 bookmark mutation with current prerequisite
seonghobae 49cfb55
test(mv3): preserve restart-safe download prerequisite
seonghobae 18ebb7f
fix(mv3): preserve restart-safe download behavior
seonghobae 83df60f
merge: align bookmark mutation with current MV3 download prerequisite
seonghobae 857134a
merge: realign bookmark mutation with cleanup-safe MV3 root
seonghobae 369cb5d
test(mv3): inherit cleanup import normalization
seonghobae 6a98045
merge: realign bookmark mutation to current downloads prerequisite
seonghobae 82403ec
chore(mv3): align bookmark mutation with current downloads prerequisite
seonghobae cea76b9
chore(mv3): align bookmark mutation with transport fix
seonghobae 71420d0
test(mv3): realign bookmark mutation to hardened downloads root
seonghobae 2e5984a
merge: align bookmark mutation with current MV3 prerequisite
seonghobae 22bf829
chore(mv3): realign bookmark mutation with current downloads head
seonghobae 2ede65b
chore(stack): align bookmark mutation with current downloads head
seonghobae 70c2c36
chore(mv3): realign bookmark mutation with live downloads prerequisite
seonghobae 7042b25
chore(mv3): align bookmark mutation with latest downloads prerequisite
seonghobae 779c3c9
chore(mv3): merge live downloads prerequisite
seonghobae 3536718
chore(mv3): realign bookmark stack to live downloads head
seonghobae 8dc607c
test(mv3): require bounded bookmark diagnostics
seonghobae bf17be1
fix(mv3): classify bookmark mutation stages
seonghobae 450509b
fix(mv3): propagate bookmark diagnostics
seonghobae a850467
fix(mv3): sanitize bookmark compatibility evidence
seonghobae 03f8e37
merge(mv3): reconcile bookmark mutation onto downloads parent
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| """Fail-first contract for real Manifest V3 bookmark mutation compatibility.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import importlib.util | ||
| import json | ||
| import pathlib | ||
| import unittest | ||
|
|
||
| ROOT = pathlib.Path(__file__).resolve().parents[1] | ||
| FIXTURE = ROOT / "tests" / "fixtures" / "mv3_basic" | ||
| RUNNER = ROOT / "scripts" / "ci" / "run_mv3_compatibility.py" | ||
|
|
||
|
|
||
| def _load_runner_module(): | ||
| """Load the compatibility runner without invoking its command-line entry point.""" | ||
|
|
||
| spec = importlib.util.spec_from_file_location("originweave_mv3_runner", RUNNER) | ||
| if spec is None or spec.loader is None: | ||
| raise AssertionError("unable to load the MV3 compatibility runner") | ||
| module = importlib.util.module_from_spec(spec) | ||
| spec.loader.exec_module(module) | ||
| return module | ||
|
|
||
|
|
||
| class ManifestV3BookmarkMutationContractTests(unittest.TestCase): | ||
| """Require one bounded create/read/delete bookmark lifecycle in real Chromium.""" | ||
|
|
||
| def test_fixture_declares_bookmarks_permission(self) -> None: | ||
| """The controlled extension must explicitly request bookmark authority.""" | ||
|
|
||
| manifest = json.loads((FIXTURE / "manifest.json").read_text(encoding="utf-8")) | ||
| self.assertIn("bookmarks", manifest["permissions"]) | ||
|
|
||
| def test_service_worker_executes_bounded_bookmark_mutation_lifecycle(self) -> None: | ||
| """Compatibility evidence must require create/read/delete, not only tree reads.""" | ||
|
|
||
| worker = (FIXTURE / "service_worker.js").read_text(encoding="utf-8") | ||
| for expected in ( | ||
| "exerciseBookmarkMutation", | ||
| "chrome.bookmarks.create", | ||
| "chrome.bookmarks.get", | ||
| "chrome.bookmarks.remove", | ||
| '"OriginWeave MV3 compatibility bookmark"', | ||
| "bookmarkMutationReady", | ||
| ): | ||
| with self.subTest(expected=expected): | ||
| self.assertIn(expected, worker) | ||
|
|
||
|
seonghobae marked this conversation as resolved.
|
||
| def test_bookmark_mutation_is_bound_to_controlled_fixture_url_and_cleanup(self) -> None: | ||
| """The fixture must not mutate bookmarks for an arbitrary sender or leave residue.""" | ||
|
|
||
| worker = (FIXTURE / "service_worker.js").read_text(encoding="utf-8") | ||
| for expected in ( | ||
| 'parsed.protocol !== "http:"', | ||
| 'parsed.hostname !== "127.0.0.1"', | ||
| 'parsed.pathname !== "/page.html"', | ||
| "finally", | ||
| "chrome.bookmarks.remove", | ||
| ): | ||
| with self.subTest(expected=expected): | ||
| self.assertIn(expected, worker) | ||
| self.assertNotIn("_error.message", worker) | ||
| self.assertNotIn("String(_error)", worker) | ||
|
|
||
| def test_bookmark_failures_emit_only_bounded_stage_diagnostics(self) -> None: | ||
| """Every bookmark stage must return a reviewed token without raw browser values.""" | ||
|
|
||
| worker = (FIXTURE / "service_worker.js").read_text(encoding="utf-8") | ||
| for expected in ( | ||
| "bookmark-source-rejected", | ||
| "bookmark-create-rejected", | ||
| "bookmark-get-missing", | ||
| "bookmark-id-mismatch", | ||
| "bookmark-title-mismatch", | ||
| "bookmark-url-mismatch", | ||
| "bookmark-remove-rejected", | ||
| "bookmark-complete-ready", | ||
| "bookmarksDiagnostic", | ||
| ): | ||
| with self.subTest(expected=expected): | ||
| self.assertIn(expected, worker) | ||
| self.assertNotIn("_error.message", worker) | ||
| self.assertNotIn("String(_error)", worker) | ||
|
|
||
| def test_runner_preserves_only_reviewed_bookmark_diagnostic_tokens(self) -> None: | ||
| """Trial evidence must reduce arbitrary bookmark diagnostics to `unexpected`.""" | ||
|
|
||
| runner = _load_runner_module() | ||
| approved = { | ||
| "bookmark-source-rejected", | ||
| "bookmark-create-rejected", | ||
| "bookmark-get-missing", | ||
| "bookmark-id-mismatch", | ||
| "bookmark-title-mismatch", | ||
| "bookmark-url-mismatch", | ||
| "bookmark-remove-rejected", | ||
| "bookmark-complete-ready", | ||
| "bookmark-not-evaluated", | ||
| } | ||
| self.assertIn("bookmarksDiagnostic", runner.SURFACE_EVIDENCE_KEYS) | ||
| self.assertEqual(runner.BOOKMARK_DIAGNOSTIC_VALUES, frozenset(approved)) | ||
| for token in approved: | ||
| with self.subTest(token=token): | ||
| self.assertEqual( | ||
| runner._safe_surface_value("bookmarksDiagnostic", token), token | ||
| ) | ||
|
|
||
| for raw in ( | ||
| "OriginWeave MV3 compatibility bookmark", | ||
| "Error: secret bookmark failure", | ||
| ): | ||
| with self.subTest(raw=raw): | ||
| error = runner.CompatibilitySurfaceError( | ||
| {"bookmarks": "missing", "bookmarksDiagnostic": raw} | ||
| ) | ||
| evidence = runner._failure_evidence(error) | ||
| self.assertEqual( | ||
| evidence["observed"]["bookmarksDiagnostic"], "unexpected" | ||
| ) | ||
| self.assertNotIn(raw, repr(evidence)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
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.