Closed Bug 1427298 Opened 7 years ago Closed 1 year ago

ContextMenu selectionText formatting issue with Pre, Textarea

Categories

(WebExtensions :: Frontend, defect, P5)

58 Branch
defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: eros_uk, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0 Build ID: 20171115220414 Steps to reproduce: The selectionText passed to ContextMenu onclick is normalised when the selection text is inside a PRE or TEXTAREA. The return value is a long string. eg: Instead of this: { "name": "Eternal Flame", "age": 1000000, "secretIdentity": "Unknown", "powers": [ "Immortality", "Heat Immunity", "Inferno", "Teleportation", "Interdimensional travel" ] } You end up with: { "name": "Eternal Flame", "age": 1000000, "secretIdentity": "Unknown", "powers": [ "Immortality", "Heat Immunity", "Inferno", "Teleportation", "Interdimensional travel" ] } I don't know if that was intended or not, but it is causing inconsistencies.
Priority: -- → P5
Product: Toolkit → WebExtensions
Severity: normal → S3

I was working on the update of my addon and it appears that the bug is no longer an issue.
It seems the issue has been fixed as part of some other process.
info.selectionText currently returns a JSON.stringify string.
If you know when it was done, you can mark it fixed for that Firefox version.

browser.menus.onClicked.addListener(process);
function process(info, tab) {
  console.log(info);
}

/*
{
  "menuItemId": "copyPlainText",
  "parentMenuItemId": 129,
  "viewType": "tab",
  "frameId": 0,
  "editable": true,
  "targetElementId": 723970,
  "pageUrl": "file:///..../TestPage.htm",
  "selectionText": "{\n  \"name\": \"Eternal Flame\",\n  \"age\": 1000000,\n  \"secretIdentity\": \"Unknown\",\n  \"powers\": [\n    \"Immortality\",\n    \"Heat Immunity\",\n    \"Inferno\",\n    \"Teleportation\",\n    \"Interdimensional travel\"\n  ]\n}",
  "modifiers": [],
  "button": 0
}
*/

This was resolved in bug 1338898.

Here is the relevant source change: it passes the original selection text instead of converting consecutive whitespace to a space character: https://searchfox.org/mozilla-central/diff/5a4e0a54509eb4337f407710563be66a463ed810/toolkit/modules/BrowserUtils.jsm#485-509

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Depends on: 1338898
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.