diff -r 000000000000 -r 6474c204b198 browser/metro/base/tests/mochitest/helpers/BookmarksHelper.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browser/metro/base/tests/mochitest/helpers/BookmarksHelper.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,101 @@ +// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +var BookmarksTestHelper = { + _originalNavHistoryService: null, + _startView: null, + MockNavHistoryService: { + getNewQueryOptions: function () { + return {}; + }, + getNewQuery: function () { + return { + setFolders: function(){} + }; + }, + executeQuery: function () { + return { + root: { + get childCount() { + return Object.keys(BookmarksTestHelper._nodes).length; + }, + + getChild: function (aIndex) BookmarksTestHelper._nodes[Object.keys(BookmarksTestHelper._nodes)[aIndex]] + } + } + } + }, + + _originalBookmarkService: null, + MockBookmarkService: { + getItemIndex: function (aIndex) aIndex, + getBookmarkURI: function (aId) BookmarksTestHelper._nodes[aId].uri, + getItemTitle: function (aId) BookmarksTestHelper._nodes[aId].title, + removeItem: function (aId) { + delete BookmarksTestHelper._nodes[aId]; + + // Simulate observer notification + BookmarksTestHelper._startView._changes.onItemRemoved(aId, BookmarksTestHelper._startView._root); + }, + }, + + Node: function (aTitle, aId) { + this.type = this.RESULT_TYPE_URI = 0; + this.title = aTitle; + this.itemId = aId; + this.uri = "http://" + aTitle + ".com.br"; + this.pinned = true + }, + + _nodes: null, + createNodes: function (aMany) { + this._nodes = {}; + for (let i=0; i