Closed Bug 376954 Opened 17 years ago Closed 17 years ago

Document about when accessing childCount throws

Categories

(Firefox :: Bookmarks & History, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 3 alpha4

People

(Reporter: johnath, Assigned: johnath)

Details

Attachments

(1 file, 1 obsolete file)

Attempting to access the childCount property of an nsINavHistoryContainerResultNode instance throws NS_ERROR_NOT_AVAILABLE if the object's containerOpen property is false.

This may be deliberate, in which case the docs on childCount should be updated to reflect this.  Otherwise, some typical error value like -1 might be appropriate?

To recreate:

  var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
    .getService(Components.interfaces.nsINavHistoryService);
    
  var options = historyService.getNewQueryOptions();
  var query = historyService.getNewQuery();
  query.domain = "foo";

  var result = historyService.executeQuery(query, options);
  //result.root.containerOpen = true;
  alert(result.root.childCount);
Attached patch Add @throws line for childCount (obsolete) — Splinter Review
As discussed - the behaviour is correct as is, it's the documentation that is lacking.
Attachment #261079 - Flags: review?
Attachment #261079 - Attachment is obsolete: true
Attachment #261081 - Flags: review?(mano)
Attachment #261079 - Flags: review?
Comment on attachment 261081 [details] [diff] [review]
Whoops - last one was an ugly diff

>Index: nsINavHistoryService.idl
>===================================================================
>RCS file: /cvsroot/mozilla/toolkit/components/places/public/nsINavHistoryService.idl,v
>retrieving revision 1.53
>diff -u -8 -r1.53 nsINavHistoryService.idl
>--- nsINavHistoryService.idl	28 Mar 2007 00:28:34 -0000	1.53
>+++ nsINavHistoryService.idl	9 Apr 2007 23:35:55 -0000
>@@ -240,16 +240,18 @@
>    * to a tree item.
>    */
>   readonly attribute boolean hasChildren;
> 
>   /**
>    * This gives you the children of the nodes. It is preferrable to use this
>    * interface over the array one, since it avoids creating an nsIArray object
>    * and the interface is already the correct type.
>+   *
>+   * @throws NS_ERROR_NOT_AVAILABLE if containerOpen is false.
>    */
>   readonly attribute PRUint32 childCount;
>   nsINavHistoryResultNode getChild(in PRUint32 index);
> 
>   /**
>    * Returns false if this node's list of children can be modified
>    * (adding or removing children, or reordering children), or true if
>    * the UI should not allow the list of children to be modified.
Attachment #261081 - Flags: review?(mano) → review+
Oops
mozilla/toolkit/components/places/public/nsINavHistoryService.idl  1.54
Assignee: nobody → johnath
Flags: in-testsuite-
OS: Mac OS X → All
Hardware: PC → All
Summary: Accessing childCount on query result throws if !containerOpen → Document about when acc essing childCount throws
Target Milestone: --- → Firefox 3 alpha4
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Summary: Document about when acc essing childCount throws → Document about when accessing childCount throws
Bug 451915 - move Firefox/Places bugs to Firefox/Bookmarks and History. Remove all bugspam from this move by filtering for the string "places-to-b-and-h".

In Thunderbird 3.0b, you do that as follows:
Tools | Message Filters
Make sure the correct account is selected. Click "New"
Conditions: Body   contains   places-to-b-and-h
Change the action to "Delete Message".
Select "Manually Run" from the dropdown at the top.
Click OK.

Select the filter in the list, make sure "Inbox" is selected at the bottom, and click "Run Now". This should delete all the bugspam. You can then delete the filter.

Gerv
Component: Places → Bookmarks & History
QA Contact: places → bookmarks
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: