mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test(firefox): add more Puppeteer-Firefox tests to Puppeteer (#3892)
References #3889
This commit is contained in:
parent
b5e53fdbf4
commit
47fbb117f5
8
test/assets/frames/frameset.html
Normal file
8
test/assets/frames/frameset.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<frameset>
|
||||||
|
<frameset>
|
||||||
|
<frame src='./frame.html'></frame>
|
||||||
|
<frame src='about:blank'></frame>
|
||||||
|
</frameset>
|
||||||
|
<frame src='/empty.html'></frame>
|
||||||
|
<frame></frame>
|
||||||
|
</frameset>
|
@ -136,6 +136,26 @@ module.exports.addTests = function({testRunner, expect}) {
|
|||||||
expect(detachedFrames.length).toBe(4);
|
expect(detachedFrames.length).toBe(4);
|
||||||
expect(navigatedFrames.length).toBe(1);
|
expect(navigatedFrames.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
it('should support framesets', async({page, server}) => {
|
||||||
|
let attachedFrames = [];
|
||||||
|
let detachedFrames = [];
|
||||||
|
let navigatedFrames = [];
|
||||||
|
page.on('frameattached', frame => attachedFrames.push(frame));
|
||||||
|
page.on('framedetached', frame => detachedFrames.push(frame));
|
||||||
|
page.on('framenavigated', frame => navigatedFrames.push(frame));
|
||||||
|
await page.goto(server.PREFIX + '/frames/frameset.html');
|
||||||
|
expect(attachedFrames.length).toBe(4);
|
||||||
|
expect(detachedFrames.length).toBe(0);
|
||||||
|
expect(navigatedFrames.length).toBe(5);
|
||||||
|
|
||||||
|
attachedFrames = [];
|
||||||
|
detachedFrames = [];
|
||||||
|
navigatedFrames = [];
|
||||||
|
await page.goto(server.EMPTY_PAGE);
|
||||||
|
expect(attachedFrames.length).toBe(0);
|
||||||
|
expect(detachedFrames.length).toBe(4);
|
||||||
|
expect(navigatedFrames.length).toBe(1);
|
||||||
|
});
|
||||||
it('should report frame.name()', async({page, server}) => {
|
it('should report frame.name()', async({page, server}) => {
|
||||||
await utils.attachFrame(page, 'theFrameId', server.EMPTY_PAGE);
|
await utils.attachFrame(page, 'theFrameId', server.EMPTY_PAGE);
|
||||||
await page.evaluate(url => {
|
await page.evaluate(url => {
|
||||||
|
@ -43,6 +43,24 @@ module.exports.addTests = function({testRunner, expect}) {
|
|||||||
).catch(e => error = e);
|
).catch(e => error = e);
|
||||||
expect(error.message).toContain('Are you passing a nested JSHandle?');
|
expect(error.message).toContain('Are you passing a nested JSHandle?');
|
||||||
});
|
});
|
||||||
|
it('should accept object handle to unserializable value', async({page, server}) => {
|
||||||
|
const aHandle = await page.evaluateHandle(() => Infinity);
|
||||||
|
expect(await page.evaluate(e => Object.is(e, Infinity), aHandle)).toBe(true);
|
||||||
|
});
|
||||||
|
it('should use the same JS wrappers', async({page, server}) => {
|
||||||
|
const aHandle = await page.evaluateHandle(() => {
|
||||||
|
window.FOO = 123;
|
||||||
|
return window;
|
||||||
|
});
|
||||||
|
expect(await page.evaluate(e => e.FOO, aHandle)).toBe(123);
|
||||||
|
});
|
||||||
|
it('should work with primitives', async({page, server}) => {
|
||||||
|
const aHandle = await page.evaluateHandle(() => {
|
||||||
|
window.FOO = 123;
|
||||||
|
return window;
|
||||||
|
});
|
||||||
|
expect(await page.evaluate(e => e.FOO, aHandle)).toBe(123);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('JSHandle.getProperty', function() {
|
describe('JSHandle.getProperty', function() {
|
||||||
@ -125,6 +143,13 @@ module.exports.addTests = function({testRunner, expect}) {
|
|||||||
expect(element).toBeTruthy();
|
expect(element).toBeTruthy();
|
||||||
expect(await page.evaluate(e => e.nodeType === HTMLElement.TEXT_NODE, element));
|
expect(await page.evaluate(e => e.nodeType === HTMLElement.TEXT_NODE, element));
|
||||||
});
|
});
|
||||||
|
it('should work with nullified Node', async({page, server}) => {
|
||||||
|
await page.setContent('<section>test</section>');
|
||||||
|
await page.evaluate(() => delete Node);
|
||||||
|
const handle = await page.evaluateHandle(() => document.querySelector('section'));
|
||||||
|
const element = handle.asElement();
|
||||||
|
expect(element).not.toBe(null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('JSHandle.toString', function() {
|
describe('JSHandle.toString', function() {
|
||||||
@ -138,5 +163,25 @@ module.exports.addTests = function({testRunner, expect}) {
|
|||||||
const aHandle = await page.evaluateHandle(() => window);
|
const aHandle = await page.evaluateHandle(() => window);
|
||||||
expect(aHandle.toString()).toBe('JSHandle@object');
|
expect(aHandle.toString()).toBe('JSHandle@object');
|
||||||
});
|
});
|
||||||
|
it('should work with different subtypes', async({page, server}) => {
|
||||||
|
expect((await page.evaluateHandle('(function(){})')).toString()).toBe('JSHandle@function');
|
||||||
|
expect((await page.evaluateHandle('12')).toString()).toBe('JSHandle:12');
|
||||||
|
expect((await page.evaluateHandle('true')).toString()).toBe('JSHandle:true');
|
||||||
|
expect((await page.evaluateHandle('undefined')).toString()).toBe('JSHandle:undefined');
|
||||||
|
expect((await page.evaluateHandle('"foo"')).toString()).toBe('JSHandle:foo');
|
||||||
|
expect((await page.evaluateHandle('Symbol()')).toString()).toBe('JSHandle@symbol');
|
||||||
|
expect((await page.evaluateHandle('new Map()')).toString()).toBe('JSHandle@map');
|
||||||
|
expect((await page.evaluateHandle('new Set()')).toString()).toBe('JSHandle@set');
|
||||||
|
expect((await page.evaluateHandle('[]')).toString()).toBe('JSHandle@array');
|
||||||
|
expect((await page.evaluateHandle('null')).toString()).toBe('JSHandle:null');
|
||||||
|
expect((await page.evaluateHandle('/foo/')).toString()).toBe('JSHandle@regexp');
|
||||||
|
expect((await page.evaluateHandle('document.body')).toString()).toBe('JSHandle@node');
|
||||||
|
expect((await page.evaluateHandle('new Date()')).toString()).toBe('JSHandle@date');
|
||||||
|
expect((await page.evaluateHandle('new WeakMap()')).toString()).toBe('JSHandle@weakmap');
|
||||||
|
expect((await page.evaluateHandle('new WeakSet()')).toString()).toBe('JSHandle@weakset');
|
||||||
|
expect((await page.evaluateHandle('new Error()')).toString()).toBe('JSHandle@error');
|
||||||
|
expect((await page.evaluateHandle('new Int32Array()')).toString()).toBe('JSHandle@typedarray');
|
||||||
|
expect((await page.evaluateHandle('new Proxy({}, {})')).toString()).toBe('JSHandle@proxy');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -71,6 +71,15 @@ module.exports.addTests = function({testRunner, expect, headless}) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Page.Events.Load', function() {
|
||||||
|
it('should fire when expected', async({page, server}) => {
|
||||||
|
await Promise.all([
|
||||||
|
page.goto('about:blank'),
|
||||||
|
utils.waitEvent(page, 'load'),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
(asyncawait ? describe : xdescribe)('Async stacks', () => {
|
(asyncawait ? describe : xdescribe)('Async stacks', () => {
|
||||||
it('should work', async({page, server}) => {
|
it('should work', async({page, server}) => {
|
||||||
server.setRoute('/empty.html', (req, res) => {
|
server.setRoute('/empty.html', (req, res) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user