From 41646828daf70aeda9e30eac15f189a6cd9dc91e Mon Sep 17 00:00:00 2001 From: agentflow-marathon Date: Fri, 27 Nov 2026 20:33:09 -0800 Subject: [PATCH 1/2] Qualify same-version browsers through an older signed updater --- docs/chromium-159-runtime-qualification.md | 32 ++++++++ scripts/package_chromium_release.py | 2 +- scripts/updater/macos_smoke_scope.py | 20 ++++- scripts/updater/test_macos_smoke_scope.py | 95 ++++++++++++++++++++++ scripts/verify_chromium_toolbar.cua.js | 57 +++++++++++++ 5 files changed, 201 insertions(+), 5 deletions(-) create mode 100644 docs/chromium-159-runtime-qualification.md create mode 100644 scripts/verify_chromium_toolbar.cua.js diff --git a/docs/chromium-159-runtime-qualification.md b/docs/chromium-159-runtime-qualification.md new file mode 100644 index 0000000000..4f4cda67a7 --- /dev/null +++ b/docs/chromium-159-runtime-qualification.md @@ -0,0 +1,32 @@ +# Chromium 159 runtime qualification + +The shared build driver invokes `package_chromium_release.py --verify-existing` +for both signed DMGs, using hash-verified frozen inputs and an explicitly +installed baseline browser of the same version. Native frontend, AI update +action, executable tools, About callback and actual browser/renderer CPU checks +run from disposable installed copies. Universal includes x86_64 under Rosetta. + +The baseline browser version must match its registered version and the candidate +browser version. The active updater is an independent signed product and may +legitimately be older. Its identity, team, version-directory agreement, binary +hash, Current target and launch-agent hashes are captured. The same snapshot +must be restored through the permanent browser's native API after each test, +including on failure. The test never edits live preferences, forces helper +activation or uninstalls an existing helper. + +For the visible native toolbar, open a blank Guest window in the verified app +and execute `scripts/verify_chromium_toolbar.cua.js` through the Codex computer-use +tool. Set `releaseToolbarOptions` with the verified app path, engine version and +product version. The script refreshes accessibility selectors after each action, +checks open/close/reopen and opens native About from the 0.7.0 banner. Run it for +each DMG's installed app; retain its output with the CLI verification evidence. + +This qualifies browser runtime and a real native update check. It does not prove +updater-service self-replacement: a staged 159 helper still requires the real +signed qualification payload before it can replace an active 158 helper. An +empty Omaha catalog returns `noupdate` for that qualifier, so this remains a +separate release gate. Physical Intel hardware and provider conversations also +remain separate from Rosetta and credential-free functional checks. + +Release publication, private asset replacement and Omaha promotion remain held +until the owner merges the matching PR stack. No qualification command publishes. diff --git a/scripts/package_chromium_release.py b/scripts/package_chromium_release.py index 5ca6ec94e3..eb457800c1 100644 --- a/scripts/package_chromium_release.py +++ b/scripts/package_chromium_release.py @@ -391,7 +391,7 @@ def main(): args.installed_updater_baseline = args.installed_updater_baseline.resolve() baseline_version = plistlib.loads((args.installed_updater_baseline / 'Contents/Info.plist').read_bytes())['CFBundleShortVersionString'] if baseline_version != plistlib.loads((app / 'Contents/Info.plist').read_bytes())['CFBundleShortVersionString']: - raise RuntimeError('Baseline reuse requires exactly the same browser/updater version; use a dedicated clean user for version upgrades') + raise RuntimeError('Baseline reuse requires exactly the same browser version; use a dedicated clean user for browser version upgrades') if args.updater_enabled and not args.defer_runtime_verification: from updater.macos_smoke_scope import UpdaterSmokeScope UpdaterSmokeScope(settings, team, output, baseline_app=args.installed_updater_baseline).require_clean() diff --git a/scripts/updater/macos_smoke_scope.py b/scripts/updater/macos_smoke_scope.py index 423dc34f55..1820a9e9a7 100644 --- a/scripts/updater/macos_smoke_scope.py +++ b/scripts/updater/macos_smoke_scope.py @@ -7,6 +7,7 @@ import time from pathlib import Path import plistlib +import re import subprocess @@ -65,21 +66,32 @@ def baseline_registration(self): if not current.is_symlink() or not current.resolve().is_relative_to(self.controller.resolve()): raise RuntimeError('Expected an existing user updater within its own namespace') helper = current / (self.product + '.app') + if (current.resolve().parent != self.controller.resolve() or + helper.resolve().parent != current.resolve()): + raise RuntimeError('Baseline updater path escapes its version directory') helper_info = plistlib.loads((helper / 'Contents/Info.plist').read_bytes()) if helper_info.get('CFBundleIdentifier') != self.appid: raise RuntimeError('Unexpected baseline updater identity') + helper_version = helper_info.get('CFBundleShortVersionString', '') + if (not re.fullmatch(r'\d+\.\d+\.\d+\.\d+', helper_version) or + any(int(part) > 0xffffffff for part in helper_version.split('.')) or + current.resolve().name != helper_version): + raise RuntimeError('Baseline updater version differs from its installed directory') subprocess.run(['codesign', '--verify', '--deep', '--strict', str(helper)], check=True) helper_details = subprocess.run(['codesign', '-dv', '--verbose=4', str(helper)], capture_output=True, text=True, check=True).stderr if f'TeamIdentifier={self.team}' not in helper_details: raise RuntimeError('Baseline updater is from another signing team') registration = json.loads((self.controller / 'prefs.json').read_text())['updateclientdata']['apps']['com.browseroperator.browseroperator'] if (Path(registration['ecp']).resolve() != app or - registration['pv'] != info['CFBundleShortVersionString'] or - helper_info['CFBundleShortVersionString'] != info['CFBundleShortVersionString']): - raise RuntimeError('Baseline app, updater and registration must have the same version and path') + registration['pv'] != info['CFBundleShortVersionString']): + raise RuntimeError('Baseline app and browser registration must have the same version and path') with (helper / 'Contents/MacOS' / self.product).open('rb') as stream: helper_hash = hashlib.file_digest(stream, 'sha256').hexdigest() - return {'application': str(app), 'version': registration['pv'], 'helper_sha256': helper_hash, + # Browser and updater are independent native products. An older active + # helper can legitimately serve this browser while a new helper awaits + # self-qualification. Preserve that exact helper, never force promotion. + return {'application': str(app), 'version': registration['pv'], + 'helper_version': helper_version, 'helper_sha256': helper_hash, 'current_target': str(current.readlink()), 'launch_agents': {p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in self.agents()}} diff --git a/scripts/updater/test_macos_smoke_scope.py b/scripts/updater/test_macos_smoke_scope.py index 4d2d5239e1..99e71304ac 100644 --- a/scripts/updater/test_macos_smoke_scope.py +++ b/scripts/updater/test_macos_smoke_scope.py @@ -1,6 +1,7 @@ """Ensure release smoke tests never replace an existing updater registration.""" from pathlib import Path +import json import plistlib import subprocess import tempfile @@ -120,3 +121,97 @@ def test_outside_dangling_link_is_preserved_and_rejected(self): with patch.object(scope,'agents',return_value=[]): with self.assertRaisesRegex(RuntimeError,'escapes'):scope.__exit__(None,None,None) self.assertTrue((scope.controller/'Current').is_symlink()) + + +class InstalledBaselineTests(unittest.TestCase): + def fixture(self, root): + evidence = root / 'evidence' + evidence.mkdir() + app = root / 'Applications/Browser Operator.app' + (app / 'Contents').mkdir(parents=True) + (app / 'Contents/Info.plist').write_bytes(plistlib.dumps({ + 'CFBundleIdentifier':'com.browseroperator.BrowserOperator', + 'CFBundleShortVersionString':'159.0.8154.13'})) + scope = UpdaterSmokeScope({'browser_operator_updater_config':'"//config/updater/macos-production.gni"'}, + 'UNITTEAM', evidence, home=root, baseline_app=app, restore_baseline=lambda:None) + helper = scope.controller / '158.0.8127.18/BrowserOperatorUpdater.app' + (helper / 'Contents/MacOS').mkdir(parents=True) + (helper / 'Contents/Info.plist').write_bytes(plistlib.dumps({ + 'CFBundleIdentifier':scope.appid, 'CFBundleShortVersionString':'158.0.8127.18'})) + binary = helper / 'Contents/MacOS/BrowserOperatorUpdater' + binary.write_bytes(b'signed helper fixture') + (scope.controller / 'Current').symlink_to('158.0.8127.18') + prefs = scope.controller / 'prefs.json' + prefs.write_text(json.dumps({'updateclientdata':{'apps':{'com.browseroperator.browseroperator':{ + 'pv':'159.0.8154.13','ecp':str(app)}}}})) + return scope, helper, binary, prefs + + def signed(self, command, **kwargs): + return subprocess.CompletedProcess(command, 0, stderr='TeamIdentifier=UNITTEAM\n') + + def test_older_signed_helper_is_preserved_while_serving_newer_browser(self): + with tempfile.TemporaryDirectory() as temp: + scope, helper, binary, prefs = self.fixture(Path(temp).resolve()) + before = prefs.read_bytes() + with patch('macos_smoke_scope.subprocess.run', side_effect=self.signed) as calls: + with scope: + self.assertEqual('158.0.8127.18', scope.baseline['helper_version']) + self.assertEqual('159.0.8154.13', scope.baseline['version']) + self.assertEqual(before, prefs.read_bytes()) + self.assertEqual(b'signed helper fixture', binary.read_bytes()) + self.assertEqual(Path('158.0.8127.18'), (scope.controller/'Current').readlink()) + self.assertFalse(any('--uninstall' in call.args[0] for call in calls.call_args_list)) + self.assertTrue((scope.evidence/'native-updater-baseline-restored.json').exists()) + + def test_mismatched_browser_registration_refuses_before_test(self): + for field, value in [('pv','158.0.8127.18'), ('ecp','/wrong/app')]: + with self.subTest(field=field), tempfile.TemporaryDirectory() as temp: + scope, _, _, prefs = self.fixture(Path(temp).resolve()) + data=json.loads(prefs.read_text());data['updateclientdata']['apps']['com.browseroperator.browseroperator'][field]=value + prefs.write_text(json.dumps(data));before=prefs.read_bytes() + with patch('macos_smoke_scope.subprocess.run',side_effect=self.signed): + with self.assertRaisesRegex(RuntimeError,'browser registration'): + with scope:self.fail('must not enter') + self.assertEqual(before,prefs.read_bytes()) + + def test_wrong_helper_identity_version_or_signing_team_is_rejected(self): + for change, value, error in [('CFBundleIdentifier','other.updater','identity'), + ('CFBundleShortVersionString','159.0.8154.13','directory'), + ('CFBundleShortVersionString','4294967296.0.0.0','directory'), + ('signing-team','OTHERTEAM','signing team')]: + with self.subTest(change=change,value=value), tempfile.TemporaryDirectory() as temp: + scope, helper, _, _ = self.fixture(Path(temp).resolve()) + info=helper/'Contents/Info.plist' + data=plistlib.loads(info.read_bytes());data[change]=value;info.write_bytes(plistlib.dumps(data)) + def signed(command,**kwargs): + if change=='signing-team' and Path(command[-1]).resolve()==helper.resolve() and '-dv' in command: + return subprocess.CompletedProcess(command,0,stderr='TeamIdentifier=OTHERTEAM\n') + return self.signed(command,**kwargs) + with patch('macos_smoke_scope.subprocess.run',side_effect=signed): + with self.assertRaisesRegex(RuntimeError,error):scope.require_clean() + + def test_helper_path_escape_is_rejected(self): + with tempfile.TemporaryDirectory() as temp: + root=Path(temp).resolve();scope, helper, _, _=self.fixture(root) + target=root/'other/BrowserOperatorUpdater.app';target.parent.mkdir();helper.rename(target) + helper.symlink_to(target) + with patch('macos_smoke_scope.subprocess.run',side_effect=self.signed): + with self.assertRaisesRegex(RuntimeError,'path escapes'):scope.require_clean() + + def test_current_path_escape_is_rejected(self): + with tempfile.TemporaryDirectory() as temp: + root=Path(temp).resolve();scope, _, _, _=self.fixture(root) + current=scope.controller/'Current';current.unlink();current.symlink_to(root/'outside') + with patch('macos_smoke_scope.subprocess.run',side_effect=self.signed): + with self.assertRaisesRegex(RuntimeError,'within its own namespace'):scope.require_clean() + + def test_changed_helper_bytes_fail_exact_restoration_without_uninstall(self): + with tempfile.TemporaryDirectory() as temp: + scope, _, binary, prefs=self.fixture(Path(temp).resolve());before=prefs.read_bytes() + with patch('macos_smoke_scope.subprocess.run',side_effect=self.signed) as calls, \ + patch('macos_smoke_scope.time.sleep'): + with self.assertRaisesRegex(RuntimeError,'not restored exactly'): + with scope:binary.write_bytes(b'changed helper') + self.assertEqual(before,prefs.read_bytes()) + self.assertFalse(any('--uninstall' in call.args[0] for call in calls.call_args_list)) + self.assertTrue((scope.evidence/'native-updater-baseline-RESTORE-FAILED.json').exists()) diff --git a/scripts/verify_chromium_toolbar.cua.js b/scripts/verify_chromium_toolbar.cua.js new file mode 100644 index 0000000000..f532d93874 --- /dev/null +++ b/scripts/verify_chromium_toolbar.cua.js @@ -0,0 +1,57 @@ +// Run this source through Codex's cua_repl in an unlocked macOS GUI session. +// The CLI verification scripts remain authoritative for native update checks. +// Supply releaseToolbarOptions when testing another reviewed release. +{ + const options = typeof releaseToolbarOptions === 'undefined' ? { + app: '/Applications/Browser Operator.app', version: '159.0.8154.13', productVersion: '0.7.0', + } : releaseToolbarOptions; + const app = await cua.getApp(options.app); + const observations = []; + async function observe(label) { + const state = await app.getAXState({disableDiffing: true}); + observations.push({label, state}); + return state; + } + function requireText(state, text) { + if (!state.includes(text)) throw new Error('Missing UI evidence: ' + text); + } + function button(state, name) { + const line = state.split('\n').find(line => line.trim().replace(/^\d+ /, '') === 'button ' + name); + if (!line) throw new Error('Missing button: ' + name); + return Number(line.trim().match(/^\d+/)[0]); + } + let state = await observe('initial'); + // Restrict this flow to the test guest window, never an everyday profile/tab. + requireText(state, 'Browser Operator (Guest)'); + if (!state.includes('URL: about:blank') && !state.includes('URL: chrome://settings/help')) { + throw new Error('Open a blank test guest window before running the toolbar check'); + } + if (state.includes('container AI Assistant panel')) { + await app.click(button(state, 'Close Chat Window')); + state = await observe('reset-closed'); + } + await app.click(button(state, 'AI Assistant')); + state = await observe('opened'); + requireText(state, 'container AI Assistant panel'); + if (state.split('\n').some(line => /^\s*\d+ button Skip$/.test(line))) { + await app.click(button(state, 'Skip')); + state = await observe('welcome-dismissed'); + } + requireText(state, 'Browser Operator ' + options.productVersion); + button(state, 'Check for updates'); + await app.click(button(state, 'Close Chat Window')); + state = await observe('closed'); + if (state.includes('container AI Assistant panel')) throw new Error('AI panel did not close'); + await app.click(button(state, 'AI Assistant')); + state = await observe('reopened'); + requireText(state, 'container AI Assistant panel'); + requireText(state, 'Browser Operator ' + options.productVersion); + await app.click(button(state, 'Check for updates')); + state = await observe('native-about-opened'); + requireText(state, 'Value: chrome://settings/help'); + requireText(state, 'Version ' + options.version + ' (Official Build)'); + await app.getScreenshot(); + nodeRepl.write({schema: 1, passed: true, app: options.app, version: options.version, + productVersion: options.productVersion, checks: ['toolbar-open','panel-close','toolbar-reopen','native-update-banner'], + nativeUpdateCheck: 'verified separately by verify_browser_updater.mjs', observations}); +} From 488f5436b90fe6c2d12cea238f4959147d9117cd Mon Sep 17 00:00:00 2001 From: agentflow-marathon Date: Fri, 27 Nov 2026 20:36:07 -0800 Subject: [PATCH 2/2] Script isolated toolbar launches and pin final qualification PR --- config/releases/0.7.0.json | 7 +- docs/chromium-159-runtime-qualification.md | 12 ++- scripts/launch_chromium_toolbar_check.py | 97 ++++++++++++++++++++++ scripts/verify_chromium_toolbar.cua.js | 36 +++++--- 4 files changed, 137 insertions(+), 15 deletions(-) create mode 100644 scripts/launch_chromium_toolbar_check.py diff --git a/config/releases/0.7.0.json b/config/releases/0.7.0.json index 47fdd0321c..948a86a1b6 100644 --- a/config/releases/0.7.0.json +++ b/config/releases/0.7.0.json @@ -2,12 +2,17 @@ "product_version": "0.7.0", "chromium_version": "159.0.8154.13", "integration_repository": "BrowserOperator/browser-operator-core", - "required_merged_pr": 115, + "required_merged_pr": 116, "required_base_branch": "main", "allowed_mergers": [ "tysonthomas9" ], "additional_merged_prs": [ + { + "repository": "BrowserOperator/browser-operator-core", + "number": 115, + "base_branch": "main" + }, { "repository": "BrowserOperator/browser-operator-core", "number": 114, diff --git a/docs/chromium-159-runtime-qualification.md b/docs/chromium-159-runtime-qualification.md index 4f4cda67a7..bff6ed1cea 100644 --- a/docs/chromium-159-runtime-qualification.md +++ b/docs/chromium-159-runtime-qualification.md @@ -14,12 +14,18 @@ must be restored through the permanent browser's native API after each test, including on failure. The test never edits live preferences, forces helper activation or uninstalls an existing helper. -For the visible native toolbar, open a blank Guest window in the verified app -and execute `scripts/verify_chromium_toolbar.cua.js` through the Codex computer-use -tool. Set `releaseToolbarOptions` with the verified app path, engine version and +For the visible native toolbar, run `scripts/launch_chromium_toolbar_check.py` +with `--release`, `--frozen-input`, `--installed-updater-baseline` and a new +`--output` directory. It verifies and installs the exact DMG copy, opens a Guest +window with a disposable profile and prints its app path. Then execute +`scripts/verify_chromium_toolbar.cua.js` through the Codex computer-use tool. +Set `releaseToolbarOptions` with that verified app path, engine version and product version. The script refreshes accessibility selectors after each action, checks open/close/reopen and opens native About from the 0.7.0 banner. Run it for each DMG's installed app; retain its output with the CLI verification evidence. +Quit the owned Guest app when finished. The launcher then restores the original +native registration and verifies the helper snapshot. Launcher success alone +does not assert the toolbar actions passed; retain both reports. This qualifies browser runtime and a real native update check. It does not prove updater-service self-replacement: a staged 159 helper still requires the real diff --git a/scripts/launch_chromium_toolbar_check.py b/scripts/launch_chromium_toolbar_check.py new file mode 100644 index 0000000000..f63a35088a --- /dev/null +++ b/scripts/launch_chromium_toolbar_check.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 +"""Launch an exact signed DMG copy for the scripted Guest toolbar check.""" +import argparse +import hashlib +import json +from pathlib import Path +import plistlib +import shutil +import subprocess +import tempfile + +from chromium_build_input import load +from chromium_macos_arch import verify_architectures, verify_bundle_version, verify_update_channel +from package_chromium_release import smoke_test, validate_mounted_app +from updater.macos_smoke_scope import UpdaterSmokeScope + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--release', required=True, type=Path) + parser.add_argument('--frozen-input', required=True, type=Path) + parser.add_argument('--installed-updater-baseline', required=True, type=Path) + parser.add_argument('--output', required=True, type=Path) + args = parser.parse_args() + release, frozen = args.release.resolve(), args.frozen_input.resolve() + baseline, output = args.installed_updater_baseline.resolve(), args.output.resolve() + if output.exists(): + raise RuntimeError('Toolbar evidence output must be new') + provenance = load(frozen) + manifest_path = release / 'release-manifest.json' + if not manifest_path.exists(): + manifest_path = release / 'candidate-manifest.json' + manifest = json.loads(manifest_path.read_text()) + if (hashlib.sha256((frozen/'frozen-input.json').read_bytes()).hexdigest() != manifest['source_frozen_manifest_sha256'] or + provenance['version'] != manifest['version'] or manifest['build_settings']['enable_updater'] != 'true'): + raise RuntimeError('Toolbar candidate provenance/updater mismatch') + baseline_info = plistlib.loads((baseline/'Contents/Info.plist').read_bytes()) + if baseline_info['CFBundleShortVersionString'] != manifest['version']: + raise RuntimeError('Toolbar baseline must have the same browser version') + dmg = release/'artifacts'/manifest['dmg'] + if dmg.parent != release/'artifacts': + raise RuntimeError('Unexpected DMG filename') + with dmg.open('rb') as stream: + if hashlib.file_digest(stream,'sha256').hexdigest() != manifest['sha256']: + raise RuntimeError('Toolbar candidate DMG changed') + node = shutil.which('node') + if not node: + raise RuntimeError('Node is required for native baseline restoration') + output.mkdir(parents=True) + app = output/'installed/Browser Operator.app' + app.parent.mkdir() + mounted = plistlib.loads(subprocess.check_output(['hdiutil','attach','-readonly','-nobrowse','-plist',str(dmg)])) + volume = next(Path(entry['mount-point']) for entry in mounted['system-entities'] if 'mount-point' in entry) + try: + subprocess.run(['cp','-cR',str(volume/app.name),str(app)],check=True) + finally: + subprocess.run(['hdiutil','detach',str(volume)],check=True) + validate_mounted_app(app,manifest['team_id'],output/'gatekeeper-app.txt') + verify_architectures(app,manifest['architecture']) + verify_bundle_version(app,manifest['version']) + verify_update_channel(app,manifest['build_settings']) + + def restore_baseline(): + evidence = Path(tempfile.mkdtemp(prefix='restore-baseline-',dir=output)) + smoke_test(baseline,evidence,node,updater_enabled=True,frontend_checks=False) + + with UpdaterSmokeScope(manifest['build_settings'],manifest['team_id'],output, + baseline_app=baseline,restore_baseline=restore_baseline): + with (output/'browser.log').open('x') as log: + child = subprocess.Popen([str(app/'Contents/MacOS/Browser Operator'), + '--guest','--user-data-dir='+str(output/'profile'),'--use-mock-keychain', + '--no-first-run','--no-default-browser-check','--lang=en-US','about:blank'], + stdout=log,stderr=subprocess.STDOUT) + try: + ready = {'application':str(app),'pid':child.pid,'version':manifest['version'], + 'architecture':manifest['architecture'],'product_version':provenance['browser_operator_version'], + 'dmg_sha256':manifest['sha256'],'publication':'held-until-owner-merge'} + (output/'ready.json').write_text(json.dumps(ready,indent=2)+'\n') + print('Run verify_chromium_toolbar.cua.js for this app, then quit its Guest process:',flush=True) + print(json.dumps(ready),flush=True) + code = child.wait(timeout=1200) + if code: + raise RuntimeError('Toolbar test browser exited with code '+str(code)) + finally: + if child.poll() is None: + child.terminate() + try: + child.wait(timeout=20) + except subprocess.TimeoutExpired: + child.kill() + child.wait(timeout=10) + (output/'launcher-report.json').write_text(json.dumps({**ready,'startup_and_trust':'passed', + 'native_baseline_restoration':'passed','toolbar_actions':'recorded separately by CUA script'},indent=2)+'\n') + + +if __name__ == '__main__': + main() diff --git a/scripts/verify_chromium_toolbar.cua.js b/scripts/verify_chromium_toolbar.cua.js index f532d93874..e2595f9781 100644 --- a/scripts/verify_chromium_toolbar.cua.js +++ b/scripts/verify_chromium_toolbar.cua.js @@ -7,10 +7,17 @@ } : releaseToolbarOptions; const app = await cua.getApp(options.app); const observations = []; - async function observe(label) { - const state = await app.getAXState({disableDiffing: true}); - observations.push({label, state}); - return state; + async function observe(label, expected) { + for (let attempt = 0; attempt < 4; attempt++) { + const state = await app.getAXState({disableDiffing: true}); + requireGuestWindow(state); + observations.push({label, attempt, state}); + if (!expected || expected(state)) return state; + // A rendering observation provides missing transition context, without + // reusing old indexes or adding an arbitrary startup delay. + await app.getScreenshot(); + } + throw new Error('UI transition did not complete: ' + label); } function requireText(state, text) { if (!state.includes(text)) throw new Error('Missing UI evidence: ' + text); @@ -20,34 +27,41 @@ if (!line) throw new Error('Missing button: ' + name); return Number(line.trim().match(/^\d+/)[0]); } + function requireGuestWindow(state) { + const windows = state.split('\n').filter(line => /^\d+ standard window /.test(line)); + if (windows.length !== 1 || !windows[0].includes('Browser Operator (Guest)')) { + throw new Error('Expected exactly one inspected Guest window'); + } + } let state = await observe('initial'); // Restrict this flow to the test guest window, never an everyday profile/tab. - requireText(state, 'Browser Operator (Guest)'); + requireGuestWindow(state); if (!state.includes('URL: about:blank') && !state.includes('URL: chrome://settings/help')) { throw new Error('Open a blank test guest window before running the toolbar check'); } if (state.includes('container AI Assistant panel')) { await app.click(button(state, 'Close Chat Window')); - state = await observe('reset-closed'); + state = await observe('reset-closed', state => !state.includes('container AI Assistant panel')); } await app.click(button(state, 'AI Assistant')); - state = await observe('opened'); + state = await observe('opened', state => state.includes('container AI Assistant panel')); requireText(state, 'container AI Assistant panel'); if (state.split('\n').some(line => /^\s*\d+ button Skip$/.test(line))) { await app.click(button(state, 'Skip')); - state = await observe('welcome-dismissed'); + state = await observe('welcome-dismissed', state => state.includes('Browser Operator ' + options.productVersion)); } requireText(state, 'Browser Operator ' + options.productVersion); button(state, 'Check for updates'); await app.click(button(state, 'Close Chat Window')); - state = await observe('closed'); + state = await observe('closed', state => !state.includes('container AI Assistant panel')); if (state.includes('container AI Assistant panel')) throw new Error('AI panel did not close'); await app.click(button(state, 'AI Assistant')); - state = await observe('reopened'); + state = await observe('reopened', state => state.includes('container AI Assistant panel')); requireText(state, 'container AI Assistant panel'); requireText(state, 'Browser Operator ' + options.productVersion); await app.click(button(state, 'Check for updates')); - state = await observe('native-about-opened'); + state = await observe('native-about-opened', state => state.includes('Version ' + options.version + ' (Official Build)')); + requireGuestWindow(state); requireText(state, 'Value: chrome://settings/help'); requireText(state, 'Version ' + options.version + ' (Official Build)'); await app.getScreenshot();