fune/browser/base/content/test/general/browser_bug1124271_readerModePinnedTab.js
Timothy Guan-tin Chien 66f6b8a43b Bug 1184950 - Use goBack to leave the reader view when possible, r=margaret, r=gijs
MozReview-Commit-ID: G9wn4OyUL5q

--HG--
extra : transplant_source : %5Cw%B1%F5X%9A%95N%93i%91%9B%BA%CC%BBr%F2%E1%A0%99
2016-04-19 05:46:58 +08:00

47 lines
1.6 KiB
JavaScript

/* 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 won't open in a new tab when clicked from a pinned tab
const PREF = "reader.parse-on-load.enabled";
const TEST_PATH = "http://example.com/browser/browser/base/content/test/general/";
var readerButton = document.getElementById("reader-mode-button");
add_task(function* () {
registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF);
while (gBrowser.tabs.length > 1) {
gBrowser.removeCurrentTab();
}
});
// Enable the reader mode button.
Services.prefs.setBoolPref(PREF, true);
let tab = gBrowser.selectedTab = gBrowser.addTab();
gBrowser.pinTab(tab);
let initialTabsCount = gBrowser.tabs.length;
// Point tab to a test page that is reader-able.
let url = TEST_PATH + "readerModeArticle.html";
yield promiseTabLoadEvent(tab, url);
yield promiseWaitForCondition(() => !readerButton.hidden);
readerButton.click();
yield promiseTabLoadEvent(tab);
// Ensure no new tabs are opened when exiting reader mode in a pinned tab
is(gBrowser.tabs.length, initialTabsCount, "No additional tabs were opened.");
readerButton.click();
yield BrowserTestUtils.waitForContentEvent(tab.linkedBrowser, "pageshow");
// Ensure no new tabs are opened when exiting reader mode in a pinned tab
is(gBrowser.tabs.length, initialTabsCount, "No additional tabs were opened.");
gBrowser.removeCurrentTab();
});