Repository: mozilla/pdf.js
File: test/integration/viewer_spec.mjs (JavaScript)

Code before:
      );
    });

    afterEach(async () => {
      await closePages(pages);
    });

    async function waitForTextAfterZoom(page, originX, originY, scale, text) {
      const handlePromise = await createPromise(page, resolve => {
        const callback = e => {
          if (e.pageNumber === 2) {
            window.PDFViewerApplication.eventBus.off(
              "textlayerrendered",
              callback
            );
            resolve();
          }
        };
        window.PDFViewerApplication.eventBus.on("textlayerrendered", callback);
      });

      await page.evaluate(
        (scaleFactor, origin) => {
          window.PDFViewerApplication.pdfViewer.updateScale({
            drawingDelay: 0,
            steps: 1,
            scaleFactor,
            origin,
          });
        },
        scale,
        [originX, originY]
      );

      await awaitPromise(handlePromise);

      await page.waitForFunction(
        `document.elementFromPoint(${originX}, ${originY})?.textContent === "${text}"`
      );
    }

    it("supports specifying a custom origin", async () => {
      await Promise.all(
        pages.map(async ([browserName, page]) => {
          // We use this text span of page 2 because:
          // - it's in the visible area even when zooming at page-width
          // - it's small, so it easily catches if the page moves too much
          // - it's in a "random" position: not near the center of the
          //   viewport, and not near the borders
          const text = "guards";


Review comment (suggestion):
This line shouldn't be necessary, since `steps` isn't used when a `scaleFactor` is provided; [please see this code](https://github.com/mozilla/pdf.js/blob/712d502561a29df3378dd7fb7cca7a22e4a48ea9/web/pdf_viewer.js#L2289-L2301).
```suggestion
```

Code after:
      );
    });

    afterEach(async () => {
      await closePages(pages);
    });

    async function waitForTextAfterZoom(page, originX, originY, scale, text) {
      const handlePromise = await createPromise(page, resolve => {
        const callback = e => {
          if (e.pageNumber === 2) {
            window.PDFViewerApplication.eventBus.off(
              "textlayerrendered",
              callback
            );
            resolve();
          }
        };
        window.PDFViewerApplication.eventBus.on("textlayerrendered", callback);
      });

      await page.evaluate(
        (scaleFactor, origin) => {
          window.PDFViewerApplication.pdfViewer.updateScale({
            drawingDelay: 0,
            scaleFactor,
            origin,
          });
        },
        scale,
        [originX, originY]
      );

      await awaitPromise(handlePromise);

      await page.waitForFunction(
        `document.elementFromPoint(${originX}, ${originY})?.textContent === "${text}"`
      );
    }

    it("supports specifying a custom origin", async () => {
      await Promise.all(
        pages.map(async ([browserName, page]) => {
          // We use this text span of page 2 because:
          // - it's in the visible area even when zooming at page-width
          // - it's small, so it easily catches if the page moves too much
          // - it's in a "random" position: not near the center of the
          //   viewport, and not near the borders
          const text = "guards";

          const rect = await getSpanRectFromText(page, 2, text);