Skip to content

[Feature] Allow display-mode media query to be emulated for standalone PWA #26853

Closed

Description

I would like to be able to run tests with the app (a PWA) in standalone mode, as though it had been installed as a desktop/home page app.

Use case: The app code needs to adapt to whether it is in browser or standalone mode and fine tune the UI, for example to add a back navigation UI in the absence of a browser Back button. I need to test that these changes work but I can’t figure out how to do it. Playwright always runs the tests in regular browser mode.

My app tests the mode at runtime with a media query:

const displayModeQuery = window.matchMedia('(display-mode: standalone)');
const isStandalone = displayModeQuery.matches

I would like to write something like this in my test setup, but it isn’t valid:

await page.emulateMedia({ display-mode: 'standalone' });

(My PWA manifest.json contains "display": "standalone")

Activity

  1. MattHorrocksNetwealth commented on Mar 13, 2024

    @MattHorrocksNetwealth

    Ben Staveley-Taylor (@BenStaveleyTaylor)

    I have the same requirement as you! Did you find any work arounds for this?

  2. BenStaveleyTaylor commented on Mar 13, 2024

    @BenStaveleyTaylor
    Author

    MattHorrocksNetwealth No, sorry. I am not working in this area any more so will leave it to the Playwright team to comment further.

  3. MattHorrocksNetwealth commented on Mar 14, 2024

    @MattHorrocksNetwealth

    Pavel Feldman (@pavelfeldman) Starting chromium with something like the code below seems like it should be enough to force the browser into standalone mode, but the --app flag is being ignored. Do you know why? Is this expected behaviour to ignore certain flags?

    var Browser = await PlaywrightMain.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false, Args = new string[] { "--app=https://url-for-pwa" } });

  4. pavelfeldman commented on Aug 16, 2024

    @pavelfeldman
    Member

    Why was this issue closed?

    Thank you for your involvement. This issue was closed due to limited engagement (upvotes/activity), lack of recent activity, and insufficient actionability. To maintain a manageable database, we prioritize issues based on these factors.

    If you disagree with this closure, please open a new issue and reference this one. More support or clarity on its necessity may prompt a review. Your understanding and cooperation are appreciated.

  5. Scheepers-db commented on Mar 6, 2026

    @Scheepers-db

    This would be great as a way of testing WebView embedded pages

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions