-
Notifications
You must be signed in to change notification settings - Fork 19
Add browser_launch_opts config option #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
12bb360
Add browser_launch_opts config option
srcrip c8c2dac
Fix misleading test comment
srcrip c3afa2e
Add stronger test proving browser_launch_opts flags work
srcrip 7937ff6
Use pop! since NimbleOptions provides default
srcrip fec6545
Use keyword_list type since Keyword.merge is used
srcrip 545e311
Remove this alltogether
srcrip f200633
Use evaluate
srcrip ce0730f
Revert README changes
srcrip 1683010
Format
ftes 3563ac9
Skip for websocket
ftes 05c1dc4
Merge branch 'main' into add-browser-launch-opts
ftes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| defmodule PhoenixTest.Playwright.BrowserLaunchOptsTest do | ||
| @moduledoc """ | ||
| Tests that browser_launch_opts are passed through to Playwright. | ||
|
|
||
| These tests verify that browser launch flags actually affect browser behavior | ||
| by testing getUserMedia with and without fake media device flags. | ||
| """ | ||
|
|
||
| use PhoenixTest.Playwright.Case, | ||
| async: true, | ||
| browser_pool: false, | ||
| browser_launch_opts: [ | ||
| args: [ | ||
| "--use-fake-ui-for-media-stream", | ||
| "--use-fake-device-for-media-stream" | ||
| ] | ||
| ] | ||
|
|
||
| test "getUserMedia succeeds with fake media device flags", %{conn: conn} do | ||
| conn | ||
| |> visit("/pw/live") | ||
| |> assert_has("h1") | ||
| |> evaluate( | ||
| """ | ||
| navigator.mediaDevices.getUserMedia({ audio: true }) | ||
| .then(() => "success") | ||
| .catch(e => "error: " + e.name) | ||
| """, | ||
| &assert(&1 == "success") | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| defmodule PhoenixTest.Playwright.BrowserLaunchOptsWithoutFlagsTest do | ||
| @moduledoc """ | ||
| Tests that getUserMedia fails WITHOUT the fake media device flags. | ||
| This proves the flags in BrowserLaunchOptsTest actually have an effect. | ||
| """ | ||
|
|
||
| use PhoenixTest.Playwright.Case, | ||
| async: true, | ||
| browser_pool: false | ||
|
|
||
| test "getUserMedia fails without fake media device flags", %{conn: conn} do | ||
| conn | ||
| |> visit("/pw/live") | ||
| |> assert_has("h1") | ||
| |> evaluate( | ||
| """ | ||
| navigator.mediaDevices.getUserMedia({ audio: true }) | ||
| .then(() => "success") | ||
| .catch(e => "error: " + e.name) | ||
| """, | ||
| # Without fake device flags, getUserMedia should fail in headless mode | ||
| &assert(&1 =~ "error:") | ||
| ) | ||
| end | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍