Skip to content

Commit

Permalink
Allow scratch-gui (and others) to extend unsandboxed extension APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Apr 6, 2024
1 parent 60f9740 commit 11eec66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/extension-support/tw-unsandboxed-extension-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ const setupUnsandboxedExtensionAPI = vm => new Promise(resolve => {

global.Scratch = Scratch;
global.ScratchExtensions = createScratchX(Scratch);

vm.emit('CREATE_UNSANDBOXED_EXTENSION_API', Scratch);
});

/**
Expand Down
10 changes: 10 additions & 0 deletions test/unit/tw_unsandboxed_extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

0 comments on commit 11eec66

Please sign in to comment.