Open Bug 1352835 Opened 7 years ago Updated 2 years ago

bookmarks.search fails on non-http(s) URLs

Categories

(WebExtensions :: General, defect, P3)

52 Branch
defect

Tracking

(Not tracked)

REOPENED

People

(Reporter: k, Unassigned)

Details

(Whiteboard: [bookmarks], triaged)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0
Build ID: 20170317213149

Steps to reproduce:

I'm developping a WebExtension that calls bookmarks.search for the current tab URL. Works fine for http(s) URLs but fails for about: and file: URLs.


Actual results:

Thrown error: "Type error for parameter query (Value must either: be a string value, or .url must match the format "url") for bookmarks.search."


Expected results:

It should not throw an error and return the search result instead.
Component: Untriaged → WebExtensions: Untriaged
Product: Firefox → Toolkit
Flags: needinfo?(bob.silverberg)
Priority: -- → P3
Whiteboard: [bookmarks], triaged
I confirmed that this does work in Chrome with chrome:// and file:// URLs. Kris said it's something we might as well do, with the comment "Just add a flag to MatchPattern to allow it to match all protocols", although I'm not yet sure exactly what that means.

A current workaround, until someone fixes this bug, is to just use the basic string search, which will match the url field of the bookmark.
Status: UNCONFIRMED → NEW
Component: WebExtensions: Untriaged → WebExtensions: General
Ever confirmed: true
Flags: needinfo?(bob.silverberg)
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INACTIVE
Status: RESOLVED → REOPENED
Resolution: INACTIVE → ---
Product: Toolkit → WebExtensions

Same problem here, on my Bookmark Search Plus 2 extension:

If I search through

browser.bookmarks.search({url: tabUrl})

I get an exception

Error: Type error for parameter query (Value must either: be a string value, or .url must match the format "url") for bookmarks.search.

for URLs in

	   || (tabUrl.startsWith("moz-extension://"))
	   || (tabUrl.startsWith("about:"))
	   || (tabUrl.startsWith("data:"))
	   || (tabUrl.startsWith("file:"))
	   || (tabUrl.startsWith("blob:))

Note also that doing a simple general search like

browser.bookmarks.search(tabUrl)

does not generate the exception (and therefore is a workaround, although it can return more results because this is mathcing both toitle and url, and so it needs filtering out).

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.