Skip to content

Testcafe does not respect base tag #1965

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

Closed
mbazalik opened this issue Mar 19, 2019 · 3 comments
Closed

Testcafe does not respect base tag #1965

mbazalik opened this issue Mar 19, 2019 · 3 comments

Comments

@mbazalik
Copy link

What is your Test Scenario?

My application at some point injects <base> tag into website and after that creates a new <script> tag with relative src. Testcafe does not respect the value of base tag when injecting the <script> tag

What is the Current behavior?

For example sets <base href="http://localhost:8080/chapters/de/auth/"> and injects <script src="build.js" type="text/javascript" /> resulting into browser downloading script from http://localhost:8080/chapters/de/auth/build.js.

When running the same application in testcafe, the result is slightly different. Inserted base is <base href-hammerhead-stored-value="http://localhost:8080/chapters/de/auth/" href="http://localhost:1337/Lj6CFUfNF/http://localhost:8080/chapters/de/auth/"> and script is <script src-hammerhead-stored-value="build.js" src="http://localhost:1337/Lj6CFUfNF!s!utf-8/http://localhost:8080/account/build.js" type="text/javascript" />

Suddenly the previously relative url build.js turned into http://localhost:8080/account/build.js which is inconsistent with what is set in

What is the Expected behavior?

I would expect the injected script tag to be <script src-hammerhead-stored-value="build.js" src="http://localhost:1337/Lj6CFUfNF!s!utf-8/http://localhost:8080/chapters/de/auth/build.js" type="text/javascript" />

What is your web application and your TestCafe test code?

I am sorry, there is no sample url available at the moment

Your Environment details:

  • testcafe version: 1.1.0
  • node.js version: 8.10.0
  • command-line arguments: running from node:
createTestCafe('localhost', 1337, 1338)
    .then(testcafe => testcafe.createRunner()
        .src('e2e/**/*.test.js')
        .browsers(browsers)
        .startApp('yarn start')
        .run({
            selectorTimeout: 30000,
            assertionTimeout: 30000,
            skipJsErrors: true,
        })
    )
    .then(failedCount => {
        if (failedCount) {
            process.exit(1);
        }
        process.exit(0);
    });
  • browser name and version: Chrome
  • platform and version: macOs
@AlexKamaev AlexKamaev self-assigned this Mar 20, 2019
@AlexKamaev
Copy link
Contributor

I was not able to reproduce the issue. I prepared a sample project. Please check the attached file.
project.zip
 
I would appreciate it if you modify my example to reproduce the issue.

@mbazalik
Copy link
Author

Hey @AlexKamaev
thank you very much for your reply. The project you sent works as expected and it took me some time to understand how is my use case different from yours. In the end, it seems, that it depends on where I am inejcting base tag into document. If that happens after the script is created (not injected) the testcafe seems to get confused. I have slightly updated your code to reflect that. In short term, I think I can update the base url before creating script tags in my case, it just seems that in this edge case testcafe / hammerhead is missbehaving slightly, so would still consider it being a bug

project.zip

@AlexKamaev
Copy link
Contributor

Thank you @mbazalik
Now I can reproduce the issue. I think since there is a difference between Chrome and TestCafe we can consider this as a bug.

@AndreyBelym AndreyBelym transferred this issue from DevExpress/testcafe Mar 20, 2019
@LavrovArtem LavrovArtem modified the milestones: Sprint #36, Sprint #37 Jul 12, 2019
@LavrovArtem LavrovArtem modified the milestones: Sprint #37, Sprint #38 Aug 5, 2019
@LavrovArtem LavrovArtem modified the milestones: Sprint #38, Sprint #39 Aug 14, 2019
@AndreyBelym AndreyBelym modified the milestones: Sprint #39, Planned Sep 10, 2019
@LavrovArtem LavrovArtem removed this from the Planned milestone Feb 26, 2020
@LavrovArtem LavrovArtem removed their assignment Feb 26, 2020
@LavrovArtem LavrovArtem self-assigned this Jun 10, 2021
LavrovArtem added a commit to LavrovArtem/testcafe-hammerhead that referenced this issue Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants