mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-10 13:18:45 +02:00
Backed out changeset 0e88de036c55 (bug 1412456) Backed out changeset 49b93f807db0 (bug 1412456) Backed out changeset 039e980b7dc6 (bug 1412456) Backed out changeset c7698410ddbd (bug 1412456) Backed out changeset e56a1ba26b7c (bug 1412456) Backed out changeset 0c4506e124ac (bug 1412456) Backed out changeset a7aec2ce903b (bug 1412456) Backed out changeset 3e9fb71f1e8e (bug 1412456)
126 lines
3.7 KiB
JavaScript
126 lines
3.7 KiB
JavaScript
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
|
function invokeUsingCtrlD(phase) {
|
|
switch (phase) {
|
|
case 1:
|
|
EventUtils.synthesizeKey("d", { accelKey: true });
|
|
break;
|
|
case 2:
|
|
case 4:
|
|
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
|
break;
|
|
case 3:
|
|
EventUtils.synthesizeKey("d", { accelKey: true });
|
|
EventUtils.synthesizeKey("d", { accelKey: true });
|
|
break;
|
|
}
|
|
}
|
|
|
|
function invokeUsingStarButton(phase) {
|
|
switch (phase) {
|
|
case 1:
|
|
EventUtils.synthesizeMouseAtCenter(BookmarkingUI.star, {});
|
|
break;
|
|
case 2:
|
|
case 4:
|
|
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
|
break;
|
|
case 3:
|
|
EventUtils.synthesizeMouseAtCenter(BookmarkingUI.star,
|
|
{ clickCount: 2 });
|
|
break;
|
|
}
|
|
}
|
|
|
|
var testURL = "data:text/plain,Content";
|
|
var bookmarkId;
|
|
|
|
function add_bookmark(aURI, aTitle) {
|
|
return PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
|
|
aURI, PlacesUtils.bookmarks.DEFAULT_INDEX,
|
|
aTitle);
|
|
}
|
|
|
|
// test bug 432599
|
|
function test() {
|
|
waitForExplicitFinish();
|
|
|
|
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
|
|
gBrowser.selectedBrowser.addEventListener("load", function() {
|
|
waitForStarChange(false, initTest);
|
|
}, {capture: true, once: true});
|
|
|
|
content.location = testURL;
|
|
}
|
|
|
|
function initTest() {
|
|
// First, bookmark the page.
|
|
bookmarkId = add_bookmark(makeURI(testURL), "Bug 432599 Test");
|
|
|
|
checkBookmarksPanel(invokers[currentInvoker], 1);
|
|
}
|
|
|
|
function waitForStarChange(aValue, aCallback) {
|
|
let expectedStatus = aValue ? BookmarkingUI.STATUS_STARRED
|
|
: BookmarkingUI.STATUS_UNSTARRED;
|
|
if (BookmarkingUI.status == BookmarkingUI.STATUS_UPDATING ||
|
|
BookmarkingUI.status != expectedStatus) {
|
|
info("Waiting for star button change.");
|
|
setTimeout(waitForStarChange, 50, aValue, aCallback);
|
|
return;
|
|
}
|
|
aCallback();
|
|
}
|
|
|
|
var invokers = [invokeUsingStarButton, invokeUsingCtrlD];
|
|
var currentInvoker = 0;
|
|
|
|
var initialValue;
|
|
var initialRemoveHidden;
|
|
|
|
var popupElement = document.getElementById("editBookmarkPanel");
|
|
var titleElement = document.getElementById("editBookmarkPanelTitle");
|
|
var removeElement = document.getElementById("editBookmarkPanelRemoveButton");
|
|
|
|
function checkBookmarksPanel(invoker, phase) {
|
|
let onPopupShown = function popupShownListener(aEvent) {
|
|
if (aEvent.originalTarget == popupElement) {
|
|
popupElement.removeEventListener("popupshown", popupShownListener);
|
|
checkBookmarksPanel(invoker, phase + 1);
|
|
}
|
|
};
|
|
let onPopupHidden = function listener(aEvent) {
|
|
if (aEvent.originalTarget == popupElement) {
|
|
popupElement.removeEventListener("popuphidden", listener);
|
|
if (phase < 4) {
|
|
checkBookmarksPanel(invoker, phase + 1);
|
|
} else {
|
|
++currentInvoker;
|
|
if (currentInvoker < invokers.length) {
|
|
checkBookmarksPanel(invokers[currentInvoker], 1);
|
|
} else {
|
|
gBrowser.removeTab(gBrowser.selectedTab, {skipPermitUnload: true});
|
|
PlacesUtils.bookmarks.removeItem(bookmarkId);
|
|
executeSoon(finish);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
switch (phase) {
|
|
case 1:
|
|
case 3:
|
|
popupElement.addEventListener("popupshown", onPopupShown);
|
|
break;
|
|
case 2:
|
|
popupElement.addEventListener("popuphidden", onPopupHidden);
|
|
initialValue = titleElement.value;
|
|
initialRemoveHidden = removeElement.hidden;
|
|
break;
|
|
case 4:
|
|
popupElement.addEventListener("popuphidden", onPopupHidden);
|
|
is(titleElement.value, initialValue, "The bookmark panel's title should be the same");
|
|
is(removeElement.hidden, initialRemoveHidden, "The bookmark panel's visibility should not change");
|
|
break;
|
|
}
|
|
invoker(phase);
|
|
}
|