mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Add a new helper, in the viewer, to close everything during testing
This has two advantages, as far as I'm concerned: - The tests don't need to manually invoke multiple functions to properly clean-up, which reduces the risk of missing something. - By collecting all the relevant clean-up in one method, rather than spreading it out, we get a much better overview of exactly what is being reset.
This commit is contained in:
parent
c53f71a7d2
commit
c771ac81cd
2 changed files with 16 additions and 12 deletions
|
@ -80,10 +80,7 @@ function closePages(pages) {
|
|||
pages.map(async ([_, page]) => {
|
||||
// Avoid to keep something from a previous test.
|
||||
await page.evaluate(async () => {
|
||||
const viewer = window.PDFViewerApplication;
|
||||
viewer.unbindWindowEvents();
|
||||
viewer.unbindEvents();
|
||||
await viewer.close();
|
||||
await window.PDFViewerApplication.testingClose();
|
||||
window.localStorage.clear();
|
||||
});
|
||||
await page.close({ runBeforeUnload: false });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue