2008-12-18 12:12:40 -08:00
|
|
|
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.sendMouseEvent({ type: "click" }, "star-button");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
EventUtils.synthesizeMouse(document.getElementById("star-button"),
|
|
|
|
1, 1, { clickCount: 2 });
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-27 12:23:26 -07:00
|
|
|
var testURL = "data:text/plain,Content";
|
2010-11-22 11:34:57 -08:00
|
|
|
var bookmarkId;
|
|
|
|
|
|
|
|
function add_bookmark(aURI, aTitle) {
|
|
|
|
return PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
|
|
|
|
aURI, PlacesUtils.bookmarks.DEFAULT_INDEX,
|
|
|
|
aTitle);
|
|
|
|
}
|
2009-07-27 12:23:26 -07:00
|
|
|
|
2008-12-18 12:12:40 -08:00
|
|
|
// test bug 432599
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2009-07-27 12:23:26 -07:00
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
2010-11-22 11:34:57 -08:00
|
|
|
gBrowser.selectedBrowser.addEventListener("load", function () {
|
|
|
|
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
|
|
|
waitForStarChange(false, initTest);
|
|
|
|
}, true);
|
2008-12-18 12:12:40 -08:00
|
|
|
|
2009-07-27 12:23:26 -07:00
|
|
|
content.location = testURL;
|
2008-12-18 12:12:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function initTest() {
|
2010-11-22 11:34:57 -08:00
|
|
|
// First, bookmark the page.
|
|
|
|
bookmarkId = add_bookmark(makeURI(testURL), "Bug 432599 Test");
|
2008-12-18 12:12:40 -08:00
|
|
|
|
|
|
|
checkBookmarksPanel(invokers[currentInvoker], 1);
|
|
|
|
}
|
|
|
|
|
2010-11-22 11:34:57 -08:00
|
|
|
function waitForStarChange(aValue, aCallback) {
|
|
|
|
let starButton = document.getElementById("star-button");
|
2010-12-28 05:29:15 -08:00
|
|
|
if (PlacesStarButton._ignoreClicks || starButton.hasAttribute("starred") != aValue) {
|
2010-11-22 11:34:57 -08:00
|
|
|
info("Waiting for star button change.");
|
|
|
|
setTimeout(arguments.callee, 50, aValue, aCallback);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
aCallback();
|
|
|
|
}
|
|
|
|
|
|
|
|
let invokers = [invokeUsingStarButton, invokeUsingCtrlD];
|
|
|
|
let currentInvoker = 0;
|
|
|
|
|
2008-12-18 12:12:40 -08:00
|
|
|
let initialValue;
|
|
|
|
let initialRemoveHidden;
|
|
|
|
|
|
|
|
let popupElement = document.getElementById("editBookmarkPanel");
|
|
|
|
let titleElement = document.getElementById("editBookmarkPanelTitle");
|
|
|
|
let removeElement = document.getElementById("editBookmarkPanelRemoveButton");
|
|
|
|
|
|
|
|
function checkBookmarksPanel(invoker, phase)
|
|
|
|
{
|
|
|
|
let onPopupShown = function(aEvent) {
|
|
|
|
if (aEvent.originalTarget == popupElement) {
|
2010-11-22 11:34:57 -08:00
|
|
|
popupElement.removeEventListener("popupshown", arguments.callee, false);
|
2008-12-18 12:12:40 -08:00
|
|
|
checkBookmarksPanel(invoker, phase + 1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let onPopupHidden = function(aEvent) {
|
|
|
|
if (aEvent.originalTarget == popupElement) {
|
2010-11-22 11:34:57 -08:00
|
|
|
popupElement.removeEventListener("popuphidden", arguments.callee, false);
|
2008-12-18 12:12:40 -08:00
|
|
|
if (phase < 4) {
|
|
|
|
checkBookmarksPanel(invoker, phase + 1);
|
|
|
|
} else {
|
2009-07-27 12:23:26 -07:00
|
|
|
++currentInvoker;
|
2008-12-18 12:12:40 -08:00
|
|
|
if (currentInvoker < invokers.length) {
|
|
|
|
checkBookmarksPanel(invokers[currentInvoker], 1);
|
|
|
|
} else {
|
|
|
|
gBrowser.removeCurrentTab();
|
2010-11-22 11:34:57 -08:00
|
|
|
PlacesUtils.bookmarks.removeItem(bookmarkId);
|
|
|
|
executeSoon(finish);
|
2008-12-18 12:12:40 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
switch (phase) {
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
popupElement.addEventListener("popupshown", onPopupShown, false);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
popupElement.addEventListener("popuphidden", onPopupHidden, false);
|
|
|
|
initialValue = titleElement.value;
|
|
|
|
initialRemoveHidden = removeElement.hidden;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
popupElement.addEventListener("popuphidden", onPopupHidden, false);
|
|
|
|
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);
|
|
|
|
}
|