summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/test/src/frame.spec.ts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /remote/test/puppeteer/test/src/frame.spec.ts
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'remote/test/puppeteer/test/src/frame.spec.ts')
-rw-r--r--remote/test/puppeteer/test/src/frame.spec.ts51
1 files changed, 33 insertions, 18 deletions
diff --git a/remote/test/puppeteer/test/src/frame.spec.ts b/remote/test/puppeteer/test/src/frame.spec.ts
index a49fb19482..758725f932 100644
--- a/remote/test/puppeteer/test/src/frame.spec.ts
+++ b/remote/test/puppeteer/test/src/frame.spec.ts
@@ -7,6 +7,7 @@
import expect from 'expect';
import {CDPSession} from 'puppeteer-core/internal/api/CDPSession.js';
import type {Frame} from 'puppeteer-core/internal/api/Frame.js';
+import {assert} from 'puppeteer-core/internal/util/assert.js';
import {getTestState, setupTestBrowserHooks} from './mocha-utils.js';
import {
@@ -78,7 +79,7 @@ describe('Frame specs', function () {
const {page, server} = await getTestState();
await page.goto(server.PREFIX + '/frames/nested-frames.html');
- expect(dumpFrames(page.mainFrame())).toEqual([
+ expect(await dumpFrames(page.mainFrame())).toEqual([
'http://localhost:<PORT>/frames/nested-frames.html',
' http://localhost:<PORT>/frames/two-frames.html (2frames)',
' http://localhost:<PORT>/frames/frame.html (uno)',
@@ -232,23 +233,6 @@ describe('Frame specs', function () {
expect(page.frames()).toHaveLength(2);
expect(page.frames()[1]!.url()).toBe(server.EMPTY_PAGE);
});
- it('should report frame.name()', async () => {
- const {page, server} = await getTestState();
-
- await attachFrame(page, 'theFrameId', server.EMPTY_PAGE);
- await page.evaluate((url: string) => {
- const frame = document.createElement('iframe');
- frame.name = 'theFrameName';
- frame.src = url;
- document.body.appendChild(frame);
- return new Promise(x => {
- return (frame.onload = x);
- });
- }, server.EMPTY_PAGE);
- expect(page.frames()[0]!.name()).toBe('');
- expect(page.frames()[1]!.name()).toBe('theFrameId');
- expect(page.frames()[2]!.name()).toBe('theFrameName');
- });
it('should report frame.parent()', async () => {
const {page, server} = await getTestState();
@@ -306,4 +290,35 @@ describe('Frame specs', function () {
expect(page.mainFrame().client).toBeInstanceOf(CDPSession);
});
});
+
+ describe('Frame.prototype.frameElement', function () {
+ it('should work', async () => {
+ const {page, server} = await getTestState();
+
+ await attachFrame(page, 'theFrameId', server.EMPTY_PAGE);
+ await page.evaluate((url: string) => {
+ const frame = document.createElement('iframe');
+ frame.name = 'theFrameName';
+ frame.src = url;
+ document.body.appendChild(frame);
+ return new Promise(x => {
+ return (frame.onload = x);
+ });
+ }, server.EMPTY_PAGE);
+ using frame0 = await page.frames()[0]?.frameElement();
+ assert(!frame0);
+ using frame1 = await page.frames()[1]?.frameElement();
+ assert(frame1);
+ using frame2 = await page.frames()[2]?.frameElement();
+ assert(frame2);
+ const name1 = await frame1.evaluate(frame => {
+ return frame.id;
+ });
+ expect(name1).toBe('theFrameId');
+ const name2 = await frame2.evaluate(frame => {
+ return frame.name;
+ });
+ expect(name2).toBe('theFrameName');
+ });
+ });
});