Skip to content

[Bug]: Empty sandboxed iframes throw "Blocked script execution" errors in Playwright #33343

Description

@krokben

Version

1.48.2

Steps to reproduce

Example steps:

  1. Clone my repo at https://github.com/krokben/sandboxed-iframe
  2. npm install
  3. npm run start
  4. npm run test
  5. Check for error: Blocked script execution in 'about:blank' because the document's frame is sandboxed and the 'allow-scripts' permission is not set. in the devtools console.

Expected behavior

For it to not throw an error when my website includes an injected iframe with an empty sandbox attribute.

Actual behavior

My page injects an iframe with an empty sandbox attribute. Running this page in the browser throws no error, but in playwright it throws this error:

Blocked script execution in 'about:blank' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.

Additional context

It looks like Playwright tries to run some scripts in all the iframes on the page, which probably leads to this issue. The behavior is then different from what one would expect when just visiting the page in the browser.

I would consider this a bug, but is there maybe some setting I can change in Playwright so that this doesn't happen?

My actual website relies on a third-party plugin that injects these sandboxed iframes, so i cannot influence what their code and add allow-scripts to the sandbox, for example.

Environment

System:
OS: macOS 14.7
CPU: (8) arm64 Apple M1
Memory: 81.13 MB / 8.00 GB
Binaries:
Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
Yarn: 4.1.1 - ~/.nvm/versions/node/v20.15.0/bin/yarn
npm: 10.7.0 - ~/.nvm/versions/node/v20.15.0/bin/npm
pnpm: 9.12.3 - ~/.nvm/versions/node/v20.15.0/bin/pnpm
bun: 1.0.29 - ~/.bun/bin/bun
IDEs:
VSCode: 1.94.2 - /usr/local/bin/code
Languages:
Bash: 3.2.57 - /bin/bash
npmPackages:
@playwright/test: ^1.48.2 => 1.48.2

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions