fune/toolkit/components/reader/test/browser_readerMode_cached.js
Neil Deakin 239cbc0daf Bug 1640490, cache the article data in the parent process then retrieve it in the reader mode process when entering reader mode, r=Gijs
This allows the correct article to be displayed even when the reader mode ends up using a different process than the original page,

Differential Revision: https://phabricator.services.mozilla.com/D78487
2020-06-06 20:41:02 +00:00

32 lines
1.2 KiB
JavaScript

/* 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);
});