Skip to content

switch to no-user-gesture-required' - disables userGesture constrain #15856

Closed

Description

@themihai

Is your feature request related to a problem? Please describe.
In the browser window some HTML APIs like requestFullScreen can only be invoked by a gesture from the user. I need to execute requestFullScreen(among other APIs) without a user interaction as my app is remotely controlled (via websockets).

Describe the solution you'd like
I would like a switch such app.commandLine.appendSwitch( 'no-user-gesture-required', 'true'); that should remove this requirement to have user interaction for restricted APIs.

Describe alternatives you've considered
I considered webFrame.executeJavaScript(code[, userGesture, callback]) but this is hard to impossible to use because I need to use it in various contexts (i.e. in a class method so I cannot execute 'this.Xmethod()' in a webframe because the javascript I need to execute is local/scoped not global/at the webframe level .

Activity

  1. changed the title [-]switch to no-user-gesture-required'[/-] [+]switch to no-user-gesture-required' - disables userGesture constrain[/+] on Nov 27, 2018
  2. MarshallOfSound commented on Nov 28, 2018

    @MarshallOfSound
    Member

    @themihai Chromium already has command line switches to disable / change certain gesture requirements / behaviors.

    See this page for an incomplete list: https://peter.sh/experiments/chromium-command-line-switches/

    It sounds like the flag you want is probably --disable-gesture-requirement-for-presentation

  3. riccardocagnasso commented on May 18, 2019

    @riccardocagnasso

    --disable-gesture-requirement-for-presentation
    Doesn't seem to be supported by electron, please reopen

  4. mihaiav commented on Nov 7, 2019

    @mihaiav

    @MarshallOfSound Chromium made it clear that the flags are temporary, experimental and should be used for testing only. No flag exists anymore to disable the gesture requirement.

  5. ThalorSe commented on Dec 29, 2019

    @ThalorSe

    you may use the contents.executeJavaScript api and set userGesture with true

  6. mihaiav commented on Jan 4, 2020

    @mihaiav

    @buptsky contents.executeJavaScript with userGesture:true is not making the events trusted. For example if you fire a keyboard event as below you will find out that the event is set with attribute isTrusted: false.

        sendKey(data){
            const jsContent = `
            try {
                var e = new KeyboardEvent("keydown", {
                    isTrusted: true,
                    bubbles: true,
                    cancelable: true,
                    keyCode:  '` + data.keyCode + `',
                    code: '` + data.code + `',
                    key: '` + data.key + `',
                });
                try {
                    document.dispatchEvent(e);
                    console.log('dispatched', e);
                } catch (errx) {
                    console.log('event error', errx);
                }
            } catch (errx) {
                console.log(errx);
            }
           `;
            const userGesture = true;
            this.windowContents.executeJavaScript(jsContent, userGesture);
        }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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