Skip to content

Commit

Permalink
test(firefox): add puppeteer-firefox unique evaluation tests
Browse files Browse the repository at this point in the history
References puppeteer#3889
  • Loading branch information
aslushnikov committed Feb 2, 2019
1 parent 6bb0350 commit f5cb5b6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion experimental/puppeteer-firefox/test/evaluation.spec.js
Expand Up @@ -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);
});
Expand Down
33 changes: 32 additions & 1 deletion test/evaluation.spec.js
Expand Up @@ -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;
Expand All @@ -33,6 +33,37 @@ 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);
});
(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.
Expand Down

0 comments on commit f5cb5b6

Please sign in to comment.