diff --git a/src/extension-support/tw-unsandboxed-extension-runner.js b/src/extension-support/tw-unsandboxed-extension-runner.js index 6f44d7cb22f..45312e76ac4 100644 --- a/src/extension-support/tw-unsandboxed-extension-runner.js +++ b/src/extension-support/tw-unsandboxed-extension-runner.js @@ -131,6 +131,8 @@ const setupUnsandboxedExtensionAPI = vm => new Promise(resolve => { global.Scratch = Scratch; global.ScratchExtensions = createScratchX(Scratch); + + vm.emit('CREATE_UNSANDBOXED_EXTENSION_API', Scratch); }); /** diff --git a/test/unit/tw_unsandboxed_extensions.js b/test/unit/tw_unsandboxed_extensions.js index 48cf89c12ed..54dc34fcd34 100644 --- a/test/unit/tw_unsandboxed_extensions.js +++ b/test/unit/tw_unsandboxed_extensions.js @@ -417,3 +417,13 @@ test('canEmbed', async t => { t.end(); }); + +test('CREATE_UNSANDBOXED_EXTENSION_API', t => { + const vm = new VirtualMachine(); + vm.on('CREATE_UNSANDBOXED_EXTENSION_API', api => { + api.extraStuff = 'aaaa'; + }); + UnsandboxedExtensionRunner.setupUnsandboxedExtensionAPI(vm); + t.equal(global.Scratch.extraStuff, 'aaaa'); + t.end(); +});