summaryrefslogtreecommitdiffstats
path: root/toolkit/components/tooltiptext/tests
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/tooltiptext/tests
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/tooltiptext/tests')
-rw-r--r--toolkit/components/tooltiptext/tests/browser.ini7
-rw-r--r--toolkit/components/tooltiptext/tests/browser_bug329212.js35
-rw-r--r--toolkit/components/tooltiptext/tests/browser_bug331772_xul_tooltiptext_in_html.js19
-rw-r--r--toolkit/components/tooltiptext/tests/browser_bug561623.js24
-rw-r--r--toolkit/components/tooltiptext/tests/browser_bug581947.js87
-rw-r--r--toolkit/components/tooltiptext/tests/browser_input_file_tooltips.js122
-rw-r--r--toolkit/components/tooltiptext/tests/title_test.svg59
-rw-r--r--toolkit/components/tooltiptext/tests/xul_tooltiptext.xhtml14
8 files changed, 367 insertions, 0 deletions
diff --git a/toolkit/components/tooltiptext/tests/browser.ini b/toolkit/components/tooltiptext/tests/browser.ini
new file mode 100644
index 000000000..9896fcd2c
--- /dev/null
+++ b/toolkit/components/tooltiptext/tests/browser.ini
@@ -0,0 +1,7 @@
+[browser_bug329212.js]
+support-files = title_test.svg
+[browser_bug331772_xul_tooltiptext_in_html.js]
+support-files = xul_tooltiptext.xhtml
+[browser_bug561623.js]
+[browser_bug581947.js]
+[browser_input_file_tooltips.js]
diff --git a/toolkit/components/tooltiptext/tests/browser_bug329212.js b/toolkit/components/tooltiptext/tests/browser_bug329212.js
new file mode 100644
index 000000000..b3434eff6
--- /dev/null
+++ b/toolkit/components/tooltiptext/tests/browser_bug329212.js
@@ -0,0 +1,35 @@
+"use strict";
+
+add_task(function*() {
+ yield BrowserTestUtils.withNewTab({
+ gBrowser,
+ url: "http://mochi.test:8888/browser/toolkit/components/tooltiptext/tests/title_test.svg",
+ }, function*(browser) {
+ yield ContentTask.spawn(browser, "", function() {
+ let tttp = Cc["@mozilla.org/embedcomp/default-tooltiptextprovider;1"]
+ .getService(Ci.nsITooltipTextProvider);
+ function checkElement(id, expectedTooltipText) {
+ let el = content.document.getElementById(id);
+ let textObj = {};
+ let shouldHaveTooltip = expectedTooltipText !== null;
+ is(tttp.getNodeText(el, textObj, {}), shouldHaveTooltip,
+ "element " + id + " should " + (shouldHaveTooltip ? "" : "not ") + "have a tooltip");
+ if (shouldHaveTooltip) {
+ is(textObj.value, expectedTooltipText,
+ "element " + id + " should have the right tooltip text");
+ }
+ }
+ checkElement("svg1", "This is a non-root SVG element title");
+ checkElement("text1", "\n\n\n This is a title\n\n ");
+ checkElement("text2", null);
+ checkElement("text3", null);
+ checkElement("link1", "\n This is a title\n ");
+ checkElement("text4", "\n This is a title\n ");
+ checkElement("link2", null);
+ checkElement("link3", "This is an xlink:title attribute");
+ checkElement("link4", "This is an xlink:title attribute");
+ checkElement("text5", null);
+ });
+ });
+});
+
diff --git a/toolkit/components/tooltiptext/tests/browser_bug331772_xul_tooltiptext_in_html.js b/toolkit/components/tooltiptext/tests/browser_bug331772_xul_tooltiptext_in_html.js
new file mode 100644
index 000000000..23d8c4a6e
--- /dev/null
+++ b/toolkit/components/tooltiptext/tests/browser_bug331772_xul_tooltiptext_in_html.js
@@ -0,0 +1,19 @@
+/**
+ * Tests that the tooltiptext attribute is used for XUL elements in an HTML doc.
+ */
+add_task(function*() {
+ yield BrowserTestUtils.withNewTab({
+ gBrowser,
+ url: "http://mochi.test:8888/browser/toolkit/components/tooltiptext/tests/xul_tooltiptext.xhtml",
+ }, function*(browser) {
+ yield ContentTask.spawn(browser, "", function() {
+ let textObj = {};
+ let tttp = Cc["@mozilla.org/embedcomp/default-tooltiptextprovider;1"]
+ .getService(Ci.nsITooltipTextProvider);
+ let xulToolbarButton = content.document.getElementById("xulToolbarButton");
+ ok(tttp.getNodeText(xulToolbarButton, textObj, {}), "should get tooltiptext");
+ is(textObj.value, "XUL tooltiptext");
+ });
+ });
+});
+
diff --git a/toolkit/components/tooltiptext/tests/browser_bug561623.js b/toolkit/components/tooltiptext/tests/browser_bug561623.js
new file mode 100644
index 000000000..49c51c4ba
--- /dev/null
+++ b/toolkit/components/tooltiptext/tests/browser_bug561623.js
@@ -0,0 +1,24 @@
+add_task(function*() {
+ yield BrowserTestUtils.withNewTab({
+ gBrowser,
+ url: "data:text/html,<!DOCTYPE html><html><body><input id='i'></body></html>",
+ }, function*(browser) {
+ yield ContentTask.spawn(browser, "", function() {
+ let tttp = Cc["@mozilla.org/embedcomp/default-tooltiptextprovider;1"]
+ .getService(Ci.nsITooltipTextProvider);
+ let i = content.document.getElementById("i");
+
+ ok(!tttp.getNodeText(i, {}, {}),
+ "No tooltip should be shown when @title is null");
+
+ i.title = "foo";
+ ok(tttp.getNodeText(i, {}, {}),
+ "A tooltip should be shown when @title is not the empty string");
+
+ i.pattern = "bar";
+ ok(tttp.getNodeText(i, {}, {}),
+ "A tooltip should be shown when @title is not the empty string");
+ });
+ });
+});
+
diff --git a/toolkit/components/tooltiptext/tests/browser_bug581947.js b/toolkit/components/tooltiptext/tests/browser_bug581947.js
new file mode 100644
index 000000000..034e0a4d1
--- /dev/null
+++ b/toolkit/components/tooltiptext/tests/browser_bug581947.js
@@ -0,0 +1,87 @@
+function check(aBrowser, aElementName, aBarred, aType) {
+ return ContentTask.spawn(aBrowser, [aElementName, aBarred, aType], function*([aElementName, aBarred, aType]) {
+ let e = content.document.createElement(aElementName);
+ let contentElement = content.document.getElementById('content');
+ contentElement.appendChild(e);
+
+ if (aType) {
+ e.type = aType;
+ }
+
+ let tttp = Cc["@mozilla.org/embedcomp/default-tooltiptextprovider;1"]
+ .getService(Ci.nsITooltipTextProvider);
+ ok(!tttp.getNodeText(e, {}, {}),
+ "No tooltip should be shown when the element is valid");
+
+ e.setCustomValidity('foo');
+ if (aBarred) {
+ ok(!tttp.getNodeText(e, {}, {}),
+ "No tooltip should be shown when the element is barred from constraint validation");
+ } else {
+ ok(tttp.getNodeText(e, {}, {}),
+ e.tagName + " " +"A tooltip should be shown when the element isn't valid");
+ }
+
+ e.setAttribute('title', '');
+ ok (!tttp.getNodeText(e, {}, {}),
+ "No tooltip should be shown if the title attribute is set");
+
+ e.removeAttribute('title');
+ contentElement.setAttribute('novalidate', '');
+ ok (!tttp.getNodeText(e, {}, {}),
+ "No tooltip should be shown if the novalidate attribute is set on the form owner");
+ contentElement.removeAttribute('novalidate');
+
+ e.remove();
+ });
+}
+
+function todo_check(aBrowser, aElementName, aBarred) {
+ return ContentTask.spawn(aBrowser, [aElementName, aBarred], function*([aElementName, aBarred]) {
+ let e = content.document.createElement(aElementName);
+ let contentElement = content.document.getElementById('content');
+ contentElement.appendChild(e);
+
+ let caught = false;
+ try {
+ e.setCustomValidity('foo');
+ } catch (e) {
+ caught = true;
+ }
+
+ todo(!caught, "setCustomValidity should exist for " + aElementName);
+
+ e.remove();
+ });
+}
+
+add_task(function*() {
+ yield BrowserTestUtils.withNewTab({
+ gBrowser,
+ url: "data:text/html,<!DOCTYPE html><html><body><form id='content'></form></body></html>",
+ }, function*(browser) {
+ let testData = [
+ /* element name, barred */
+ [ 'input', false, null],
+ [ 'textarea', false, null],
+ [ 'button', true, 'button'],
+ [ 'button', false, 'submit'],
+ [ 'select', false, null],
+ [ 'output', true, null],
+ [ 'fieldset', true, null],
+ [ 'object', true, null],
+ ];
+
+ for (let data of testData) {
+ yield check(browser, data[0], data[1], data[2]);
+ }
+
+ let todo_testData = [
+ [ 'keygen', 'false' ],
+ ];
+
+ for (let data of todo_testData) {
+ yield todo_check(browser, data[0], data[1]);
+ }
+ });
+});
diff --git a/toolkit/components/tooltiptext/tests/browser_input_file_tooltips.js b/toolkit/components/tooltiptext/tests/browser_input_file_tooltips.js
new file mode 100644
index 000000000..a1323095d
--- /dev/null
+++ b/toolkit/components/tooltiptext/tests/browser_input_file_tooltips.js
@@ -0,0 +1,122 @@
+
+let tempFile;
+add_task(function* setup() {
+ yield new Promise(resolve => {
+ SpecialPowers.pushPrefEnv({"set": [["ui.tooltipDelay", 0]]}, resolve);
+ });
+ tempFile = createTempFile();
+ registerCleanupFunction(function() {
+ tempFile.remove(true);
+ });
+});
+
+add_task(function* test_singlefile_selected() {
+ yield do_test({value: true, result: "testfile_bug1251809"});
+});
+
+add_task(function* test_title_set() {
+ yield do_test({title: "foo", result: "foo"});
+});
+
+add_task(function* test_nofile_selected() {
+ yield do_test({result: "No file selected."});
+});
+
+add_task(function* test_multipleset_nofile_selected() {
+ yield do_test({multiple: true, result: "No files selected."});
+});
+
+add_task(function* test_requiredset() {
+ yield do_test({required: true, result: "Please select a file."});
+});
+
+function* do_test(test) {
+ info(`starting test ${JSON.stringify(test)}`);
+
+ let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser);
+
+ info("Moving mouse out of the way.");
+ yield new Promise(resolve => {
+ EventUtils.synthesizeNativeMouseMove(tab.linkedBrowser, 300, 300, resolve);
+ });
+
+ info("creating input field");
+ yield ContentTask.spawn(tab.linkedBrowser, test, function*(test) {
+ let doc = content.document;
+ let input = doc.createElement("input");
+ doc.body.appendChild(input);
+ input.id = "test_input";
+ input.setAttribute("style", "position: absolute; top: 0; left: 0;");
+ input.type = "file";
+ if (test.title) {
+ input.setAttribute("title", test.title);
+ }
+ if (test.multiple) {
+ input.multiple = true;
+ }
+ if (test.required) {
+ input.required = true;
+ }
+ });
+
+ if (test.value) {
+ info("Creating mock filepicker to select files");
+ let MockFilePicker = SpecialPowers.MockFilePicker;
+ MockFilePicker.init(window);
+ MockFilePicker.returnValue = MockFilePicker.returnOK;
+ MockFilePicker.displayDirectory = FileUtils.getDir("TmpD", [], false);
+ MockFilePicker.returnFiles = [tempFile];
+
+ try {
+ // Open the File Picker dialog (MockFilePicker) to select
+ // the files for the test.
+ yield BrowserTestUtils.synthesizeMouseAtCenter("#test_input", {}, tab.linkedBrowser);
+ info("Waiting for the input to have the requisite files");
+ yield ContentTask.spawn(tab.linkedBrowser, {}, function*() {
+ let input = content.document.querySelector("#test_input");
+ yield ContentTaskUtils.waitForCondition(() => input.files.length,
+ "The input should have at least one file selected");
+ info(`The input has ${input.files.length} file(s) selected.`);
+ });
+ } finally {
+ MockFilePicker.cleanup();
+ }
+ } else {
+ info("No real file selection required.");
+ }
+
+ let awaitTooltipOpen = new Promise(resolve => {
+ let tooltipId = Services.appinfo.browserTabsRemoteAutostart ?
+ "remoteBrowserTooltip" :
+ "aHTMLTooltip";
+ let tooltip = document.getElementById(tooltipId);
+ tooltip.addEventListener("popupshown", function onpopupshown(event) {
+ tooltip.removeEventListener("popupshown", onpopupshown);
+ resolve(event.target);
+ });
+ });
+ info("Initial mouse move");
+ yield new Promise(resolve => {
+ EventUtils.synthesizeNativeMouseMove(tab.linkedBrowser, 50, 5, resolve);
+ });
+ info("Waiting");
+ yield new Promise(resolve => setTimeout(resolve, 400));
+ info("Second mouse move");
+ yield new Promise(resolve => {
+ EventUtils.synthesizeNativeMouseMove(tab.linkedBrowser, 70, 5, resolve);
+ });
+ info("Waiting for tooltip to open");
+ let tooltip = yield awaitTooltipOpen;
+
+ is(tooltip.getAttribute("label"), test.result, "tooltip label should match expectation");
+
+ info("Closing tab");
+ yield BrowserTestUtils.removeTab(tab);
+}
+
+function createTempFile() {
+ let file = FileUtils.getDir("TmpD", [], false);
+ file.append("testfile_bug1251809");
+ file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
+ return file;
+}
diff --git a/toolkit/components/tooltiptext/tests/title_test.svg b/toolkit/components/tooltiptext/tests/title_test.svg
new file mode 100644
index 000000000..7638fd5cc
--- /dev/null
+++ b/toolkit/components/tooltiptext/tests/title_test.svg
@@ -0,0 +1,59 @@
+<svg width="640px" height="480px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <title>This is a root SVG element's title</title>
+ <foreignObject>
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <body>
+ <svg xmlns="http://www.w3.org/2000/svg" id="svg1">
+ <title>This is a non-root SVG element title</title>
+ </svg>
+ </body>
+ </html>
+ </foreignObject>
+ <text id="text1" x="10px" y="32px" font-size="24px">
+ This contains only &lt;title&gt;
+ <title>
+
+
+ This is a title
+
+ </title>
+ </text>
+ <text id="text2" x="10px" y="96px" font-size="24px">
+ This contains only &lt;desc&gt;
+ <desc>This is a desc</desc>
+ </text>
+ <text id="text3" x="10px" y="128px" font-size="24px" title="ignored for SVG">
+ This contains nothing.
+ </text>
+ <a id="link1" xlink:href="#">
+ This link contains &lt;title&gt;
+ <title>
+ This is a title
+ </title>
+ <text id="text4" x="10px" y="192px" font-size="24px">
+ </text>
+ </a>
+ <a id="link2" xlink:href="#">
+ <text x="10px" y="192px" font-size="24px">
+ This text contains &lt;title&gt;
+ <title>
+ This is a title
+ </title>
+ </text>
+ </a>
+ <a id="link3" xlink:href="#" xlink:title="This is an xlink:title attribute">
+ <text x="10px" y="224px" font-size="24px">
+ This link contains &lt;title&gt; &amp; xlink:title attr.
+ <title>This is a title</title>
+ </text>
+ </a>
+ <a id="link4" xlink:href="#" xlink:title="This is an xlink:title attribute">
+ <text x="10px" y="256px" font-size="24px">
+ This link contains xlink:title attr.
+ </text>
+ </a>
+ <text id="text5" x="10px" y="160px" font-size="24px"
+ xlink:title="This is an xlink:title attribute but it isn't on a link" >
+ This contains nothing.
+ </text>
+</svg>
diff --git a/toolkit/components/tooltiptext/tests/xul_tooltiptext.xhtml b/toolkit/components/tooltiptext/tests/xul_tooltiptext.xhtml
new file mode 100644
index 000000000..4a80864dd
--- /dev/null
+++ b/toolkit/components/tooltiptext/tests/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>
+
+