mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
1096696388
--HG-- extra : transplant_source : %AA%DA%ED%B6%24F%92%F0%D3k%F6%D34%2054%C4%23%D8%F0
122 lines
3.5 KiB
JavaScript
122 lines
3.5 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
let gTestTab;
|
|
let gContentAPI;
|
|
let gContentWindow;
|
|
|
|
Components.utils.import("resource:///modules/UITour.jsm");
|
|
|
|
function test() {
|
|
requestLongerTimeout(2);
|
|
UITourTest();
|
|
}
|
|
|
|
function searchEngineTargets() {
|
|
let engines = Services.search.getVisibleEngines();
|
|
return ["searchEngine-" + engine.identifier
|
|
for (engine of engines)
|
|
if (engine.identifier)];
|
|
}
|
|
|
|
let tests = [
|
|
function test_availableTargets(done) {
|
|
gContentAPI.getConfiguration("availableTargets", (data) => {
|
|
ok_targets(data, [
|
|
"accountStatus",
|
|
"addons",
|
|
"appMenu",
|
|
"backForward",
|
|
"bookmarks",
|
|
"customize",
|
|
"help",
|
|
"home",
|
|
"loop",
|
|
"pinnedTab",
|
|
"privateWindow",
|
|
"quit",
|
|
"search",
|
|
"searchProvider",
|
|
"urlbar",
|
|
].concat(searchEngineTargets()));
|
|
ok(UITour.availableTargetsCache.has(window),
|
|
"Targets should now be cached");
|
|
done();
|
|
});
|
|
},
|
|
|
|
function test_availableTargets_changeWidgets(done) {
|
|
CustomizableUI.removeWidgetFromArea("bookmarks-menu-button");
|
|
ok(!UITour.availableTargetsCache.has(window),
|
|
"Targets should be evicted from cache after widget change");
|
|
gContentAPI.getConfiguration("availableTargets", (data) => {
|
|
ok_targets(data, [
|
|
"accountStatus",
|
|
"addons",
|
|
"appMenu",
|
|
"backForward",
|
|
"customize",
|
|
"help",
|
|
"loop",
|
|
"home",
|
|
"pinnedTab",
|
|
"privateWindow",
|
|
"quit",
|
|
"search",
|
|
"searchProvider",
|
|
"urlbar",
|
|
].concat(searchEngineTargets()));
|
|
ok(UITour.availableTargetsCache.has(window),
|
|
"Targets should now be cached again");
|
|
CustomizableUI.reset();
|
|
ok(!UITour.availableTargetsCache.has(window),
|
|
"Targets should not be cached after reset");
|
|
done();
|
|
});
|
|
},
|
|
|
|
function test_availableTargets_exceptionFromGetTarget(done) {
|
|
// The query function for the "search" target will throw if it's not found.
|
|
// Make sure the callback still fires with the other available targets.
|
|
CustomizableUI.removeWidgetFromArea("search-container");
|
|
gContentAPI.getConfiguration("availableTargets", (data) => {
|
|
// Default minus "search" and "searchProvider"
|
|
ok_targets(data, [
|
|
"accountStatus",
|
|
"addons",
|
|
"appMenu",
|
|
"backForward",
|
|
"bookmarks",
|
|
"customize",
|
|
"help",
|
|
"home",
|
|
"loop",
|
|
"pinnedTab",
|
|
"privateWindow",
|
|
"quit",
|
|
"urlbar",
|
|
]);
|
|
CustomizableUI.reset();
|
|
done();
|
|
});
|
|
},
|
|
];
|
|
|
|
function ok_targets(actualData, expectedTargets) {
|
|
// Depending on how soon after page load this is called, the selected tab icon
|
|
// may or may not be showing the loading throbber. Check for its presence and
|
|
// insert it into expectedTargets if it's visible.
|
|
let selectedTabIcon =
|
|
document.getAnonymousElementByAttribute(gBrowser.selectedTab,
|
|
"anonid",
|
|
"tab-icon-image");
|
|
if (selectedTabIcon && UITour.isElementVisible(selectedTabIcon))
|
|
expectedTargets.push("selectedTabIcon");
|
|
|
|
ok(Array.isArray(actualData.targets), "data.targets should be an array");
|
|
is(actualData.targets.sort().toString(), expectedTargets.sort().toString(),
|
|
"Targets should be as expected");
|
|
}
|