Bug 1437476 - Add a test for checking that a bookmark can be loaded inside the Bookmarks sidebar. r=standard8

MozReview-Commit-ID: 2UfcC1tF6Eh

--HG--
extra : rebase_source : 494159007f2efc9f89cd4ee77c8ff17e53c73cae
This commit is contained in:
Paul Silaghi 2018-02-28 15:59:57 +00:00
Родитель 199e734a04
Коммит e39ab9c0e6
2 изменённых файлов: 74 добавлений и 0 удалений

Просмотреть файл

@ -19,6 +19,8 @@ skip-if = (os == 'win' && ccov) # Bug 1423667
skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_bookmark_folder_moveability.js]
skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_bookmark_load_in_sidebar.js]
skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_bookmark_private_window.js]
skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_bookmark_remove_tags.js]

Просмотреть файл

@ -0,0 +1,72 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Test that a bookmark can be loaded inside the Bookmarks sidebar.
*/
"use strict";
const TEST_URL = "about:buildconfig";
// Cleanup.
registerCleanupFunction(async () => {
await PlacesUtils.bookmarks.eraseEverything();
});
add_task(async function test_load_in_sidebar() {
let bm = await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: TEST_URL,
title: TEST_URL,
});
await withSidebarTree("bookmarks", async function(tree) {
tree.selectItems([bm.guid]);
await withBookmarksDialog(
false,
function openPropertiesDialog() {
tree.controller.doCommand("placesCmd_show:info");
},
// Check the "Load this bookmark in the sidebar" option.
async function test(dialogWin) {
let loadInSidebar = dialogWin.document.getElementById("editBMPanel_loadInSidebarCheckbox");
let promiseCheckboxChanged = PlacesTestUtils.waitForNotification(
"onItemChanged",
(id, parentId, checked) => checked === true
);
loadInSidebar.click();
EventUtils.synthesizeKey("VK_RETURN", {}, dialogWin);
await promiseCheckboxChanged;
}
);
let sidebar = document.getElementById("sidebar");
let sidebarLoadedPromise = new Promise(resolve => {
sidebar.addEventListener("load", function() {
executeSoon(resolve);
}, {capture: true, once: true});
});
// Select and open the bookmark in the sidebar.
tree.selectItems([bm.guid]);
tree.controller.doCommand("placesCmd_open");
await sidebarLoadedPromise;
let sidebarTitle = document.getElementById("sidebar-title");
let sidebarBrowser = sidebar.contentDocument.getElementById("web-panels-browser");
await BrowserTestUtils.browserLoaded(sidebarBrowser, false, TEST_URL);
let h1Elem = sidebarBrowser.contentDocument.getElementsByTagName("h1")[0];
// Check that the title and the content of the page are loaded successfully.
Assert.equal(sidebarTitle.value, TEST_URL, "The sidebar title is successfully loaded.");
Assert.equal(h1Elem.textContent, TEST_URL, "The sidebar content is successfully loaded.");
});
});