Repository: microsoft/playwright-python

Issue:
`ignoreDefaultArgs` launch parameter is broken
I'm trying to disable default launch arguments however when this parameter is set to True one of two things happen:

```
browser: Browser = chromium.launch(ignoreDefaultArgs=True)
```
will break with:
```
  File "/home/user/.local/lib/python3.8/site-packages/playwright/browser_type.py", line 66, in launch
    normalize_launch_params(params)
  File "/home/user/.local/lib/python3.8/site-packages/playwright/browser_type.py", line 140, in normalize_launch_params
    params["env"] = {name: str(value) for [name, value] in params["env"].items()}
KeyError: 'env'
``` 

I've made a hotfix patch here https://github.com/Granitosaurus/playwright-python/commit/2dc0e107719097e1105e36149a7fe8238c210e38  now the browser launches fine but timesout on `launch()` call:
```
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/playwright/browser_type.py", line 68, in launch
    return from_channel(await self._channel.send("launch", params))
  File "/home/user/.local/lib/python3.8/site-packages/playwright/connection.py", line 39, in send
    result = await callback.future
  File "/usr/lib/python3.8/asyncio/futures.py", line 260, in __await__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.8/asyncio/tasks.py", line 349, in __wakeup
    future.result()
  File "/usr/lib/python3.8/asyncio/futures.py", line 178, in result
    raise self._exception
playwright.helper.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
<launching> /home/user/.cache/ms-playwright/chromium-799411/chrome-linux/chrome 
<launched> pid=301672
[err] [301699:301699:0914/061714.839670:ERROR:sandbox_linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.
```


Discussion:
I thought it might be hanging because some of browser flags were required but I popped the defaults from `playwright` repo here https://github.com/microsoft/playwright/blob/ed3b00efdf0d2e44fc667ade8298ac6d504109bf/src/server/chromium/chromium.ts#L151 and passed them to `launch(args=)` and unfortunately it's still timing out on launch:

```
browser_args = [
  '--disable-background-networking',
  '--enable-features=NetworkService,NetworkServiceInProcess',
  '--disable-background-timer-throttling',
  '--disable-backgrounding-occluded-windows',
  '--disable-breakpad',
  '--disable-client-side-phishing-detection',
  '--disable-component-extensions-with-background-pages',
  '--disable-default-apps',
  '--disable-dev-shm-usage',
  '--disable-extensions',
  # BlinkGenPropertyTrees disabled due to crbug.com/937609
  '--disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading',
  '--disable-hang-monitor',
  '--disable-ipc-flooding-protection',
  '--disable-popup-blocking',
  '--disable-prompt-on-repost',
  '--disable-renderer-backgrounding',
  '--disable-sync',
  '--force-color-profile=srgb',
  '--metrics-recording-only',
  '--no-first-run',
  '--enable-automation',
  '--password-store=basic',
  '--use-mock-keychain',
]
pw.chromium.launch(args=browser_args, ignoreDefaultArgs=True)
# or 
pw.chromium.launch(args=['--enable-automation'], ignoreDefaultArgs=True)
# alternatively passing this list to ignoreDefaultArgs doesn't seem to disable the flags.
pw.chromium.launch(ignoreDefaultArgs=browser_args)
```

From what I understand here:
```
pw.chromium.launch(args=browser_args, ignoreDefaultArgs=True)
# should be equivalent of 
pw.chromium.launch()
```

Resolving patch:
diff --git a/playwright/browser_type.py b/playwright/browser_type.py
--- a/playwright/browser_type.py
+++ b/playwright/browser_type.py
@@ -132,10 +132,9 @@ def normalize_launch_params(params: Dict) -> None:
     if "env" in params:
         params["env"] = {name: str(value) for [name, value] in params["env"].items()}
     if "ignoreDefaultArgs" in params:
-        if isinstance(params["ignoreDefaultArgs"], bool):
+        if params["ignoreDefaultArgs"] is True:
             params["ignoreAllDefaultArgs"] = True
             del params["ignoreDefaultArgs"]
-        params["env"] = {name: str(value) for [name, value] in params["env"].items()}
     if "executablePath" in params:
         params["executablePath"] = str(Path(params["executablePath"]))
     if "downloadsPath" in params:


Test patch:
diff --git a/tests/async/test_issues.py b/tests/async/test_issues.py
new file mode 100644
--- /dev/null
+++ b/tests/async/test_issues.py
@@ -0,0 +1,9 @@
+import pytest
+
+
+@pytest.mark.only_browser("chromium")
+async def test_issue_189(browser_type):
+    browser = await browser_type.launch(ignoreDefaultArgs=["--mute-audio"])
+    page = await browser.newPage()
+    assert await page.evaluate("1 + 1") == 2
+    await browser.close()