Skip to content

Dynamic menu potential bug in sandboxed extension #229

@totchi-lagawi

Description

@totchi-lagawi

Expected Behavior

When loading a sandboxed extension with a defined dynamic menu, the dynamic menu should work as expected.

Actual Behavior

All the blocks in the block panel stack together at the top of the panel (which isn't important, as it is caused by the following problem), and the console throws the error Uncaught TypeError: e[t] is undefined. The problem came from the function _getExtensionMenuItems. It takes as argument argumentObject, and menuItemFunctionName. It tries to access the function with extensionObject[menuItemFunctionName], but when the extension is sandboxed, this does not exist. The function name is correct. Loading the extension in unsandboxed mode works.

Steps to Reproduce

Load the following extension :

class Extension {
    getInfo() {
        return {
            id: "extension",
            name: "Extension",
            blocks: [
                {
                    opcode: "block",
                    blocktype: "command",
                    text: "A block with an argument : [ARG]",
                    arguments: {
                        ARG: {
                            type: "string",
                            menu: "extensionMenu"
                        }
                    }
                }
            ],
            menus: {
                extensionMenu: {
                    items: "extensionMenuFunction"
                }
            }
        }
    }

    block() {
        console.log("Hello world!")
    }

    extensionMenuFunction() {
        return ["Hello", "world", "!"]
    }
}

Scratch.extensions.register(new Extension())

Operating System and Browser

Firefox 131.0.3 (64-bit) - Windows 11 24H2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions