Closed
Bug 1235376
Opened 8 years ago
Closed 8 years ago
Selection context menu does not replace %s format specifier with selection text
Categories
(WebExtensions :: Untriaged, defect)
Tracking
(firefox46 verified, firefox48 verified)
VERIFIED
FIXED
mozilla46
People
(Reporter: ato, Assigned: gkrizsanits)
Details
Attachments
(3 files)
The %s format specifier is according to https://developer.chrome.com/extensions/contextMenus#method-create supposed to be replaced with the selectionText if a context menu item’s "contexts" array contains "selection". Example: var translateSelection = ev => console.log(ev.selectionText); chrome.contextMenus.create({ title: "Translate “%s”", contexts: ["selection"], onclick: translateSelection }); On Firefox Nightly 46.0a1 (2015-12-18), "%s" is left untouched. If selecting a text "foo" in content, I’d expect "foo" to appear in the context menu as "Translate “foo”", instead "Translate “%s”" is displayed.
Reporter | ||
Comment 1•8 years ago
|
||
See attached screenshot.
Assignee | ||
Comment 2•8 years ago
|
||
Yeah it's a known issue, I'm currently doing a refactoring on contextMenus, I'll fix this soon too after landing those patches.
Assignee: nobody → gkrizsanits
Assignee | ||
Comment 3•8 years ago
|
||
It feels to me that we should have a max length for menu item labels so I've added that too. Kris, what do you think?
Attachment #8702868 -
Flags: review?(kmaglione+bmo)
Comment 4•8 years ago
|
||
Comment on attachment 8702868 [details] [diff] [review] Handling %s in contextMenus. v1 Review of attachment 8702868 [details] [diff] [review]: ----------------------------------------------------------------- (In reply to Gabor Krizsanits [:krizsa :gabor] from comment #3) > It feels to me that we should have a max length for menu item labels so I've > added that too. Kris, what do you think? I agree, but I think it would probably be better to leave it to the layout engine, and just limit the length of the selection text here, so something like 'Translate "%s"' would become 'Translate "foo bar..."' rather than 'Translate "foo bar...'.
Attachment #8702868 -
Flags: review?(kmaglione+bmo) → review+
Reporter | ||
Comment 5•8 years ago
|
||
(In reply to Kris Maglione [:kmag] from comment #4) > (In reply to Gabor Krizsanits [:krizsa :gabor] from comment #3) > > It feels to me that we should have a max length for menu item labels so I've > > added that too. Kris, what do you think? > > I agree, but I think it would probably be better to leave it to the layout > engine, and just limit the length of the selection text here, so something > like 'Translate "%s"' would become 'Translate "foo bar..."' rather than > 'Translate "foo bar...'. Yes. The most obvious behaviour to me would be to leave the overall length of the context menu item to be decided by whatever the toolkit’s default hard limit is, and not to apply a special restriction to a string that happens to have a %s substitution in it. Limiting the length of the substitution explicitly seems like a much nicer approach.
Status: NEW → ASSIGNED
Comment 7•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/81e407daa222
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox46:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
Comment 8•8 years ago
|
||
Is manual testing necessary here? If yes, could you provide the proper webextension?
Flags: needinfo?(ato)
Reporter | ||
Comment 9•8 years ago
|
||
Attaching an extension you can use to test this. Install, select any text in a content document, and verify that a "Translate “selected text”" context menu item is added on right-click. The "selected text" above should be replaced by what you select and not exceed 64 characters.
Flags: needinfo?(ato)
Reporter | ||
Comment 10•8 years ago
|
||
FWIW I should add I tested this in Firefox Nightly 48.0a1 (2016-04-03) and it works as expected there.
Comment 11•8 years ago
|
||
Thanks Andreas! I was able to reproduce the initial issue on Firefox 46.0a1 (2015-12-28). Confirm as fixed on Firefox 48.0a1 (2016-04-04) and Firefox 46 beta 6 under Windows 10 64-bit, Mac OS X 10.11 and Ubuntu 12.04 32-bit.
Updated•6 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•