Skip to content

Commit

Permalink
fix(firefox): enable more firefox tests (#4007)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Feb 14, 2019
1 parent e8f044c commit 247733b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
17 changes: 12 additions & 5 deletions experimental/puppeteer-firefox/lib/ExecutionContext.js
Expand Up @@ -59,11 +59,18 @@ class ExecutionContext {
return {unserializableValue: 'NaN'};
return {value: arg};
});
const payload = await this._session.send('Page.evaluate', {
functionText,
args,
executionContextId: this._executionContextId
});
let payload = null;
try {
payload = await this._session.send('Page.evaluate', {
functionText,
args,
executionContextId: this._executionContextId
});
} catch (err) {
if (err instanceof TypeError && err.message === 'Converting circular structure to JSON')
err.message += ' Are you passing a nested JSHandle?';
throw err;
}
return createHandle(this, payload.result, payload.exceptionDetails);
}

Expand Down
13 changes: 8 additions & 5 deletions test/jshandle.spec.js
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

module.exports.addTests = function({testRunner, expect}) {
module.exports.addTests = function({testRunner, expect, CHROME}) {
const {describe, xdescribe, fdescribe} = testRunner;
const {it, fit, xit, it_fails_ffox} = testRunner;
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;

describe('Page.evaluateHandle', function() {
it_fails_ffox('should work', async({page, server}) => {
it('should work', async({page, server}) => {
const windowHandle = await page.evaluateHandle(() => window);
expect(windowHandle).toBeTruthy();
});
Expand All @@ -34,7 +34,7 @@ module.exports.addTests = function({testRunner, expect}) {
const isFive = await page.evaluate(e => Object.is(e, 5), aHandle);
expect(isFive).toBeTruthy();
});
it_fails_ffox('should warn on nested object handles', async({page, server}) => {
it('should warn on nested object handles', async({page, server}) => {
const aHandle = await page.evaluateHandle(() => document.body);
let error = null;
await page.evaluateHandle(
Expand Down Expand Up @@ -86,11 +86,14 @@ module.exports.addTests = function({testRunner, expect}) {
const json = await dateHandle.jsonValue();
expect(json).toEqual({});
});
it_fails_ffox('should throw for circular objects', async({page, server}) => {
it('should throw for circular objects', async({page, server}) => {
const windowHandle = await page.evaluateHandle('window');
let error = null;
await windowHandle.jsonValue().catch(e => error = e);
expect(error.message).toContain('Object reference chain is too long');
if (CHROME)
expect(error.message).toContain('Object reference chain is too long');
else
expect(error.message).toContain('Object is not serializable');
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/navigation.spec.js
Expand Up @@ -61,7 +61,7 @@ module.exports.addTests = function({testRunner, expect, Errors, CHROME}) {
else
expect(error.message).toContain('NS_BINDING_ABORTED');
});
it_fails_ffox('should navigate to empty page with domcontentloaded', async({page, server}) => {
it('should navigate to empty page with domcontentloaded', async({page, server}) => {
const response = await page.goto(server.EMPTY_PAGE, {waitUntil: 'domcontentloaded'});
expect(response.status()).toBe(200);
});
Expand Down

0 comments on commit 247733b

Please sign in to comment.