зеркало из https://github.com/mozilla/pjs.git
Bug475045 - Can't drag unlinkified URL to bookmarks toolbar. r=mak,enndeakin
This commit is contained in:
Родитель
83965d4183
Коммит
f31ff44f8e
|
@ -1376,15 +1376,23 @@ let PlacesControllerDragHelper = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Extract the first accepted flavor from a flavors array.
|
||||
* Extract the first accepted flavor from a list of flavors.
|
||||
* @param aFlavors
|
||||
* The flavors array.
|
||||
* The flavors list of type nsIDOMDOMStringList.
|
||||
*/
|
||||
getFirstValidFlavor: function PCDH_getFirstValidFlavor(aFlavors) {
|
||||
for (let i = 0; i < aFlavors.length; i++) {
|
||||
if (this.GENERIC_VIEW_DROP_TYPES.indexOf(aFlavors[i]) != -1)
|
||||
return aFlavors[i];
|
||||
}
|
||||
|
||||
// If no supported flavor is found, check if data includes text/plain
|
||||
// contents. If so, request them as text/unicode, a conversion will happen
|
||||
// automatically.
|
||||
if (aFlavors.contains("text/plain")) {
|
||||
return PlacesUtils.TYPE_UNICODE;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_0_library_left_pane_migration.js \
|
||||
browser_library_left_pane_fixnames.js \
|
||||
browser_425884.js \
|
||||
browser_475045.js \
|
||||
browser_423515.js \
|
||||
browser_410196_paste_into_tags.js \
|
||||
browser_457473_no_copy_guid.js \
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
// Make sure the bookmarks bar is visible and restore its state on cleanup.
|
||||
let toolbar = document.getElementById("PersonalToolbar");
|
||||
ok(toolbar, "PersonalToolbar should not be null");
|
||||
|
||||
if (toolbar.collapsed) {
|
||||
setToolbarVisibility(toolbar, true);
|
||||
registerCleanupFunction(function() {
|
||||
setToolbarVisibility(toolbar, false);
|
||||
});
|
||||
}
|
||||
|
||||
// Setup the node we will use to be dropped. The actual node used does not
|
||||
// matter because we will set its data, effect, and mimeType manually.
|
||||
let placesItems = document.getElementById("PlacesToolbarItems");
|
||||
ok(placesItems, "PlacesToolbarItems should not be null");
|
||||
ok(placesItems.localName == "scrollbox", "PlacesToolbarItems should not be null");
|
||||
ok(placesItems.childNodes[0], "PlacesToolbarItems must have at least one child");
|
||||
|
||||
/**
|
||||
* Simulates a drop of a URI onto the bookmarks bar.
|
||||
*
|
||||
* @param aEffect
|
||||
* The effect to use for the drop operation: move, copy, or link.
|
||||
* @param aMimeType
|
||||
* The mime type to use for the drop operation.
|
||||
*/
|
||||
let simulateDragDrop = function(aEffect, aMimeType) {
|
||||
const uriSpec = "http://www.mozilla.org/D1995729-A152-4e30-8329-469B01F30AA7";
|
||||
let uri = makeURI(uriSpec);
|
||||
EventUtils.synthesizeDrop(placesItems.childNodes[0],
|
||||
placesItems,
|
||||
[[{type: aMimeType,
|
||||
data: uriSpec}]],
|
||||
aEffect, window);
|
||||
|
||||
// Verify that the drop produces exactly one bookmark.
|
||||
let bookmarkIds = PlacesUtils.bookmarks
|
||||
.getBookmarkIdsForURI(uri);
|
||||
ok(bookmarkIds.length == 1, "There should be exactly one bookmark");
|
||||
|
||||
PlacesUtils.bookmarks.removeItem(bookmarkIds[0]);
|
||||
|
||||
// Verify that we removed the bookmark successfully.
|
||||
ok(!PlacesUtils.bookmarks.isBookmarked(uri), "URI should be removed");
|
||||
}
|
||||
|
||||
// Simulate a bookmark drop for all of the mime types and effects.
|
||||
let mimeTypes = ["text/plain", "text/unicode", "text/x-moz-url"];
|
||||
let effects = ["move", "copy", "link"];
|
||||
effects.forEach(function (effect) {
|
||||
mimeTypes.forEach(function (mimeType) {
|
||||
simulateDragDrop(effect, mimeType);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -638,7 +638,7 @@ function synthesizeDrop(srcElement, destElement, dragData, dropEffect, aWindow)
|
|||
try {
|
||||
// need to use real mouse action
|
||||
aWindow.addEventListener("dragstart", trapDrag, true);
|
||||
synthesizeMouse(srcElement, 2, 2, { type: "mousedown" }, aWindow);
|
||||
synthesizeMouseAtCenter(srcElement, { type: "mousedown" }, aWindow);
|
||||
synthesizeMouse(srcElement, 11, 11, { type: "mousemove" }, aWindow);
|
||||
synthesizeMouse(srcElement, 20, 20, { type: "mousemove" }, aWindow);
|
||||
aWindow.removeEventListener("dragstart", trapDrag, true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче