<!--
{
  "availability" : [
    "iOS: 18.4.0 -",
    "iPadOS: 18.4.0 -",
    "macCatalyst: 18.4.0 -",
    "macOS: 15.4.0 -",
    "visionOS: 2.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKWebExtensionContext/performAction(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKWebExtensionContext(im)performActionForTab:"
  },
  "title" : "performAction(for:)"
}
-->

# performAction(for:)

Performs the extension action associated with the specified tab or performs the default action if `nil` is passed.

```
func performAction(for tab: (any WKWebExtensionTab)?)
```

## Parameters

`tab`

The tab for which to perform the extension action, or `nil` to perform the default action.

## Discussion

Performing the action will mark the tab, if specified, as having an active user gesture. When the `tab` parameter is `nil`, the default action is performed. The action can either trigger an event or display a popup, depending on how the extension is configured.

If the action is configured to display a popup, implementing the appropriate web extension controller delegate method is required; otherwise, no action is performed for popup actions.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)