From e99a2bcb4509e78574d41b836248146b962a4a3a Mon Sep 17 00:00:00 2001 From: Ian Bicking Date: Mon, 14 Nov 2016 14:39:34 -0600 Subject: [PATCH] Suppress some errors that are happening during teardown, when the document is no longer valid --- addon/data/error-utils.js | 6 +++++- addon/data/selector-ui.js | 4 ++++ addon/data/shooter-interactive-worker.js | 11 ++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/addon/data/error-utils.js b/addon/data/error-utils.js index b0338cc15f..4ff7da2dbe 100644 --- a/addon/data/error-utils.js +++ b/addon/data/error-utils.js @@ -4,7 +4,11 @@ /** Call with an error object (with .name, .message, .help, etc) */ function unhandled(error) { - console.error("Internal error", location.href); + try { + console.error("Internal error", location.href); + } catch (e) { + // Something location.href doesn't work + } self.port.emit("alertError", error); } diff --git a/addon/data/selector-ui.js b/addon/data/selector-ui.js index b54fff5871..0602e66bd5 100644 --- a/addon/data/selector-ui.js +++ b/addon/data/selector-ui.js @@ -416,10 +416,14 @@ const ui = (function () { // eslint-disable-line no-unused-vars /** Removes every UI this module creates */ exports.remove = function () { for (let name in exports) { + if (name == "iframe") { + continue; + } if (typeof exports[name] == "object" && exports[name].remove) { exports[name].remove(); } } + exports.iframe.remove(); }; exports.ChromeInterface = { diff --git a/addon/data/shooter-interactive-worker.js b/addon/data/shooter-interactive-worker.js index 8153b608e9..f938b42a16 100644 --- a/addon/data/shooter-interactive-worker.js +++ b/addon/data/shooter-interactive-worker.js @@ -843,9 +843,14 @@ function activate() { function deactivate() { ui.Box.remove(); - ui.remove(); - removeHandlers(); - setState("cancel"); + try { + ui.remove(); + removeHandlers(); + setState("cancel"); + } catch (e) { + // Sometimes this fires so late that the document isn't available + // We don't care about the exception, so we swallow it here + } } /***********************************************