How to detect / identify PWA (web apps) windows?

Firefox has now web-apps support:

But I’m unable to “detect” web-app being opened.
For example:

browser.windows.onCreated.addListener(console.log);
// will print this after opening "WhatsApp" from taskbar:
{
  "id": 2830,
  "focused": false,
  "top": 236,
  "left": 513,
  "width": 1738,
  "height": 1066,
  "incognito": false,
  "type": "normal",
  "state": "normal",
  "alwaysOnTop": false,
  "title": "Firefox Developer Edition"
}

And querying Window + Tab data later on doesn’t get anything web-app specific.
Tab object:

{
  "id": 323,
  "index": 0,
  "windowId": 2716,
  "highlighted": true,
  "active": true,
  "attention": false,
  "pinned": false,
  "status": "complete",
  "hidden": false,
  "discarded": false,
  "incognito": false,
  "width": 1722,
  "height": 1023,
  "lastAccessed": 1786611813460,
  "audible": false,
  "autoDiscardable": true,
  "mutedInfo": {
    "muted": false
  },
  "isInReaderMode": false,
  "sharingState": {
    "camera": false,
    "microphone": false
  },
  "successorTabId": -1,
  "groupId": -1,
  "splitViewId": -1,
  "cookieStoreId": "firefox-default",
  "url": "https://web.whatsapp.com/",
  "title": "WhatsApp",
  "favIconUrl": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACuklEQVQ4T3WRzW7TWBiG3+/YjvMDlUFCQqJlXCQkJBZEsGOVXAFEM23pLKbtpjF/qnsFTa+gjpCgYZOCEJRGKJ0rSOcGwCxGQpopsfgVG7AEbdLE53zIDY6ggmdl+Xzvo/N+h3AAu3GjsCfkpR2DLxPDHukKmJJ8JvgGjOUX014wHAZAyUeh6Vpv9jpLfSKXiEJdsm8qPE/3BCTRuR2DC1IAmb7mHZPa8tacFw4F+aZrdXZ3W32BfKSJ6lEjXfFLg4GEM49c+4vWc0e6YuFQD35W04uxZF9wolFeMSS7Alh8eeWul4R+xtkHN11WvEIg79+/bi3S8aZjs1JtU1L11WTNtR9fndEVzx5Kp0sHb5EwunHDS0VYSJFepONPynUwz6Y1MR6UVgN73Wkzwe7rYvnd77crw9R3xJV3dmVbEd8je2P+mSQKX0/UinbTtUS3+4kYkAJrwZXVuWHqABfq11ufTbbp1KN51piq//1Zc+ODsw+cVo9QUDqVtqfubCaBg1yoX/NCEwv7AqtH1aczA0Gh7tjvU+rZpyyFWVAxrjX471rJ08Wcfuh4kmLBerk90kXgz9aKyeHF+rX8u1zU+pyiMNvTljVWv2kSFQisSTO9GJS8cGzDaRHIigWepngml8mOf7/1WPIhI5sdjW1FgCmBeDcws0eArtWVqg2iNbIbTgFStTQh5rYnV9cSQcL5+87sruCZSOeQCfe2p+5unmyUV3rELjQxvi9gpVqGEsX/p1e3hslfcGq9vKDAXl+n6ts/ai6NNpwKsVrKGWI86sJmoazDSvj+9GB5CfHbf4w6S3rErqHgZ7LZYlyZxjbmmwAux0OCBz0NBeR6tKUDfkcH9nTkI8F5Zlg6U3XMzFS2vu2LxhrlFphDpeEfgxFA6QFx5BLj3J6G/JcUwERBLsLfpqTNYOLHml8BaXBF9e4/dbQAAAAASUVORK5CYII="
}

UPDATE:
There is actually one way to detect PWA, but it requires "<all_urls>" permission, then you can inject and execute this JS code:

window.matchMedia('(display-mode: minimal-ui)').matches

I don’t think I need to stress out how much I want to avoid "<all_urls>" :slight_smile: .

Currently in Firefox WebExtensions API, standalone web-app (SSB / PWA) windows are classified under standard windows.WindowType as "normal" without an explicit type: "app" property or dedicated PWA metadata flag.

Because the underlying browser engine initializes these windows with standard window semantics, browser.windows.onCreated and browser.windows.get() return type: "normal".

If you need to detect or isolate web-app / SSB windows within your extension, here are two effective workarounds:

  1. Check Tab URL and Count upon Window Creation:
    Web-app windows typically open with a single dedicated tab pointing directly to the app’s scope URL:

    browser.windows.onCreated.addListener(async (window) => {
      const tabs = await browser.tabs.query({ windowId: window.id });
      if (tabs.length === 1 && tabs[0].url.startsWith('https://web.whatsapp.com')) {
        console.log('Target web app window detected:', window.id);
      }
    });
    
  2. Inspect Window UI Features & Initial Tab Context:
    Standard Firefox windows include regular tab bars and navigation bars, whereas PWA instances hide navigation controls. Checking tabs[0] properties immediately after the onCreated or onUpdated event lets you tag and track active app windows cleanly.

Hopefully Firefox WebExtensions will expose a native isPwa or distinct window type flag in future API updates as web app support matures!

I don’t think 1. would work well, since “shift + click” opens pages in new windows with singe tab, so same as web apps.

Seconds workaround is much better though, for example window with height 1066px will be 986px high for normal windows and 1023px in web-apps.
But these numbers are quite dynamic across devices/users/browser_versions/time etc…