Skip to content

[BUG] corrupted post data on application/x-protobuffer (probably other non-string postData formats) #2588

@nickchisiu

Description

@nickchisiu

Context:

  • Playwright Version: 1.1.0
  • Operating System: Mac
  • Node version: 10.16.0
  • Browser: All
  • Extra: -

Code Snippet

code snippet:

const {chromium, webkit, firefox} = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const browserContext = await browser.newContext();
  const page = await browserContext.newPage();

  await browserContext.route('**/*', async route => {
    const postData = route.request().postData();

    if (postData) {
      console.log('request: ', request);
      console.log('postdata: ', JSON.stringify(postData));
    }
    
    route.continue({
      postData: postData ? postData : undefined
    });
  });

  await page.goto('https://recaptcha-demo.appspot.com/recaptcha-v3-request-scores.php');
})();

bug

I'm trying to mock an API application/x-protobuffer endpoint. The main issue is that the request().postData() method is changing/corrupting the body data somehow. The bug can be checked with the code snippet I provided. It doesn't work if you try to continue the request with the post data provided by request().postData() object but if you change the route to route.continue() without adding the playwright postData object inside the page is rendered as expected.

I've noticed the XHR request is not shown at all via the chrome inspector on each case, including the working one.

Firefox is not returning any postData at all for the application/x-protobuffer endpoint in cause and I get null each time

Metadata

Metadata

Assignees

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