diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 8d82b22c..5113dce2 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -524,7 +524,9 @@ class VirtualMachine extends EventEmitter { /** * tw: Serialize the project into a map of files without actually zipping the project. - * @returns {Record} Files of the project. + * The buffers returned are the exact same ones used internally, not copies. Avoid directly + * manipulating them (except project.json, which is created by this function). + * @returns {Record} Map of file name to the raw data for that file. */ saveProjectSb3DontZip () { const soundDescs = serializeSounds(this.runtime); diff --git a/test/integration/tw_save_project_sb3.js b/test/integration/tw_save_project_sb3.js index d1cb5d57..69d51bb5 100644 --- a/test/integration/tw_save_project_sb3.js +++ b/test/integration/tw_save_project_sb3.js @@ -78,5 +78,9 @@ test('saveProjectSb3DontZip', async t => { t.equal(map['d9c625ae1996b615a146ac2a7dbe74d7.svg'].byteLength, 691); t.equal(map['cd21514d0531fdffb22204e0ec5ed84a.svg'].byteLength, 202); + // Make sure that the asset buffers returned are the exact same as the ones used internally, not copies. + const costume = vm.runtime.targets[0].getCostumes()[0]; + t.equal(map['cd21514d0531fdffb22204e0ec5ed84a.svg'], costume.asset.data); + t.end(); });