From 207a7d9ff7e31a2196685cb2311e220c6c4c8cec Mon Sep 17 00:00:00 2001 From: Ian Bicking Date: Tue, 29 Aug 2017 13:40:58 -0500 Subject: [PATCH] Fix #3406, add logging of unexpected clipboard state This logs cases when the passed-in text is empty, or the textarea select doesn't appear to work. Logs are sent to Sentry. --- addon/webextension/clipboard.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addon/webextension/clipboard.js b/addon/webextension/clipboard.js index 140e143fff..2a178a667e 100644 --- a/addon/webextension/clipboard.js +++ b/addon/webextension/clipboard.js @@ -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"));