2020-09-21 11:23:36 +00:00
|
|
|
/**
|
2024-01-03 10:11:33 +00:00
|
|
|
* @license
|
|
|
|
* Copyright 2020 Google Inc.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2020-09-21 11:23:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const puppeteer = require('puppeteer');
|
|
|
|
|
|
|
|
async function attachFrame(frameId, url) {
|
|
|
|
const frame = document.createElement('iframe');
|
|
|
|
frame.src = url;
|
|
|
|
frame.id = frameId;
|
|
|
|
document.body.appendChild(frame);
|
2022-06-22 13:25:44 +00:00
|
|
|
await new Promise(x => {
|
2022-06-15 10:42:21 +00:00
|
|
|
return (frame.onload = x);
|
|
|
|
});
|
2020-09-21 11:23:36 +00:00
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
// Launch browser in non-headless mode.
|
2022-06-22 13:25:44 +00:00
|
|
|
const browser = await puppeteer.launch({headless: false});
|
2020-09-21 11:23:36 +00:00
|
|
|
const page = await browser.newPage();
|
|
|
|
|
|
|
|
// Load a page from one origin:
|
|
|
|
await page.goto('http://example.org/');
|
|
|
|
|
|
|
|
// Inject iframe with the another origin.
|
|
|
|
await page.evaluateHandle(attachFrame, 'frame1', 'https://example.com/');
|
|
|
|
|
|
|
|
// At this point there should be a message in the output:
|
2022-02-07 13:03:54 +00:00
|
|
|
// puppeteer:frame The frame '...' moved to another session. Out-of-process
|
2020-09-21 11:23:36 +00:00
|
|
|
// iframes (OOPIF) are not supported by Puppeteer yet.
|
|
|
|
// https://github.com/puppeteer/puppeteer/issues/2548
|
|
|
|
|
|
|
|
await browser.close();
|
|
|
|
})();
|