Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajax request referrer header altered after iframe loads #7376

Closed
naggingant opened this issue Nov 10, 2022 · 2 comments · Fixed by DevExpress/testcafe-hammerhead#2813
Closed
Labels
TYPE: bug The described behavior is considered as wrong (bug).

Comments

@naggingant
Copy link

What is your Scenario?

Since TestCafe 1.20.x, we started getting errors on some ajax requests in our tests, claiming the referrer header is not allowed etc. which implied the header is not set properly as before.

What is the Current behavior?

I could debug a little by inspecting the outgoing headers, and noticed the proxied request's referrer header had been replaced by the iframe src URL that was last loaded in the target page.

What is the Expected behavior?

I suppose most browsers would set the header to the current page location that the request is made from, so I considered this a bug, i.e. the referrer header should remain the page URL and not change after an iframe load.

What is your public website URL? (or attach your complete example)

<html>
    <head />
    <body>
        <script type="text/javascript">
            function doAjax () {
                fetch('https://httpbin.org/headers')
                    .then(res => res.json())
                    .then(body => console.log(body.headers.Referer)) // this prints https://example.com
            }
        </script>
        <iframe src="https://example.com" onload="doAjax()" />
    </body>
</html>

What is your TestCafe test code?

Assuming the above HTML is served at http://localhost:9000

test('bug', async t => {
    await t
        .navigateTo('http://localhost:9000')
        .debug()
})

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

  1. Save the attached HTML and serve it via HTTP
  2. Modify and run the attached test scenario
  3. Observe https://example.com is printed in the console, instead of http://localhost:9000

TestCafe version

2.0.2

Node.js version

v16.14.0

Command-line arguments

testcafe chromium -e test.js

Browser name(s) and version(s)

No response

Platform(s) and version(s)

No response

Other

No response

@naggingant naggingant added the TYPE: bug The described behavior is considered as wrong (bug). label Nov 10, 2022
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Nov 10, 2022
naggingant added a commit to naggingant/testcafe-hammerhead that referenced this issue Nov 10, 2022
naggingant added a commit to naggingant/testcafe-hammerhead that referenced this issue Nov 10, 2022
naggingant added a commit to naggingant/testcafe-hammerhead that referenced this issue Nov 10, 2022
naggingant added a commit to naggingant/testcafe-hammerhead that referenced this issue Nov 10, 2022
naggingant added a commit to naggingant/testcafe-hammerhead that referenced this issue Nov 10, 2022
naggingant added a commit to naggingant/testcafe-hammerhead that referenced this issue Nov 10, 2022
naggingant added a commit to naggingant/testcafe-hammerhead that referenced this issue Nov 10, 2022
@naggingant
Copy link
Author

Oh... sorry for this mess

@Aleksey28
Copy link
Collaborator

Hi @naggingant,

I reproduced the issue. Thank you for your PR. I'll review it as soon as possible.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants