Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(browser): bound executable assignment expressions [C7,O5]

Corey Olson9a9b165ac6ee
diff --git a/src/browser-launch-source.js b/src/browser-launch-source.js
index 9e2aa8d3..a15faf95 100644
--- a/src/browser-launch-source.js
+++ b/src/browser-launch-source.js
@@ -67,9 +67,11 @@ export function sourceLaunchesBrowser(source) {
// Union executable identifier assignments, including later writes and conditional branches.
// Never let a later non-browser value erase a possible browser value; strings/comments are blank in code.
for (const match of code.matchAll(/(?<![\w$.])([$A-Z_a-z][$\w]*)\s*=(?!=|>)/gu)) {
+ // A property write is not a write to the same-named local identifier, even with whitespace.
+ if (code.slice(0, match.index).trimEnd().endsWith('.')) continue;
const start = match.index + match[0].length;
let end = start;
- while (end < code.length && !';\n'.includes(code[end])) {
+ while (end < code.length && !';,)]}\n'.includes(code[end])) {
if ('([{'.includes(code[end])) {
const close = closing(code, end);
if (close === null) return CHROME.test(source);
diff --git a/test/test-resources.test.js b/test/test-resources.test.js
index dfdd0b74..bd9cc5bd 100644
--- a/test/test-resources.test.js
+++ b/test/test-resources.test.js
@@ -509,12 +509,15 @@ test('later executable assignments retain every possible browser launch value [C
'test/quoted-write.test.js': imports + 'const generated = ' + JSON.stringify("let executable; executable = 'google-chrome'; spawnSync(executable, []);")
+ "; spawnSync('git', ['status']);",
'test/comment-write.test.js': imports + "// executable = 'google-chrome';\nspawnSync('git', ['status']);",
+ 'test/default-body.test.js': imports + "let executable = 'git'; function configure(executable = 'git') { const warning = 'Chrome'; } spawnSync(executable, ['status']);",
+ 'test/default-browser.test.js': imports + "function run(executable = 'google-chrome') { return spawnSync(executable, []); }",
+ 'test/property-write.test.js': imports + "let executable = 'git'; const options = {}; options . executable = 'google-chrome'; spawnSync(executable, ['status']);",
});
- for (const name of ['later-write', 'alias-write', 'replaced-write', 'conditional-write', 'parameter-write']) {
+ for (const name of ['later-write', 'alias-write', 'replaced-write', 'conditional-write', 'parameter-write', 'default-browser']) {
assert.equal(await testsNeedBrowser(root, [`test/${name}.test.js`], { byLaunch: true }), true,
`${name}: a later assignment keeps a possible browser value conservatively`);
}
- for (const name of ['quoted-write', 'comment-write']) {
+ for (const name of ['quoted-write', 'comment-write', 'default-body', 'property-write']) {
const file = `test/${name}.test.js`;
assert.equal(await testsNeedBrowser(root, [file], { byLaunch: true }), false, `${name}: assignment text is not executed`);
assert.equal(await testsNeedBrowser(root, [file], { byLaunch: false }), true, `${name}: default admission remains conservative`);