What is your Test Scenario?
Currently I'm implementing third party integration which uses iframe to get their SDK. They use API keys and allow-list to either deny iframe request or to accept it. E2E tests using Testcafe are failing with the "deny" error whilst manual tests on the same environment work. Localhost host which Testcafe is using is whitelisted for the given API key. The issues seems to be connected to the request being sent with invalid header:
Here's how I found it
class 3rdPartySDKHook extends RequestHook {
constructor() {
const requestFilterRules = [/* regex filtering requests to only those iframe is performing */];
super(requestFilterRules);
}
public async onRequest(event: any): Promise<void> {
console.log(event.requestOptions.headers);
}
public async onResponse(): Promise<void> {
// noop
}
}
const hook = new 3rdPartySDKHook();
fixture`My fixture`
.page(TEST_URL).requestHooks(hook);
What is the Current behavior?
The Referer header is set to unproxied version of iframe src.
What is the Expected behavior?
The Referer header is set to url of page rendering iframe.
What is your web application and your TestCafe test code?
Working workaround:
class 3rdPartySDKHook extends RequestHook {
constructor() {
const requestFilterRules = [/* regex filtering requests to only those iframe is performing */];
super(requestFilterRules);
}
public async onRequest(event: any): Promise<void> {
event.requestOptions.headers.referer = TEST_URL;
}
public async onResponse(): Promise<void> {
// noop
}
}
const hook = new 3rdPartySDKHook();
fixture`My fixture`
.page(TEST_URL).requestHooks(hook);
Steps to Reproduce:
- Use iframe with src that uses ACL based on origin.
- See if the origin header gets set properly.
Your Environment details:
- testcafe version: 1.9.4
- node.js version: lts/erbium
- command-line arguments:
chrome --disable-web-security --allow-insecure-localhost --use-fake-device-for-media-stream --use-file-for-fake-audio-capture
- browser name and version: Chrome 90
- platform and version: macOS 11.2.3
What is your Test Scenario?
Currently I'm implementing third party integration which uses iframe to get their SDK. They use API keys and allow-list to either deny iframe request or to accept it. E2E tests using Testcafe are failing with the "deny" error whilst manual tests on the same environment work. Localhost host which Testcafe is using is whitelisted for the given API key. The issues seems to be connected to the request being sent with invalid header:
Here's how I found it
What is the Current behavior?
The
Refererheader is set to unproxied version of iframe src.What is the Expected behavior?
The
Refererheader is set to url of page rendering iframe.What is your web application and your TestCafe test code?
Working workaround:
Steps to Reproduce:
Your Environment details:
chrome --disable-web-security --allow-insecure-localhost --use-fake-device-for-media-stream --use-file-for-fake-audio-capture