summaryrefslogtreecommitdiffstats
path: root/toolkit/components/pdfjs/test/browser_pdfjs_notification_close_on_navigation.js
blob: a6d4cf0a4500c1a5e3d49a74cc856531690f0c4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

const RELATIVE_DIR = "toolkit/components/pdfjs/test/";
const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR;

add_task(async function test_notification_is_removed_upon_navigation() {
  await BrowserTestUtils.withNewTab(
    { gBrowser, url: "about:blank" },
    async function(browser) {
      await waitForPdfJSAnnotationLayer(
        browser,
        TESTROOT + "file_pdfjs_form.pdf"
      );

      // Trigger the PDFjs fallback notification bar
      await ContentTask.spawn(browser, null, async () => {
        content.wrappedJSObject.PDFViewerApplication.fallback();
      });

      let notification = await TestUtils.waitForCondition(
        () =>
          browser &&
          gBrowser.getNotificationBox(browser) &&
          gBrowser.getNotificationBox(browser).currentNotification,
        "waiting for notification"
      );
      ok(notification, "A notification should be shown");
      is(
        notification.getAttribute("value"),
        "pdfjs-fallback",
        "Notification should be pdfjs-fallback"
      );

      BrowserTestUtils.loadURI(browser, "https://example.com");

      await TestUtils.waitForCondition(
        () => !notification.parentNode,
        "notification should be removed upon navigation to example.com"
      );
    }
  );
});