Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #3406, add logging of unexpected clipboard state (#3430)
Browse files Browse the repository at this point in the history
This logs cases when the passed-in text is empty, or the textarea select doesn't appear to work. Logs are sent to Sentry.
  • Loading branch information
ianb authored and jaredhirsch committed Aug 31, 2017
1 parent 900f438 commit 10b7c0f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions addon/webextension/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ this.clipboard = (function() {
let el = doc.createElement("textarea");
doc.body.appendChild(el);
el.value = text;
if (!text) {
let exc = new Error("Clipboard copy given empty text");
exc.noPopup = true;
catcher.unhandled(exc);
}
el.select();
if (doc.activeElement !== el) {
let unhandledTag = doc.activeElement ? doc.activeElement.tagName : "No active element";
let exc = new Error("Clipboard el.select failed");
exc.activeElement = unhandledTag;
exc.noPopup = true;
catcher.unhandled(exc);
}
const copied = doc.execCommand("copy");
if (!copied) {
catcher.unhandled(new Error("Clipboard copy failed"));
Expand Down

0 comments on commit 10b7c0f

Please sign in to comment.