diff --git a/src/serialization/sb3.js b/src/serialization/sb3.js index a87d566d5..ccbe4d1db 100644 --- a/src/serialization/sb3.js +++ b/src/serialization/sb3.js @@ -1025,6 +1025,9 @@ const parseScratchObject = function (object, runtime, extensions, zip) { // This will be deleted after we are done parsing and ordering the targets list. target.targetPaneOrder = object.targetPaneOrder; } + if (object.hasOwnProperty('draggable')) { + target.draggable = object.draggable; + } Promise.all(costumePromises).then(costumes => { sprite.costumes = costumes; }); diff --git a/test/fixtures/draggable.sb3 b/test/fixtures/draggable.sb3 new file mode 100644 index 000000000..06cbdda54 Binary files /dev/null and b/test/fixtures/draggable.sb3 differ diff --git a/test/unit/serialization_sb3.js b/test/unit/serialization_sb3.js index 74f146db3..9e9785b2a 100644 --- a/test/unit/serialization_sb3.js +++ b/test/unit/serialization_sb3.js @@ -9,6 +9,7 @@ const commentsSB3ProjectPath = path.resolve(__dirname, '../fixtures/comments.sb3 const commentsSB3NoDupeIds = path.resolve(__dirname, '../fixtures/comments_no_duplicate_id_serialization.sb3'); const variableReporterSB2ProjectPath = path.resolve(__dirname, '../fixtures/top-level-variable-reporter.sb2'); const topLevelReportersProjectPath = path.resolve(__dirname, '../fixtures/top-level-reporters.sb3'); +const draggableSB3ProjectPath = path.resolve(__dirname, '../fixtures/draggable.sb3'); const FakeRenderer = require('../fixtures/fake-renderer'); test('serialize', t => { @@ -288,3 +289,14 @@ test('(#1608) serializeBlocks maintains top level variable reporters', t => { t.end(); }); }); + +test('(#1850) sprite draggability state read when loading SB3 file', t => { + const vm = new VirtualMachine(); + vm.loadProject(readFileToBuffer(draggableSB3ProjectPath)) + .then(() => { + const sprite1Obj = vm.runtime.targets.find(target => target.sprite.name === 'Sprite1'); + // Sprite1 in project should have draggable set to true + t.equal(sprite1Obj.draggable, true); + t.end(); + }); +});