blob: 38a5955f619afd683705205bd715f6afe0e2cdd9 (
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
55
56
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Test that the reader mode button appears and works properly on
* reader-able content.
*/
const TEST_PREFS = [["reader.parse-on-load.enabled", true]];
const TEST_PATH = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
"http://example.com"
);
var readerButton = document.getElementById("reader-mode-button");
add_task(async function test_reader_button() {
registerCleanupFunction(function () {
// Reset test prefs.
TEST_PREFS.forEach(([name, value]) => {
Services.prefs.clearUserPref(name);
});
while (gBrowser.tabs.length > 1) {
gBrowser.removeCurrentTab();
}
});
// Set required test prefs.
TEST_PREFS.forEach(([name, value]) => {
Services.prefs.setBoolPref(name, value);
});
let tab = (gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser));
is_element_hidden(
readerButton,
"Reader mode button is not present on a new tab"
);
// Point tab to a test page that is not reader-able due to hidden nodes.
let url = TEST_PATH + "readerModeArticleHiddenNodes.html";
let paintPromise = BrowserTestUtils.waitForContentEvent(
tab.linkedBrowser,
"MozAfterPaint",
false,
e =>
e.originalTarget.location.href.endsWith("HiddenNodes.html") &&
e.originalTarget.document.readyState == "complete"
);
BrowserTestUtils.loadURIString(tab.linkedBrowser, url);
await paintPromise;
is_element_hidden(
readerButton,
"Reader mode button is still not present on tab with unreadable content."
);
});
|