Closed Bug 1595081 Opened 5 years ago Closed 5 years ago

browser.bookmarks.search fails to support quoted search tokens

Categories

(WebExtensions :: Compatibility, defect, P2)

defect

Tracking

(firefox72 fixed)

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: jimm, Assigned: mixedpuppy)

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

According to MDN, you should be able to do quoted keyword searches using browser.bookmarks.search. In practice though this doesn't appear to be implemented.

From MDN: "If query is a string, it consists of zero or more search terms. Search terms are space-delimited and may be enclosed in quotes to allow multiple-word phrases to be searched against. Each search term matches if it matches any substring in the bookmark's URL or title. Matching is case-insensitive. For a bookmark to match the query, all the query's search terms must match."

For example, say you have a bookmark with the text "Hello Dolly". The search:

browser.bookmarks.search("Hello Dolly")

succeeds due to Hello and Dolly matching independently. However if you try "'Hello Dolly'" or " 'Hello Dolly' " or "'Hello Dolly' 'Hello Dolly'" the search fails. This doesn't sync with the MDN docs.

https://searchfox.org/mozilla-central/source/toolkit/components/places/SQLFunctions.cpp#488
https://searchfox.org/mozilla-central/source/xpcom/ds/nsWhitespaceTokenizer.h#94

The doc page at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/bookmarks/search
needs to be updated, we don't support quoted strings as described (or at all really).

Flags: needinfo?(richard)
Keywords: dev-doc-needed

The documentation also describes the query as a "string or object ", could you define the quote enclosed string in an object? However, I also note that the subsequent documentation only refers to the query as a string, is there a quick way to confirm what types the function takes or should I test?

Flags: needinfo?(richard) → needinfo?(mixedpuppy)
Flags: needinfo?(mixedpuppy)
Flags: needinfo?(richard)

And the schema is definitive? So, it would appear that we missing documentation of the object that can be used to define the search terms.

Flags: needinfo?(richard) → needinfo?(mixedpuppy)

(In reply to Richard Bloor from comment #2)

could you define the quote enclosed string in an object?

No. Our underlying search code doesn't support this (per comment 0).

(In reply to Richard Bloor from comment #4)

And the schema is definitive? So, it would appear that we missing documentation of the object that can be used to define the search terms.

The object that can be passed is documented in the params section of the function. The param can either be a string or an object as documented here:

https://searchfox.org/mozilla-central/rev/524bed6dfbc5ae21c62632d83b7573448b29e0ac/browser/components/extensions/schemas/bookmarks.json#266-284

I see that the schema says we can use quoted strings, which is also wrong, I should fix that (in this bug).

Flags: needinfo?(mixedpuppy) → needinfo?(richard)
Assignee: nobody → mixedpuppy
Priority: -- → P2
Pushed by scaraveo@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8c5e8ea700d9
remove documentation about quoted phrases in bookmark search r=rpl
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72

Hello,

Will this fix require manual validation? If yes, please provide some steps to reproduce in order to correctly test it and also, please set the "qe-verify+" flag. Otherwise, could the "qe-verify-" flag be added? Thanks!

Flags: needinfo?(mixedpuppy)

Somewhat unclear as to what information I am expected to provide re-comment 4. However, I believe I have the information needed to make the necessary documentation changes.

Flags: needinfo?(richard)

https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/bookmarks/searchIs now updated with the reference to quote delineated search terms removed. Please let me know if there are any further changes needed or whether I can mark as dev-doc-done.

Thanks for the doc update, looks good.

Flags: needinfo?(mixedpuppy) → qe-verify-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: