Bug 1029486 - Check for dead wrappers after running language detection r=felipe. a=gavin
authorTim Taubert <ttaubert@mozilla.com>
Tue, 24 Jun 2014 14:04:45 +0200
changeset 207351 8d2520df7f5b9d7b09f7a296adab62a91cc7c56a
parent 207350 b17023fb1dc476d2a7fc32daf2290c4cac3a0268
child 207352 d115bce9216939320400e98401c586dd66dadcd1
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe, gavin
bugs1029486
milestone32.0a2
Bug 1029486 - Check for dead wrappers after running language detection r=felipe. a=gavin
browser/components/translation/TranslationContentHandler.jsm
--- a/browser/components/translation/TranslationContentHandler.jsm
+++ b/browser/components/translation/TranslationContentHandler.jsm
@@ -80,18 +80,25 @@ TranslationContentHandler.prototype = {
     encoder.init(content.document, "text/plain", encoder.SkipInvisibleContent);
     let string = encoder.encodeToStringWithMaxLength(60 * 1024);
 
     // Language detection isn't reliable on very short strings.
     if (string.length < 100)
       return;
 
     LanguageDetector.detectLanguage(string).then(result => {
-      if (!result.confident)
+      // Bail if we're not confident.
+      if (!result.confident) {
         return;
+      }
+
+      // The window might be gone by now.
+      if (Cu.isDeadWrapper(content)) {
+        return;
+      }
 
       content.detectedLanguage = result.language;
 
       let data = {
         state: STATE_OFFER,
         originalShown: true,
         detectedLanguage: result.language
       };