Class WebExtension.MessageSender

Enclosing class:

@UiThread public static class WebExtension.MessageSender extends Object
Describes the sender of a message from a WebExtension.

See also: WebExtensions/API/runtime/MessageSender

  • Field Details

    • webExtension

      @NonNull public final WebExtension webExtension
      WebExtension that sent this message.
    • session

      @Nullable public final GeckoSession session
      GeckoSession that sent this message. null if coming from a background script.

      public static final int ENV_TYPE_EXTENSION
      This sender originated inside a privileged extension context like a background script.
      See Also:

      public static final int ENV_TYPE_CONTENT_SCRIPT
      This sender originated inside a content script.
      See Also:
    • environmentType

      public final int environmentType
      Type of environment that sent this message, either
    • url

      @NonNull public final String url
      URL of the frame that sent this message.

      Use this value together with isTopLevel to verify that the message is coming from the expected page. Only top level frames can be trusted.

  • Constructor Details

    • MessageSender

      protected MessageSender()
      Override for testing.
  • Method Details

    • isTopLevel

      public boolean isTopLevel()
      Whether this MessageSender belongs to a top level frame.
      true if the MessageSender was sent from the top level frame, false otherwise.