fune/browser/components/preferences/in-content/tests/browser_applications_selection.js
Timothy Guan-tin Chien de00d490e0 Bug 1363850 - Part II, Move old about:preferences from in-content-old/ to in-content/, r=jaws,mconley
MozReview-Commit-ID: DPLJT1adO1c

--HG--
rename : browser/components/preferences/in-content-old/content.js => browser/components/preferences/in-content/content.js
rename : browser/components/preferences/in-content-old/content.xul => browser/components/preferences/in-content/content.xul
rename : browser/components/preferences/in-content-old/search.js => browser/components/preferences/in-content/search.js
rename : browser/components/preferences/in-content-old/search.xul => browser/components/preferences/in-content/search.xul
rename : browser/components/preferences/in-content-old/security.js => browser/components/preferences/in-content/security.js
rename : browser/components/preferences/in-content-old/security.xul => browser/components/preferences/in-content/security.xul
rename : browser/components/preferences/in-content-old/tests/browser_advanced_siteData.js => browser/components/preferences/in-content/tests/browser_advanced_siteData.js
extra : rebase_source : 57611e32dba47a2238a5e0573c25478a96cfb8fd
2017-05-31 08:20:26 +08:00

79 lines
3 KiB
JavaScript

var win;
var feedItem;
var container;
SimpleTest.requestCompleteLog();
add_task(async function setup() {
await openPreferencesViaOpenPreferencesAPI("applications", null, {leaveOpen: true});
info("Preferences page opened on the applications pane.");
registerCleanupFunction(() => {
gBrowser.removeCurrentTab();
});
});
add_task(async function getFeedItem() {
win = gBrowser.selectedBrowser.contentWindow;
container = win.document.getElementById("handlersView");
feedItem = container.querySelector("richlistitem[type='application/vnd.mozilla.maybe.feed']");
Assert.ok(feedItem, "feedItem is present in handlersView.");
})
add_task(async function selectInternalOptionForFeed() {
// Select the item.
feedItem.scrollIntoView();
container.selectItem(feedItem);
Assert.ok(feedItem.selected, "Should be able to select our item.");
// Wait for the menu.
let list = await waitForCondition(() =>
win.document.getAnonymousElementByAttribute(feedItem, "class", "actionsMenu"));
info("Got list after item was selected");
// Find the "Add Live bookmarks option".
let chooseItems = list.getElementsByAttribute("action", Ci.nsIHandlerInfo.handleInternally);
Assert.equal(chooseItems.length, 1, "Should only be one action to handle internally");
// Select the option.
let cmdEvent = win.document.createEvent("xulcommandevent");
cmdEvent.initCommandEvent("command", true, true, win, 0, false, false, false, false, null);
chooseItems[0].dispatchEvent(cmdEvent);
// Check that we display the correct result.
list = await waitForCondition(() =>
win.document.getAnonymousElementByAttribute(feedItem, "class", "actionsMenu"));
info("Got list after item was selected");
Assert.ok(list.selectedItem, "Should have a selected item.");
Assert.equal(list.selectedItem.getAttribute("action"),
Ci.nsIHandlerInfo.handleInternally,
"Newly selected item should be the expected one.");
});
// This builds on the previous selectInternalOptionForFeed task.
add_task(async function reselectInternalOptionForFeed() {
// Now select a different option in the list - use the pdf item as that doesn't
// need to load any favicons.
let anotherItem = container.querySelector("richlistitem[type='application/pdf']");
container.selectItem(anotherItem);
// Wait for the menu so that we don't hit race conditions.
await waitForCondition(() =>
win.document.getAnonymousElementByAttribute(anotherItem, "class", "actionsMenu"));
info("Got list after item was selected");
// Now select the feed item again, and check what it is displaying.
container.selectItem(feedItem);
let list = await waitForCondition(() =>
win.document.getAnonymousElementByAttribute(feedItem, "class", "actionsMenu"));
info("Got list after item was selected");
Assert.ok(list.selectedItem,
"Should have a selected item");
Assert.equal(list.selectedItem.getAttribute("action"),
Ci.nsIHandlerInfo.handleInternally,
"Selected item should still be the same as the previously selected item.");
});