summaryrefslogtreecommitdiffstats
path: root/toolkit/components/reader/test/browser_readerMode_cached.js
blob: 7f36a15dbba4c9745883d0500902b6c843dd75ba (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

// This test verifies that the article is properly using the cached data
// when switching into reader mode. The article produces a random number
// contained within it, so if the article gets reloaded instead of using
// the cached version, it would have a different value in it.
const URL =
  "http://mochi.test:8888/browser/toolkit/components/reader/test/readerModeRandom.sjs";

add_task(async function () {
  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);

  let randomNumber = await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
    return content.document.getElementById("rnd").textContent;
  });

  let promiseTabLoad = promiseTabLoadEvent(tab);
  let readerButton = document.getElementById("reader-mode-button");
  readerButton.click();
  await promiseTabLoad;
  await TestUtils.waitForCondition(() => !readerButton.hidden);

  let newRandomNumber = await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
    return content.document.getElementById("rnd").textContent;
  });

  is(randomNumber, newRandomNumber, "used the same value");

  BrowserTestUtils.removeTab(tab);
});