mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 05:22:58 -05:00
Script check: keep reporting SAVECHANGES read through an alias as a file write
A script can pass SaveOptions.SAVECHANGES to a document's close through a variable that holds SaveOptions, or through a property of an object that holds it. The check reports any SAVECHANGES member as a file write, whatever the receiver. A test now covers the alias and member cases, and a key of the script's own object literal, which is not reported.
This commit is contained in:
1 parent
0da268733e
commit
018dfc2482
1 file changed
+14
@@ -621,6 +621,20 @@ fn closing_with_save_changes_writes_a_file() {
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", &[4, 5, 7][..])]);
|
||||
}
|
||||
|
||||
/// `SAVECHANGES` read as a member of anything but `SaveOptions` may still be the save option: through
|
||||
/// an alias of `SaveOptions` or through an object that holds it. A key of the script's own object
|
||||
/// literal is not a read, so it writes nothing.
|
||||
#[test]
|
||||
fn save_changes_through_another_receiver_writes_a_file() {
|
||||
let r = report(concat!(
|
||||
"var o = SaveOptions; app.activeDocument.close(o.SAVECHANGES);\n",
|
||||
"var k = {how: SaveOptions}; documents[0].close(k.how.SAVECHANGES);\n",
|
||||
"var own = {SAVECHANGES: 1};\n",
|
||||
));
|
||||
assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[1, 2][..]));
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", &[1, 2][..])]);
|
||||
}
|
||||
|
||||
/// `saveAs` and `exportFile` called with their names as string literals in brackets write the file
|
||||
/// too; reading the method without calling it does not.
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user