Document about when accessing childCount throws

RESOLVED FIXED in Firefox 3 alpha4

Status

()

Firefox
Bookmarks & History
RESOLVED FIXED
11 years ago
8 years ago

People

(Reporter: johnath, Assigned: johnath)

Tracking

Trunk
Firefox 3 alpha4
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

11 years ago
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);
(Assignee)

Comment 1

11 years ago
Created attachment 261079 [details] [diff] [review]
Add @throws line for childCount

As discussed - the behaviour is correct as is, it's the documentation that is lacking.
Attachment #261079 - Flags: review?
(Assignee)

Comment 2

11 years ago
Created attachment 261081 [details] [diff] [review]
Whoops - last one was an ugly diff
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
Last Resolved: 11 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.