From 1bda00a462da11284bf8198501d3c9bb972909b4 Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Thu, 10 Jul 2014 03:31:04 -0700 Subject: [PATCH] Bug 1005601 - "gContextMenu is null" thrown for first textarea context menu in a window. r=Gijs --- browser/base/content/nsContextMenu.js | 4 +- .../test/general/contextmenu_common.js | 7 +- .../test/general/test_contextmenu.html | 158 ++++++++++-------- .../test/general/test_contextmenu_input.html | 27 +-- toolkit/modules/InlineSpellChecker.jsm | 6 + 5 files changed, 114 insertions(+), 88 deletions(-) diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index 981d4397b336..0c6d910ccbac 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -344,7 +344,9 @@ nsContextMenu.prototype = { }, initSpellingItems: function() { - var canSpell = InlineSpellCheckerUI.canSpellCheck && this.canSpellCheck; + var canSpell = InlineSpellCheckerUI.canSpellCheck && + !InlineSpellCheckerUI.initialSpellCheckPending && + this.canSpellCheck; var onMisspelling = InlineSpellCheckerUI.overMisspelling; var showUndo = canSpell && InlineSpellCheckerUI.canUndo(); this.showItem("spell-check-enabled", canSpell); diff --git a/browser/base/content/test/general/contextmenu_common.js b/browser/base/content/test/general/contextmenu_common.js index 4bb881355641..016afb0469b3 100644 --- a/browser/base/content/test/general/contextmenu_common.js +++ b/browser/base/content/test/general/contextmenu_common.js @@ -16,10 +16,13 @@ function openContextMenuFor(element, shiftkey, waitForSpellCheck) { synthesizeMouse(element, 2, 2, eventDetails, element.ownerDocument.defaultView); } - if (waitForSpellCheck) + if (waitForSpellCheck) { + var { onSpellCheck } = SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", {}); onSpellCheck(element, actuallyOpenContextMenuFor); - else + } + else { actuallyOpenContextMenuFor(); + } } function closeContextMenu() { diff --git a/browser/base/content/test/general/test_contextmenu.html b/browser/base/content/test/general/test_contextmenu.html index 0b7bfbb16c91..d90f21c3e600 100644 --- a/browser/base/content/test/general/test_contextmenu.html +++ b/browser/base/content/test/general/test_contextmenu.html @@ -21,7 +21,6 @@ Browser context menu tests.