summaryrefslogtreecommitdiffstats
path: root/toolkit/components/reader/test/browser_localfile_readerMode.js
blob: 118e4bb23f844f03f5036c20316bf5d9646fdb99 (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
44
45
46
47
48
49
50
51
52
53
54
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const TEST_BASE_URI = getResolvedURI(getRootDirectory(gTestPath)).spec;

let readerButton = document.getElementById("reader-mode-button");

/**
 * Reader mode should work on local files.
 */
add_task(async function test_readermode_available_for_local_files() {
  await BrowserTestUtils.withNewTab(
    TEST_BASE_URI + "readerModeArticle.html",
    async function (browser) {
      await TestUtils.waitForCondition(
        () => !readerButton.hidden,
        "Reader mode button should become visible"
      );

      is_element_visible(
        readerButton,
        "Reader mode button is present on a reader-able page"
      );

      // Switch page into reader mode.
      let promiseTabLoad = BrowserTestUtils.browserLoaded(browser);
      readerButton.click();
      await promiseTabLoad;

      let readerUrl = gBrowser.selectedBrowser.currentURI.spec;
      ok(
        readerUrl.startsWith("about:reader"),
        "about:reader loaded after clicking reader mode button"
      );
      is_element_visible(
        readerButton,
        "Reader mode button is present on about:reader"
      );

      is(
        gURLBar.untrimmedValue,
        TEST_BASE_URI + "readerModeArticle.html",
        "gURLBar value is about:reader URL"
      );
      is(
        gURLBar.value,
        gURLBar.untrimmedValue,
        "gURLBar is displaying original article URL"
      );
    }
  );
});