Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | /* test that copying a non movable query or folder shortcut makes a new query with the same url, not a deep copy */ |
michael@0 | 6 | |
michael@0 | 7 | const SHORTCUT_URL = "place:folder=2"; |
michael@0 | 8 | const QUERY_URL = "place:sort=8&maxResults=10"; |
michael@0 | 9 | |
michael@0 | 10 | add_task(function copy_toolbar_shortcut() { |
michael@0 | 11 | let library = yield promiseLibrary(); |
michael@0 | 12 | |
michael@0 | 13 | registerCleanupFunction(function () { |
michael@0 | 14 | library.close(); |
michael@0 | 15 | PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId); |
michael@0 | 16 | }); |
michael@0 | 17 | |
michael@0 | 18 | library.PlacesOrganizer.selectLeftPaneQuery("BookmarksToolbar"); |
michael@0 | 19 | |
michael@0 | 20 | yield promiseClipboard(function () { library.PlacesOrganizer._places.controller.copy(); }, |
michael@0 | 21 | PlacesUtils.TYPE_X_MOZ_PLACE); |
michael@0 | 22 | |
michael@0 | 23 | library.PlacesOrganizer.selectLeftPaneQuery("UnfiledBookmarks"); |
michael@0 | 24 | library.ContentTree.view.controller.paste(); |
michael@0 | 25 | |
michael@0 | 26 | let toolbarCopyNode = library.ContentTree.view.view.nodeForTreeIndex(0); |
michael@0 | 27 | is(toolbarCopyNode.type, |
michael@0 | 28 | Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT, |
michael@0 | 29 | "copy is still a folder shortcut"); |
michael@0 | 30 | |
michael@0 | 31 | PlacesUtils.bookmarks.removeItem(toolbarCopyNode.itemId); |
michael@0 | 32 | library.PlacesOrganizer.selectLeftPaneQuery("BookmarksToolbar"); |
michael@0 | 33 | is(library.PlacesOrganizer._places.selectedNode.type, |
michael@0 | 34 | Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT, |
michael@0 | 35 | "original is still a folder shortcut"); |
michael@0 | 36 | }); |
michael@0 | 37 | |
michael@0 | 38 | add_task(function copy_history_query() { |
michael@0 | 39 | let library = yield promiseLibrary(); |
michael@0 | 40 | |
michael@0 | 41 | library.PlacesOrganizer.selectLeftPaneQuery("History"); |
michael@0 | 42 | |
michael@0 | 43 | yield promiseClipboard(function () { library.PlacesOrganizer._places.controller.copy(); }, |
michael@0 | 44 | PlacesUtils.TYPE_X_MOZ_PLACE); |
michael@0 | 45 | |
michael@0 | 46 | library.PlacesOrganizer.selectLeftPaneQuery("UnfiledBookmarks"); |
michael@0 | 47 | library.ContentTree.view.controller.paste(); |
michael@0 | 48 | |
michael@0 | 49 | let historyCopyNode = library.ContentTree.view.view.nodeForTreeIndex(0); |
michael@0 | 50 | is(historyCopyNode.type, |
michael@0 | 51 | Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY, |
michael@0 | 52 | "copy is still a query"); |
michael@0 | 53 | |
michael@0 | 54 | PlacesUtils.bookmarks.removeItem(historyCopyNode.itemId); |
michael@0 | 55 | library.PlacesOrganizer.selectLeftPaneQuery("History"); |
michael@0 | 56 | is(library.PlacesOrganizer._places.selectedNode.type, |
michael@0 | 57 | Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY, |
michael@0 | 58 | "original is still a query"); |
michael@0 | 59 | }); |