microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.45k stars 3.63k forks source link

[BUG] 'noscript' sections always invisible in ui-mode #27504

Closed mash-graz closed 9 months ago

mash-graz commented 1 year ago

System info

Source code

Link to the GitHub repository with the repro

https://github.com/mash-graz/playwright-noscript-issue

Steps

run the example in the provided git repo in the ui-mode viewer

Expected

You will see, that the visual output of the <noscript>...</noscript> are not visible in the ui-mode viewer, although the tests look plausible and in VSCodium we even get correct visual results.

Actual

NoScript sections of html-code are never rendered in playwrights ui-mode.

As attachments you'll find screenshots of ui-mode rendering vs. vscodium usage.

Screenshot-ui-viewer Screenshot-vscodium

mash-graz commented 1 year ago

Just two additional observations concerning this issue:

  1. the actual noscript tag behavor in ui-mode seems to be caused by change #5133:

    before this commit removeNoScript was respecting the javaScriptEnabled-context settings:

    const removeNoScript = !frame._page.context()._options.javaScriptEnabled;

    but afterward it seems to be always active and ignore the context settings:

        private _removeNoScript = true;
  2. A very similar issue affecting test selectors seems to be caused by #15887, which also doesn't take the present javaScriptEnabled-context into account.

Unfortunately I'm not enough familiar with all the playwright internals to provide reliable fixes for these issues.

mash-graz commented 1 year ago

Please take a look at the suggest fix for these issues.

The actual changes look rather trivial. In fact there is no code added, but just old dysfunctional cruft removed.

The included tests should testify the changed behavior and actual need for these modifications sufficiently.

I perfectly understand, that you may not see the importance of all these <noscript>-related improvements. Usually this kind of stuff only affects little insignificant text messages on web pages, reminding you about disabled JS or adblockers, but if you have to debug and test the lifecycle of custom elements, SSG prerendering and island architectures, you really need access to this kind of information and behavior control for much more serious tasks. That's how I stumbled over these issues in practice.