Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Added iframe test.

Petr Patek550df1a44c45
diff --git a/test/stealth/stealth.js b/test/stealth/stealth.js
index b98ecf308..f7fef7169 100644
--- a/test/stealth/stealth.js
+++ b/test/stealth/stealth.js
@@ -179,6 +179,33 @@ describe('Stealth - testing headless chrome hiding tricks', () => {
return browser.close();
});
+ it('it should not break iframe ', async () => {
+ const browser = await Apify.launchPuppeteer({
+ stealth: {
+ mocksChromeInIframe: true,
+ },
+ headless: true,
+ useChrome: true,
+ });
+
+ const page = await browser.newPage();
+ const testFuncReturnValue = 'TESTSTRING';
+ await page.goto('http://example.com');
+ await page.evaluate((returnValue) => {
+ const { document } = window; //eslint-disable-line
+ const body = document.querySelector('body');
+ const iframe = document.createElement('iframe');
+ iframe.contentWindow.mySuperFunction = () => returnValue;
+ body.appendChild(iframe);
+ }, testFuncReturnValue);
+ const realReturn = await page.evaluate(
+ () => document.querySelector('iframe').contentWindow.mySuperFunction(), //eslint-disable-line
+ );
+ expect(realReturn).to.eql(testFuncReturnValue);
+
+ return browser.close();
+ });
+
it('it should mock device memory', async () => {
const browser = await Apify.launchPuppeteer({
stealth: {