test(firefox): add puppeteer-firefox unique evaluation tests (#3891)
References #3889
This commit is contained in:
parent
6bb0350b4d
commit
b5e53fdbf4
@ -132,7 +132,7 @@ module.exports.addTests = function({testRunner, expect, product}) {
|
||||
await page.goto(server.PREFIX + '/global-var.html');
|
||||
expect(await page.evaluate('globalVar')).toBe(123);
|
||||
});
|
||||
it('should use the same sandbox', async({page}) => {
|
||||
it('should modify global environment', async({page}) => {
|
||||
await page.evaluate(() => window.globalVar = 123);
|
||||
expect(await page.evaluate('globalVar')).toBe(123);
|
||||
});
|
||||
|
3
test/assets/global-var.html
Normal file
3
test/assets/global-var.html
Normal file
@ -0,0 +1,3 @@
|
||||
<script>
|
||||
var globalVar = 123;
|
||||
</script>
|
@ -23,7 +23,7 @@ try {
|
||||
asyncawait = false;
|
||||
}
|
||||
|
||||
module.exports.addTests = function({testRunner, expect}) {
|
||||
module.exports.addTests = function({testRunner, expect, FFOX}) {
|
||||
const {describe, xdescribe, fdescribe} = testRunner;
|
||||
const {it, fit, xit} = testRunner;
|
||||
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
||||
@ -33,6 +33,41 @@ module.exports.addTests = function({testRunner, expect}) {
|
||||
const result = await page.evaluate(() => 7 * 3);
|
||||
expect(result).toBe(21);
|
||||
});
|
||||
it('should transfer NaN', async({page, server}) => {
|
||||
const result = await page.evaluate(a => a, NaN);
|
||||
expect(Object.is(result, NaN)).toBe(true);
|
||||
});
|
||||
it('should transfer -0', async({page, server}) => {
|
||||
const result = await page.evaluate(a => a, -0);
|
||||
expect(Object.is(result, -0)).toBe(true);
|
||||
});
|
||||
it('should transfer Infinity', async({page, server}) => {
|
||||
const result = await page.evaluate(a => a, Infinity);
|
||||
expect(Object.is(result, Infinity)).toBe(true);
|
||||
});
|
||||
it('should transfer -Infinity', async({page, server}) => {
|
||||
const result = await page.evaluate(a => a, -Infinity);
|
||||
expect(Object.is(result, -Infinity)).toBe(true);
|
||||
});
|
||||
it('should transfer arrays', async({page, server}) => {
|
||||
const result = await page.evaluate(a => a, [1, 2, 3]);
|
||||
expect(result).toEqual([1,2,3]);
|
||||
});
|
||||
it('should transfer arrays as arrays, not objects', async({page, server}) => {
|
||||
const result = await page.evaluate(a => Array.isArray(a), [1, 2, 3]);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
it('should modify global environment', async({page}) => {
|
||||
await page.evaluate(() => window.globalVar = 123);
|
||||
expect(await page.evaluate('globalVar')).toBe(123);
|
||||
});
|
||||
it('should evaluate in the page context', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/global-var.html');
|
||||
expect(await page.evaluate('globalVar')).toBe(123);
|
||||
});
|
||||
(FFOX ? xit : it)('should return undefined for objects with symbols', async({page, server}) => {
|
||||
expect(await page.evaluate(() => [Symbol('foo4')])).toBe(undefined);
|
||||
});
|
||||
(asyncawait ? it : xit)('should work with function shorthands', async({page, server}) => {
|
||||
// trick node6 transpiler to not touch our object.
|
||||
// TODO(lushnikov): remove eval once Node6 is dropped.
|
||||
@ -227,6 +262,12 @@ module.exports.addTests = function({testRunner, expect}) {
|
||||
expect(await page.frames()[0].evaluate(() => window.FOO)).toBe('foo');
|
||||
expect(await page.frames()[1].evaluate(() => window.FOO)).toBe('bar');
|
||||
});
|
||||
it('should have correct execution contexts', async({page, server}) => {
|
||||
await page.goto(server.PREFIX + '/frames/one-frame.html');
|
||||
expect(page.frames().length).toBe(2);
|
||||
expect(await page.frames()[0].evaluate(() => document.body.textContent.trim())).toBe('');
|
||||
expect(await page.frames()[1].evaluate(() => document.body.textContent.trim())).toBe(`Hi, I'm frame`);
|
||||
});
|
||||
it('should execute after cross-site navigation', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const mainFrame = page.mainFrame();
|
||||
|
Loading…
Reference in New Issue
Block a user