<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: v1.31.2</li>
<li>Operating System: mcr.microsoft.com/playwright:v1.31.2-focal image</li>
<li>Browser: WebKit</li>
<li>Other info: JavaScript disabled</li>
</ul>
<h3 dir="auto">Source code</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I provided exact source code that allows reproducing the issue locally.</li>
</ul>




<p dir="auto"><strong>Config file</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  projects: [
    {
      name: 'Chromium without JS',
      use: { ...devices['Desktop Chrome'], javaScriptEnabled: false },
    },
    {
      name: 'WebKit with JS',
      use: { ...devices['Desktop Safari'], javaScriptEnabled: true },
    },
    {
      name: 'WebKit without JS',
      use: { ...devices['Desktop Safari'], javaScriptEnabled: false },
    },
  ]
});"><pre class="notranslate"><span class="pl-c">// playwright.config.ts</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">defineConfig</span><span class="pl-kos">,</span> <span class="pl-s1">devices</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@playwright/test'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-en">defineConfig</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">projects</span>: <span class="pl-kos">[</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">'Chromium without JS'</span><span class="pl-kos">,</span>
      <span class="pl-c1">use</span>: <span class="pl-kos">{</span> ...<span class="pl-s1">devices</span><span class="pl-kos">[</span><span class="pl-s">'Desktop Chrome'</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-c1">javaScriptEnabled</span>: <span class="pl-c1">false</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">'WebKit with JS'</span><span class="pl-kos">,</span>
      <span class="pl-c1">use</span>: <span class="pl-kos">{</span> ...<span class="pl-s1">devices</span><span class="pl-kos">[</span><span class="pl-s">'Desktop Safari'</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-c1">javaScriptEnabled</span>: <span class="pl-c1">true</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">'WebKit without JS'</span><span class="pl-kos">,</span>
      <span class="pl-c1">use</span>: <span class="pl-kos">{</span> ...<span class="pl-s1">devices</span><span class="pl-kos">[</span><span class="pl-s">'Desktop Safari'</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-c1">javaScriptEnabled</span>: <span class="pl-c1">false</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-kos">]</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Test file (self-contained)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { test, expect } from '@playwright/test';

test('Page.setContent', async ({ page }) =&gt; {
  await page.setContent('&lt;h1&gt;Hello&lt;/h1&gt;')

  await expect(page.locator('h1')).toHaveText('Hello')
})
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">test</span><span class="pl-kos">,</span> <span class="pl-s1">expect</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@playwright/test'</span><span class="pl-kos">;</span>

<span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">'Page.setContent'</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> page <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">setContent</span><span class="pl-kos">(</span><span class="pl-s">'&lt;h1&gt;Hello&lt;/h1&gt;'</span><span class="pl-kos">)</span>

  <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'h1'</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toHaveText</span><span class="pl-kos">(</span><span class="pl-s">'Hello'</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span></pre></div>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto">Tests pass.</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">The test fails when JavaScript is not available in WebKit:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Running 3 tests using 2 workers

  ✓  1 [Chromium without JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent (1.3s)
  ✓  2 [WebKit with JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent (1.3s)
  ✘  3 [WebKit without JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent (30.0s)


  1) [WebKit without JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent ──────────────────

    Test timeout of 30000ms exceeded.

    page.setContent: Navigation failed because page was closed!
    =========================== logs ===========================
    setting frame content, waiting until &quot;load&quot;
    ============================================================

      689 |
      690 | test.only('Page.setContent', async ({ page }) =&gt; {
    &gt; 691 |   await page.setContent('&lt;h1&gt;Hello&lt;/h1&gt;')
          |              ^
      692 |
      693 |   await expect(page.locator('h1')).toHaveText('Hello')
      694 | })

        at /app/integration/publishing-a-prereview.spec.ts:691:14

    Pending operations:
      - page.setContent at integration/publishing-a-prereview.spec.ts:691:14

  1 failed
    [WebKit without JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent ───────────────────
  2 passed (44.0s)"><pre class="notranslate"><code class="notranslate">Running 3 tests using 2 workers

  ✓  1 [Chromium without JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent (1.3s)
  ✓  2 [WebKit with JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent (1.3s)
  ✘  3 [WebKit without JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent (30.0s)


  1) [WebKit without JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent ──────────────────

    Test timeout of 30000ms exceeded.

    page.setContent: Navigation failed because page was closed!
    =========================== logs ===========================
    setting frame content, waiting until "load"
    ============================================================

      689 |
      690 | test.only('Page.setContent', async ({ page }) =&gt; {
    &gt; 691 |   await page.setContent('&lt;h1&gt;Hello&lt;/h1&gt;')
          |              ^
      692 |
      693 |   await expect(page.locator('h1')).toHaveText('Hello')
      694 | })

        at /app/integration/publishing-a-prereview.spec.ts:691:14

    Pending operations:
      - page.setContent at integration/publishing-a-prereview.spec.ts:691:14

  1 failed
    [WebKit without JS] › publishing-a-prereview.spec.ts:690:6 › Page.setContent ───────────────────
  2 passed (44.0s)
</code></pre></div>
<p dir="auto">The failure screenshot shows that it was able to set the content:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1784740/222746889-7013ffd8-8414-4607-954c-41c90265dd52.png"><img src="https://user-images.githubusercontent.com/1784740/222746889-7013ffd8-8414-4607-954c-41c90265dd52.png" alt="test-failed-1" style="max-width: 100%;"></a></p>
<p dir="auto">I've tried all the <code class="notranslate">waitUntil</code> options, and none work.</p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.34.3]</li>
<li>Operating System: [Windows 11]</li>
<li>Browser: [Chrome]</li>
</ul>




<p dir="auto"><strong>Config file</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  projects: [
    {
      name: 'Chrome',
      use: {
        ...devices['Desktop Chrome'],
      },
    },
  ],
});"><pre class="notranslate"><span class="pl-c">// playwright.config.ts</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">defineConfig</span><span class="pl-kos">,</span> <span class="pl-s1">devices</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@playwright/test'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-en">defineConfig</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">projects</span>: <span class="pl-kos">[</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">'Chrome'</span><span class="pl-kos">,</span>
      <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
        ...<span class="pl-s1">devices</span><span class="pl-kos">[</span><span class="pl-s">'Desktop Chrome'</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-kos">]</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Test file (self-contained)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="test('user should upload too big file and expect error appears successfully', async ({ page }) =&gt; {
    await page.getByTestId('upload-file-input').setInputFiles('./Assets/11mbphoto.jpg')
    await expect(page.getByText('Error: file size is too big')).toBeVisible()
    await expect(page.locator('div').filter({ hasText: /^Next step$/ })).not.toBeVisible()
  })"><pre class="notranslate"><span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">'user should upload too big file and expect error appears successfully'</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> page <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">await</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">getByTestId</span><span class="pl-kos">(</span><span class="pl-s">'upload-file-input'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">setInputFiles</span><span class="pl-kos">(</span><span class="pl-s">'./Assets/11mbphoto.jpg'</span><span class="pl-kos">)</span>
    <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">getByText</span><span class="pl-kos">(</span><span class="pl-s">'Error: file size is too big'</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toBeVisible</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
    <span class="pl-k">await</span> <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'div'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">hasText</span>: <span class="pl-pds"><span class="pl-c1">/</span><span class="pl-cce">^</span>Next step<span class="pl-cce">$</span><span class="pl-c1">/</span></span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">not</span><span class="pl-kos">.</span><span class="pl-en">toBeVisible</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">[Describe actual behavior]</p>
<p dir="auto">if you run this test with setInputFiles in new ui mode test will fail, becouze file not uploaded.<br>
<a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/29463426/241989247-90a9710a-807a-4ff2-afa0-a6409d6827c2.png"><img src="https://user-images.githubusercontent.com/29463426/241989247-90a9710a-807a-4ff2-afa0-a6409d6827c2.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">if you run same test in vs code headless mode it pass<br>
<a target="_blank" rel="noopener noreferrer" href="https://user-images.githubusercontent.com/29463426/241989566-d8c3e9b4-a8b0-4ff8-ace6-174a704745f9.png"><img src="https://user-images.githubusercontent.com/29463426/241989566-d8c3e9b4-a8b0-4ff8-ace6-174a704745f9.png" alt="image" style="max-width: 100%;"></a></p>