S008: importer smoke on fake Chrome and Firefox profiles
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
parent
f9d0f0d338
commit
da5a73768a
4 changed files with 78 additions and 1 deletions
|
|
@ -16,7 +16,7 @@ Verify passwords/vault and autofill, permissions prompts, history/bookmarks/down
|
|||
- [x] Permissions: a local page asking for notifications/geolocation/camera; allow/deny/remember; check `permissions` store
|
||||
- [x] History, bookmarks (add, folder, bookmarks bar, import/export HTML), downloads page lists entries
|
||||
- [x] User scripts/styles apply on matching pages; install a site as an app and launch it
|
||||
- [ ] Importer: build a fake old-Nacre profile from `~/Documents/Apps/Nacre` config format in a temp dir (never the user's real profile) and import it
|
||||
- [x] Importer: build a fake old-Nacre profile from `~/Documents/Apps/Nacre` config format in a temp dir (never the user's real profile) and import it
|
||||
- [x] R1-20 per-site memory and enforcement: set per-site zoom, ad blocker on/off, privacy-mode flag (flag persistence only; internals are D-011) and other per-site choices; set per-site permissions (camera, mic, location, notifications, pop-ups, autoplay, …); quit, relaunch with `SMOKE_HOME=<first outdir>/home`, check values are in the stores and apply again on reopening the site; check each permission is enforced (blocked/allowed/asked per its stored value), not only stored; fix what is not
|
||||
- [ ] Change a sample of settings via `set` and via clicks; check `settings.json` and the effect; mark FEATURES rows
|
||||
- [ ] PROGRESS entry, INDEX line, commit `S008: …` and push
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
//! cmd <name> [arg] back, forward, reload, bookmark, install_app, pip, exitpip, free_memory,
|
||||
//! update_lists, check_updates, close_tab, select <n>, zoom <step>,
|
||||
//! find <text>, download <url>, pause_download|resume_download|cancel_download [id] (newest),
|
||||
//! import <n> (bookmarks, history, settings from the n-th found browser profile),
|
||||
//! install_script <url> (a .user.js / .user.css), open_app [id] (default: the first installed app),
|
||||
//! navigate <typed text>, mute, pin
|
||||
//! js <script> run JavaScript in the current tab; the result goes to the log
|
||||
|
|
@ -402,6 +403,7 @@ impl App {
|
|||
"mute" => Command::MuteTab(tab),
|
||||
"pin" => Command::PinTab(tab),
|
||||
"reopen" => Command::ReopenClosed(None),
|
||||
"import" => Command::Import { source: arg.parse().unwrap_or(0), bookmarks: true, history: true, settings: true },
|
||||
"install_script" => Command::InstallScript(arg.to_owned()),
|
||||
"open_app" => Command::OpenApp(if arg.is_empty() { self.shared.apps.borrow().items.first().map(|a| a.id.clone()).unwrap_or_default() } else { arg.to_owned() }),
|
||||
"media" => Command::Media { tab, action: arg.to_owned(), value: 0.0 },
|
||||
|
|
@ -767,6 +769,9 @@ impl App {
|
|||
"vault_mode": format!("{:?}", self.shared.vault.borrow().mode()),
|
||||
"apps": self.shared.apps.borrow().items.len(),
|
||||
"scripts": self.shared.scripts.borrow().items.len(),
|
||||
"import_status": self.shared.import_status.borrow().clone(),
|
||||
"home_url": settings.startup.home_url,
|
||||
"search_engine": settings.startup.search_engine,
|
||||
"dlm": format!("{:?}", self.shared.dlm_status.borrow()),
|
||||
"discord": self.shared.presence_status.borrow().clone(),
|
||||
"spell": self.shared.spell_status.borrow().clone(),
|
||||
|
|
|
|||
44
tests/smoke/make-import-home.py
Executable file
44
tests/smoke/make-import-home.py
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Build a throwaway HOME holding fake Chrome and Firefox profiles for tests/smoke/stores-import.txt.
|
||||
Usage: tests/smoke/make-import-home.py <dir> (then SMOKE_HOME=<dir> tools/smoke.sh tests/smoke/stores-import.txt).
|
||||
Never reads a real profile. Chrome (found first): 2 bar links, a folder with 1 link, 1 link in Other, 3 visits (one non-web),
|
||||
home page and Bing. Firefox: 1 toolbar link, 1 menu link, 2 visits, home page and DuckDuckGo."""
|
||||
import json
|
||||
import sqlite3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
home = Path(sys.argv[1])
|
||||
chrome = home / ".config/google-chrome/Default"
|
||||
chrome.mkdir(parents=True)
|
||||
node = lambda name, url: {"type": "url", "name": name, "url": url}
|
||||
(chrome / "Bookmarks").write_text(json.dumps({"roots": {
|
||||
"bookmark_bar": {"children": [node("Chrome bar one", "https://one.chrome.example/"), node("Chrome bar two", "https://two.chrome.example/"),
|
||||
{"type": "folder", "name": "Chrome folder", "children": [node("Inside", "https://in.chrome.example/")]}]},
|
||||
"other": {"children": [node("Chrome other", "https://other.chrome.example/"), node("Script", "javascript:alert(1)")]},
|
||||
}}))
|
||||
(chrome / "Preferences").write_text(json.dumps({"homepage": "https://home.chrome.example/", "default_search_provider_data": {"template_url_data": {"keyword": "bing.com"}}}))
|
||||
db = sqlite3.connect(chrome / "History")
|
||||
db.executescript("CREATE TABLE urls(id INTEGER PRIMARY KEY, url TEXT, title TEXT, visit_count INT, last_visit_time INT); CREATE TABLE visits(id INTEGER PRIMARY KEY, url INT, visit_time INT);")
|
||||
epoch = 11644473600
|
||||
for i, (url, title) in enumerate([("https://a.chrome.example/", "A"), ("https://b.chrome.example/", "B"), ("chrome://settings/", "Settings")], 1):
|
||||
db.execute("INSERT INTO urls VALUES (?,?,?,1,?)", (i, url, title, (1700000000 + i * 60 + epoch) * 1_000_000))
|
||||
db.execute("INSERT INTO visits VALUES (?,?,?)", (i, i, (1700000000 + i * 60 + epoch) * 1_000_000))
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
fx_root = home / ".mozilla/firefox"
|
||||
fx = fx_root / "abc.default"
|
||||
fx.mkdir(parents=True)
|
||||
(fx_root / "profiles.ini").write_text("[Profile0]\nName=default\nIsRelative=1\nPath=abc.default\n")
|
||||
(fx / "prefs.js").write_text('user_pref("browser.startup.homepage", "https://home.firefox.example/");\nuser_pref("browser.search.defaultenginename", "DuckDuckGo");\n')
|
||||
db = sqlite3.connect(fx / "places.sqlite")
|
||||
db.executescript("""CREATE TABLE moz_places(id INTEGER PRIMARY KEY, url TEXT, title TEXT);
|
||||
CREATE TABLE moz_bookmarks(id INTEGER PRIMARY KEY, type INT, fk INT, parent INT, position INT, title TEXT);
|
||||
CREATE TABLE moz_historyvisits(id INTEGER PRIMARY KEY, place_id INT, visit_date INT);""")
|
||||
places = [(1, "https://bar.firefox.example/", "Fx bar"), (2, "https://menu.firefox.example/", "Fx menu"), (3, "https://x.firefox.example/", "X"), (4, "https://y.firefox.example/", "Y")]
|
||||
db.executemany("INSERT INTO moz_places VALUES (?,?,?)", places)
|
||||
db.executemany("INSERT INTO moz_bookmarks VALUES (?,?,?,?,?,?)", [(2, 2, None, 1, 0, "menu"), (3, 2, None, 1, 1, "toolbar"), (10, 1, 1, 3, 0, "Fx bar"), (11, 1, 2, 2, 0, "Fx menu")])
|
||||
db.executemany("INSERT INTO moz_historyvisits VALUES (?,?,?)", [(1, 3, 1700000100 * 1_000_000), (2, 4, 1700000200 * 1_000_000)])
|
||||
db.commit()
|
||||
db.close()
|
||||
28
tests/smoke/stores-import.txt
Normal file
28
tests/smoke/stores-import.txt
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Stores pass (S008): the importer reads other browsers' profiles. A fake home (tests/smoke/make-import-home.py) holds a
|
||||
# Chrome and a Firefox profile; Nacre finds both and imports bookmarks, history, home page and search engine.
|
||||
# Offline. python3 tests/smoke/make-import-home.py target/smoke/import-home
|
||||
# SMOKE_HOME=$PWD/target/smoke/import-home tools/smoke.sh tests/smoke/stores-import.txt <outdir>
|
||||
wait 3
|
||||
status found
|
||||
expect /import_sources/0 "Google Chrome"
|
||||
expect /import_sources/1 "Firefox"
|
||||
cmd import 0
|
||||
wait 3
|
||||
status chrome
|
||||
expect /bookmarks 4
|
||||
expect /bookmark_folders 2
|
||||
expect /history 2
|
||||
expect /home_url "https://home.chrome.example/"
|
||||
expect /search_engine "bing"
|
||||
page nacre://bookmarks
|
||||
wait 1
|
||||
shot chrome-imported
|
||||
cmd import 1
|
||||
wait 3
|
||||
status firefox
|
||||
expect /bookmarks 6
|
||||
expect /history 4
|
||||
expect /home_url "https://home.firefox.example/"
|
||||
expect /search_engine "duckduckgo"
|
||||
status done
|
||||
quit
|
||||
Loading…
Reference in a new issue