Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

PlacesAPI

Tests which have to access bookmarks or history related functions can use the PlacesAPI to make testing easier.

Method overview

boolean isBookmarkInFolder(in nsIURI uri, in string folderId);
restoreDefaultBookmarks();

Attributes

Attribute Type Description
bookmarksService nsINavBookmarksService Instance of the bookmarks service to ease the access to bookmark related functions.
historyService nsINavHistoryService Instance of the history service to ease the access to history related functions.
livemarkService nsILivemarkService Instance of the livemark service to ease the access to RSS related functions.

Methods

isBookmarkInFolder()

Checks to see if the given URI is bookmarked inside the specified folder, which is given by ID.

boolean isBookmarkInFolder(
  in nsIURI uri,
  in string folderId
); 
Parameters
uri
An nsIURI instance specifies the URL to check.
folderId
Folder which has to be checked for a bookmark with the given URL.
Return value

true if the URIĀ is bookmarked in the specified folder; otherwise false.

Example
// Include necessary modules
var RELATIVE_ROOT = '../../shared-modules';
var MODULE_REQUIRES = ['PlacesAPI'];

var testBookmarkInFolder = function() {
  var uri = UtilsAPI.createURI("https://www.mozilla.org");
  if (PlacesAPI.isBookmarkInFolder(uri, PlacesAPI.bookmarksService.bookmarksMenuFolder))
    controller.window.alert("URI has been bookmarked in the Bookmarks Menu folder");
}

restoreDefaultBookmarks()

Restores all the bookmarks to their initial state.

Warning: Be aware that this function will erase any of the already saved bookmarks.
restoreDefaultBookmarks();
Parameters

None.

Document Tags and Contributors

 Contributors to this page: Sheppy, Whimboo
 Last updated by: Sheppy,