Skip to content

[BUG] inconsistency with OOPIF  #5815

Closed

Description

Context:

  • Playwright Version: 1.9.2
  • Operating System: Mac
  • Node.js version: 14.15.1
  • Browser: Chromium
  • Extra: Persistent context to load an extension

Code Snippet

I have created a small repo here:

  • git clone
  • npm i
  • node pw.js

But the 2 main parts are those

Playwright launch script

const { chromium } = require('playwright')
const path = require('path')
;(async () => {
  const EXTENSION_PATH = path.resolve('./ext')
  const context = await chromium.launchPersistentContext(`userDataDir`, {
    defaultViewport: null,
    headless: false,
    timeout: 0,
    devtools: true,
    ignoreDefaultArgs: [
      `--no-sandbox`,
      `--disable-default-apps`,
      `--disable-dev-shm-usage`,
      `--disable-sync`,
      `--disable-hang-monitor`,
      `--disable-extensions`,
      `--enable-automation`,
      `--password-store=basic`,
      `--use-mock-keychain`,
      `--disable-popup-blocking`,
      `--disable-prompt-on-repost`,
      `--force-color-profile=srgb`,
      `--disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies`,
      `--disable-background-timer-throttling`,
      `--disable-backgrounding-occluded-windows`,
      `--disable-ipc-flooding-protection`,
      `--disable-renderer-backgrounding`,
      `--disable-background-networking`,
      `--disable-client-side-phishing-detection`,
      `--disable-component-extensions-with-background-pages`,
      `--metrics-recording-only`,
      `--no-first-run`,
    ],
    args: [
      `--profile-directory=Default`, // always launch default
      `--load-extension=${EXTENSION_PATH}`,
      `--allow-insecure-localhost`, // to make sure that we can communicate to local wss
    ],
  })

  const page = await context.newPage()
  await page.goto('https://google.com/', { waitUntil: `networkidle` })
  const frames = await page.mainFrame().childFrames()
  console.log('frames.length', frames.length) // frame is visible
})()

Extension content script

chrome.extension.sendMessage({}, function (response) {
  var readyStateCheckInterval = setInterval(function () {
    if (document.readyState === 'complete') {
      clearInterval(readyStateCheckInterval)
      debugger
      const iframe = document.createElement(`iframe`)
      iframe.src = 'https://playwright.dev/'
      iframe.id = 'myFrame'
      Object.assign(iframe.style, {
        position: `absolute`,
        top: 0,
        left: 0,
        width: 500,
        height: 500,
      })
      document.documentElement.appendChild(iframe)
    }
  }, 10)
})

Describe the bug

I have multiple issues with OOPIF but they are inconsistent. There is one I could repro everytime though. I cannot select an element with the devtools selector inside the injected iframe. PW detects it but it looks the devtools don't detect it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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