diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 1032ac81ad24..10a5b0be3b3e 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2636,12 +2636,23 @@ function FillInHTMLTooltip(tipElement)
var titleText = null;
var XLinkTitleText = null;
+ var SVGTitleText = null;
var direction = tipElement.ownerDocument.dir;
- while (!titleText && !XLinkTitleText && tipElement) {
+ while (!titleText && !XLinkTitleText && !SVGTitleText && tipElement) {
if (tipElement.nodeType == Node.ELEMENT_NODE) {
titleText = tipElement.getAttribute("title");
XLinkTitleText = tipElement.getAttributeNS(XLinkNS, "title");
+ if (tipElement instanceof SVGElement) {
+ let length = tipElement.childNodes.length;
+ for (let i = 0; i < length; i++) {
+ let childNode = tipElement.childNodes[i];
+ if (childNode instanceof SVGTitleElement) {
+ SVGTitleText = childNode.textContent;
+ break;
+ }
+ }
+ }
var defView = tipElement.ownerDocument.defaultView;
// XXX Work around bug 350679:
// "Tooltips can be fired in documents with no view".
@@ -2656,7 +2667,7 @@ function FillInHTMLTooltip(tipElement)
var tipNode = document.getElementById("aHTMLTooltip");
tipNode.style.direction = direction;
- [titleText, XLinkTitleText].forEach(function (t) {
+ [titleText, XLinkTitleText, SVGTitleText].forEach(function (t) {
if (t && /\S/.test(t)) {
// Per HTML 4.01 6.2 (CDATA section), literal CRs and tabs should be
diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in
index b0ed227eef61..8511bf5b3e66 100644
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -85,6 +85,8 @@ _BROWSER_FILES = \
browser_alltabslistener.js \
browser_bug304198.js \
browser_bug321000.js \
+ title_test.svg \
+ browser_bug329212.js \
browser_bug356571.js \
browser_bug386835.js \
browser_bug405137.js \
diff --git a/browser/base/content/test/browser_bug329212.js b/browser/base/content/test/browser_bug329212.js
new file mode 100644
index 000000000000..1bfede8baa4f
--- /dev/null
+++ b/browser/base/content/test/browser_bug329212.js
@@ -0,0 +1,36 @@
+function test () {
+ waitForExplicitFinish();
+ gBrowser.selectedTab = gBrowser.addTab();
+ gBrowser.selectedBrowser.addEventListener("load", function () {
+ gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
+
+ let doc = gBrowser.contentDocument;
+ let tooltip = document.getElementById("aHTMLTooltip");
+ ok(FillInHTMLTooltip(doc.getElementById("text1"), "should get title"));
+ is(tooltip.getAttribute("label"), " This is a title ");
+
+ ok(!FillInHTMLTooltip(doc.getElementById("text2"), "should not get title"));
+
+ ok(!FillInHTMLTooltip(doc.getElementById("text3"), "should not get title"));
+
+ ok(FillInHTMLTooltip(doc.getElementById("link1"), "should get title"));
+ is(tooltip.getAttribute("label"), " This is a title ");
+ ok(FillInHTMLTooltip(doc.getElementById("text4"), "should get title"));
+ is(tooltip.getAttribute("label"), " This is a title ");
+
+ ok(!FillInHTMLTooltip(doc.getElementById("link2"), "should not get title"));
+
+ ok(FillInHTMLTooltip(doc.getElementById("link3"), "should get title"));
+ ok(tooltip.getAttribute("label") != "");
+
+ ok(FillInHTMLTooltip(doc.getElementById("link4"), "should get title"));
+ is(tooltip.getAttribute("label"), "This is an xlink:title attribute");
+
+ gBrowser.removeCurrentTab();
+ finish();
+ }, true);
+
+ content.location =
+ "http://localhost:8888/browser/browser/base/content/test/title_test.svg";
+}
+
diff --git a/browser/base/content/test/title_test.svg b/browser/base/content/test/title_test.svg
new file mode 100644
index 000000000000..ad7193facbcf
--- /dev/null
+++ b/browser/base/content/test/title_test.svg
@@ -0,0 +1,45 @@
+
diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
index 2bcf5380caa8..cd2dadf4ba2b 100644
--- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
@@ -68,6 +68,10 @@
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMElement.h"
+#ifdef MOZ_SVG
+#include "nsIDOMSVGElement.h"
+#include "nsIDOMSVGTitleElement.h"
+#endif
#include "nsIDOMEvent.h"
#include "nsIDOMMouseEvent.h"
#include "nsIDOMNSUIEvent.h"
@@ -1010,6 +1014,29 @@ DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText,
currElement->GetAttributeNS(NS_LITERAL_STRING("http://www.w3.org/1999/xlink"), NS_LITERAL_STRING("title"), outText);
if ( outText.Length() )
found = PR_TRUE;
+#ifdef MOZ_SVG
+ else {
+ nsCOMPtr svgContent(do_QueryInterface(currElement));
+ if (svgContent) {
+ nsCOMPtrchildNodes;
+ aNode->GetChildNodes(getter_AddRefs(childNodes));
+ PRUint32 childNodeCount;
+ childNodes->GetLength(&childNodeCount);
+ for (PRUint32 i = 0; i < childNodeCount; i++) {
+ nsCOMPtrchildNode;
+ childNodes->Item(i, getter_AddRefs(childNode));
+ nsCOMPtr titleElement(do_QueryInterface(childNode));
+ if (titleElement) {
+ nsCOMPtr titleContent(do_QueryInterface(titleElement));
+ titleContent->GetTextContent(outText);
+ if ( outText.Length() )
+ found = PR_TRUE;
+ break;
+ }
+ }
+ }
+ }
+#endif
}
}
}