Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(firefox): enable more tests #4037

Merged
merged 1 commit into from Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions experimental/puppeteer-firefox/lib/FrameManager.js
Expand Up @@ -364,15 +364,21 @@ class Frame {
* @param {!{timeout?: number, visible?: boolean, hidden?: boolean}=} options
* @return {!Promise<!ElementHandle>}
*/
_waitForSelectorOrXPath(selectorOrXPath, isXPath, options = {}) {
async _waitForSelectorOrXPath(selectorOrXPath, isXPath, options = {}) {
const {
visible: waitForVisible = false,
hidden: waitForHidden = false,
timeout = this._timeoutSettings.timeout(),
} = options;
const polling = waitForVisible || waitForHidden ? 'raf' : 'mutation';
const title = `${isXPath ? 'XPath' : 'selector'} "${selectorOrXPath}"${waitForHidden ? ' to be hidden' : ''}`;
return new WaitTask(this, predicate, title, polling, timeout, selectorOrXPath, isXPath, waitForVisible, waitForHidden).promise;
const waitTask = new WaitTask(this, predicate, title, polling, timeout, selectorOrXPath, isXPath, waitForVisible, waitForHidden);
const handle = await waitTask.promise;
if (!handle.asElement()) {
await handle.dispose();
return null;
}
return handle.asElement();

/**
* @param {string} selectorOrXPath
Expand Down Expand Up @@ -668,7 +674,7 @@ class WaitTask {
this._frame = frame;
this._polling = polling;
this._timeout = timeout;
this._predicateBody = helper.isString(predicateBody) ? 'return ' + predicateBody : 'return (' + predicateBody + ')(...args)';
this._predicateBody = helper.isString(predicateBody) ? 'return (' + predicateBody + ')' : 'return (' + predicateBody + ')(...args)';
this._args = args;
this._runCount = 0;
frame._waitTasks.add(this);
Expand Down
11 changes: 6 additions & 5 deletions test/waittask.spec.js
Expand Up @@ -60,16 +60,17 @@ module.exports.addTests = function({testRunner, expect, product, Errors}) {
await page.waitFor(timeout);
expect(Date.now() - startTime).not.toBeLessThan(timeout / 2);
});
it_fails_ffox('should work with multiline body', async({page, server}) => {
it('should work with multiline body', async({page, server}) => {
const result = await page.waitForFunction(`
(() => true)()
`);
expect(await result.jsonValue()).toBe(true);
});
it('should wait for predicate', async({page, server}) => {
const watchdog = page.waitFor(() => window.innerWidth < 100);
page.setViewport({width: 10, height: 10});
await watchdog;
await Promise.all([
page.waitFor(() => window.innerWidth < 100),
page.setViewport({width: 10, height: 10}),
]);
});
it('should throw when unknown type', async({page, server}) => {
let error = null;
Expand Down Expand Up @@ -346,7 +347,7 @@ module.exports.addTests = function({testRunner, expect, product, Errors}) {
expect(await waitForSelector).toBe(true);
expect(divRemoved).toBe(true);
});
it_fails_ffox('should return null if waiting to hide non-existing element', async({page, server}) => {
it('should return null if waiting to hide non-existing element', async({page, server}) => {
const handle = await page.waitForSelector('non-existing', { hidden: true });
expect(handle).toBe(null);
});
Expand Down