Closed Bug 1661125 Opened 5 years ago Closed 5 years ago

Improve error messages when passing missing files to tabs.insertCSS and tabs.executeScript

Categories

(WebExtensions :: Untriaged, enhancement)

enhancement

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1420665

People

(Reporter: Fallen, Unassigned)

Details

In this issue, Dan notes that we could improve on the error messages we're showing when missing files are passed to tabs.insertCSS and tabs.executeScript. Maybe we can improve our error messages to make it easier for developer to see the differences between Chrome and Firefox here.

the incompatibility that I spent today tracking down was the difference in behavior between how Firefox and Chromium interpret relative paths passed in the file option to the browser.tabs.insertCSS and browser.tabs.executeScript APIs. The behavior difference and a reasonable workaround is documented on MDN for those APIs already, but it was a little harder than it could have been to track down the issue because Firefox does not give a useful error message when you try to call those APIs using a file that does not exist; the error I got back in that case had the message Error: an unexpected error occurred. We use the webextension APIs via https://github.com/mozilla/webextension-polyfill, not sure if that's part of our issue.

I understand that there isn't a great way to fix the behavior difference without it being a breaking change, but it would be helpful if the error message could identify the issue more concretely (bonus points for specifically detecting a relative path as the file parameter and linking the documentation about that gotcha on MDN as part of the error message)

(In reply to Philipp Kewisch [:Fallen] [:📆][:🧩] from comment #0)

In this issue, Dan notes that we could improve on the error messages we're showing when missing files are passed to tabs.insertCSS and tabs.executeScript. Maybe we can improve our error messages to make it easier for developer to see the differences between Chrome and Firefox here.

the incompatibility that I spent today tracking down was the difference in behavior between how Firefox and Chromium interpret relative paths passed in the file option to the browser.tabs.insertCSS and browser.tabs.executeScript APIs. The behavior difference and a reasonable workaround is documented on MDN for those APIs already, but it was a little harder than it could have been to track down the issue because Firefox does not give a useful error message when you try to call those APIs using a file that does not exist; the error I got back in that case had the message Error: an unexpected error occurred. We use the webextension APIs via https://github.com/mozilla/webextension-polyfill, not sure if that's part of our issue.

No the polyfill is not going to make any difference:
the polyfill is internally detecting if there is already a browser global and it does not polyfill anything at all (but it is a reasonable doubt from an addon developer perspective and so we do mention that in the README.md file here)

I understand that there isn't a great way to fix the behavior difference without it being a breaking change, but it would be helpful if the error message could identify the issue more concretely (bonus points for specifically detecting a relative path as the file parameter and linking the documentation about that gotcha on MDN as part of the error message)

Hey Philipp,
this looks kind of a duplicate of Bug 1420665 (maybe after updating it to explicitly mention that browser.tabs.insertCSS should also be covered in that issue), do you have any reason to prefer keeping this as a separate issue?
(otherwise I'll close it as a duplicate and update Bug 1420665 to explicitly mention browser.tabs.insertCSS)

Flags: needinfo?(philipp)
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Flags: needinfo?(philipp)
You need to log in before you can comment on or make changes to this bug.