Skip to content

Commit

Permalink
fix: remove viewport conditions for waitForSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Oct 10, 2022
1 parent a032583 commit 7882c57
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 39 deletions.
9 changes: 1 addition & 8 deletions packages/puppeteer-core/src/injected/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,5 @@ export const checkVisibility = (

function isBoundingBoxVisible(element: Element): boolean {
const rect = element.getBoundingClientRect();
return (
rect.width > 0 &&
rect.height > 0 &&
rect.right > 0 &&
rect.bottom > 0 &&
rect.left < self.innerWidth &&
rect.top < self.innerHeight
);
return rect.width > 0 && rect.height > 0 && rect.right > 0 && rect.bottom > 0;
}
32 changes: 1 addition & 31 deletions test/src/waittask.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from './mocha-utils.js';
import {attachFrame, detachFrame} from './utils.js';

describe('waittask specs', function () {
describe.only('waittask specs', function () {
setupTestBrowserHooks();
setupTestPageAndContextHooks();

Expand Down Expand Up @@ -537,38 +537,8 @@ describe('waittask specs', function () {
Promise.race([promise, createTimeout(40)])
).resolves.toBeFalsy();
await element.evaluate(e => {
e.style.setProperty('position', 'absolute');
e.style.setProperty('right', '100vw');
e.style.removeProperty('height');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeFalsy();
await element.evaluate(e => {
e.style.setProperty('left', '100vw');
e.style.removeProperty('right');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeFalsy();
await element.evaluate(e => {
e.style.setProperty('top', '100vh');
e.style.removeProperty('left');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeFalsy();
await element.evaluate(e => {
e.style.setProperty('bottom', '100vh');
e.style.removeProperty('top');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeFalsy();
await element.evaluate(e => {
// Just peeking
e.style.setProperty('bottom', '99vh');
});
await expect(promise).resolves.toBeTruthy();
});
it('should wait for element to be visible recursively', async () => {
Expand Down

0 comments on commit 7882c57

Please sign in to comment.