Bug 331772 - tooltiptext fails on XUL button in HTML page. r=enndeakin

This commit is contained in:
Magnus Melin 2013-12-18 22:44:34 +02:00
Родитель 158997fd52
Коммит 9d9fa3edc8
4 изменённых файлов: 52 добавлений и 6 удалений

Просмотреть файл

@ -100,6 +100,7 @@ support-files =
test_no_mcb_on_http_site_font.css
test_no_mcb_on_http_site_font2.html
test_no_mcb_on_http_site_font2.css
xul_tooltiptext.xhtml
[browser_CTP_context_menu.js]
skip-if = toolkit == "gtk2" || toolkit == "gtk3" # browser_CTP_context_menu.js fails intermittently on Linux (bug 909342)
@ -129,6 +130,7 @@ skip-if = toolkit == "windows" # Disabled on Windows due to frequent failures (b
[browser_bug321000.js]
skip-if = true # browser_bug321000.js is disabled because newline handling is shaky (bug 592528)
[browser_bug329212.js]
[browser_bug331772_xul_tooltiptext_in_html.js]
[browser_bug356571.js]
[browser_bug380960.js]
[browser_bug386835.js]

Просмотреть файл

@ -0,0 +1,23 @@
/**
* Tests that the tooltiptext attribute is used for XUL elements in an HTML doc.
*/
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(tooltip.fillInPageTooltip(doc.getElementById("xulToolbarButton")), "should get tooltiptext");
is(tooltip.getAttribute("label"), "XUL tooltiptext");
gBrowser.removeCurrentTab();
finish();
}, true);
content.location =
"http://mochi.test:8888/browser/browser/base/content/test/general/xul_tooltiptext.xhtml";
}

Просмотреть файл

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<xul:toolbox xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<toolbar>
<toolbarbutton id="xulToolbarButton"
tooltiptext="XUL tooltiptext"
title="XUL title"/>
</toolbar>
</xul:toolbox>
</html>

Просмотреть файл

@ -517,6 +517,7 @@
var titleText = null;
var XLinkTitleText = null;
var SVGTitleText = null;
var XULtooltiptextText = null;
var lookingForSVGTitle = true;
var direction = tipElement.ownerDocument.dir;
@ -575,11 +576,17 @@
} catch(e) {}
}
while ((titleText == null) && (XLinkTitleText == null) &&
(SVGTitleText == null) && tipElement) {
if (tipElement.nodeType == Node.ELEMENT_NODE &&
tipElement.namespaceURI != XULNS) {
titleText = tipElement.getAttribute("title");
// Check texts against null so that title="" can be used to undefine a
// title on a child element.
while (tipElement &&
(titleText == null) && (XLinkTitleText == null) &&
(SVGTitleText == null) && (XULtooltiptextText == null)) {
if (tipElement.nodeType == Node.ELEMENT_NODE) {
if (tipElement.namespaceURI == XULNS)
XULtooltiptextText = tipElement.getAttribute("tooltiptext");
else
titleText = tipElement.getAttribute("title");
if ((tipElement instanceof HTMLAnchorElement ||
tipElement instanceof HTMLAreaElement ||
@ -610,7 +617,7 @@
this.style.direction = direction;
return [titleText, XLinkTitleText, SVGTitleText].some(function (t) {
return [titleText, XLinkTitleText, SVGTitleText, XULtooltiptextText].some(function (t) {
if (t && /\S/.test(t)) {
// Make CRLF and CR render one line break each.
this.label = t.replace(/\r\n?/g, '\n');