Skip to content

webFrame.executeJavaScript(InIsolatedWorld) APIs don't return promises #12159

Closed

Description

@bughit
  • Electron version: recent master (dfa1dc4)
  • Operating system: win7 sp1 x64

Expected behavior

Docs say they return promises.

However since they don't and execution is synchronous, this is an opportunity to change the behavior without breaking anything. They should return the result.

Actual behavior

they return undefined

How to reproduce

call the api

Activity

  1. felixrieseberg commented on Mar 13, 2018

    @felixrieseberg
    Member

    Do you mean this API? Because it's documented to use a callback instead of a Promise.

  2. bughit commented on Mar 13, 2018

    @bughit
    ContributorAuthor

    Where does it say "instead"?

    For webFrame.executeJavaScript it says:

    Returns Promise - A promise that resolves with the result of the executed code or is rejected if the result of the code is a rejected promise.

    For webFrame.executeJavaScriptInIsolatedWorld

    Work like executeJavaScript

    However since it's synchronous and unless there are plans to support async mode, it might as well return the result.

  3. MarshallOfSound commented on Mar 14, 2018

    @MarshallOfSound
    Member

    This is actually just incorrect docs, webFrame.executeJavaScript does not return a promise. webContents.executeJavaScript does.

    Just need to correct the docs for webFrame

  4. FibreFoX commented on Dec 12, 2018

    @FibreFoX

    This was mentioned in an older isse before:
    #9804

    Maybe this should be done equal?! So it makes less confusion?!

  5. bughit commented on Jul 8, 2019

    @bughit
    ContributorAuthor

    @MarshallOfSound

    There three issues here:

    1. docs: documenting that these are synchronous and that they don't return promises
    2. bug: (webFrame.executeJavaScript(InIsolatedWorld) APIs swallow errors #12160) they swallow errors, which was auto-closed, I'll check it with 6.0
    3. enhancement: since they are synchronous they can return the eval result
  6. bughit commented on Jul 8, 2019

    @bughit
    ContributorAuthor

    no longer applies, see #19161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions