mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Fix racy condition in case of multiple parallel screenshots
Page.screenshot operates the global state of the page. In case of multiple Page.screenshot() commands running in parallel with different clipping rects, they interfere with each other. This patch makes Page.screenshot() commands run sequencially even though they were called in parallel. Fixes #15.
This commit is contained in:
@@ -70,6 +70,23 @@ describe('GoldenTests', function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
imageTest('screenshot-parallel-calls.png', async function() {
|
||||
await page.setViewportSize({width: 500, height: 500});
|
||||
await page.navigate(STATIC_PREFIX + '/grid.html');
|
||||
var promises = [];
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
promises.push(page.screenshot({
|
||||
clip: {
|
||||
x: 50 * i,
|
||||
y: 0,
|
||||
width: 50,
|
||||
height: 50
|
||||
}
|
||||
}));
|
||||
}
|
||||
return await promises[1];
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user