From fddee04e63f0d0dd37a92d3ffa78fdf58db7a39e Mon Sep 17 00:00:00 2001 From: "s@rednaks.tn" Date: Wed, 7 Nov 2012 20:47:34 +0200 Subject: [PATCH] Bug 808964 - AccessKeyLabel should be empty string for elements without the accesskey attribute,r=smaug --- content/html/content/src/nsGenericHTMLElement.cpp | 10 ++++++---- content/html/content/test/test_bug583533.html | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index ccbf0dc2b92..718f9629cc4 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -451,11 +451,13 @@ nsGenericHTMLElement::GetAccessKeyLabel(nsAString& aLabel) { nsPresContext *presContext = GetPresContext(); - if (presContext && - presContext->EventStateManager()->GetAccessKeyLabelPrefix(aLabel)) { - nsAutoString suffix; - GetAccessKey(suffix); + if (presContext) { + nsAutoString suffix; + GetAccessKey(suffix); + if (!suffix.IsEmpty() && + presContext->EventStateManager()->GetAccessKeyLabelPrefix(aLabel)) { aLabel.Append(suffix); + } } return NS_OK; diff --git a/content/html/content/test/test_bug583533.html b/content/html/content/test/test_bug583533.html index b584cd3b534..9fd6ce2a4a5 100644 --- a/content/html/content/test/test_bug583533.html +++ b/content/html/content/test/test_bug583533.html @@ -72,6 +72,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=583533 is(label, document.getElementById("e").accessKeyLabel, "JS and C++ agree on accessKeyLabel"); + /** Test for Bug 808964 **/ + + var div = document.createElement("div"); + document.body.appendChild(div); + + is(div.accessKeyLabel, "", "accessKeyLabel should be empty string"); +