[Pkg-mozext-commits] [firebug] 04/82: FBTest: API for testing tooltips
David Prévot
taffit at moszumanska.debian.org
Mon Mar 31 22:45:35 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag fbtest-1.11.2
in repository firebug.
commit f440ea1f0e62828f67ed0eadf85e0015958dacb4
Author: Jan Odvarko <odvarko at gmail.com>
Date: Wed Dec 5 13:43:47 2012 +0100
FBTest: API for testing tooltips
---
tests/FBTest/content/FBTestFirebug.js | 45 +++++++++++++++++++++++++++++++++++
tests/FBTest/content/FBTestTooltip.js | 42 ++++++++++++++++++++++++++++++++
tests/FBTest/content/wrapAJSFile.html | 1 +
tests/FBTest/modules/EventUtils.js | 4 ++--
4 files changed, 90 insertions(+), 2 deletions(-)
diff --git a/tests/FBTest/content/FBTestFirebug.js b/tests/FBTest/content/FBTestFirebug.js
index d9598e1..af42227 100644
--- a/tests/FBTest/content/FBTestFirebug.js
+++ b/tests/FBTest/content/FBTestFirebug.js
@@ -297,6 +297,14 @@ this.mouseOver = function(node, offsetX, offsetY)
this.synthesizeMouse(node, offsetX, offsetY, eventDetails, win);
};
+this.mouseMove = function(node, offsetX, offsetY)
+{
+ var win = node.ownerDocument.defaultView;
+
+ var eventDetails = {type: "mousemove"};
+ this.synthesizeMouse(node, offsetX, offsetY, eventDetails, win);
+};
+
this.sendMouseEvent = function(event, target, win)
{
if (!target)
@@ -2775,6 +2783,43 @@ this.getDOMPropertyRow = function(chrome, propName)
};
// ********************************************************************************************* //
+// Tooltips
+
+this.showTooltip = function(target, callback)
+{
+ function onTooltipShowing(event)
+ {
+ TooltipController.removeListener(onTooltipShowing);
+
+ callback(event.target);
+ }
+
+ // Tooltip controller ensures clean up (listners removal) in cases
+ // when the tooltip is never shown and so, the listener not removed.
+ TooltipController.addListener(onTooltipShowing);
+
+ var win = target.ownerDocument.defaultView;
+
+ try
+ {
+ disableNonTestMouseEvents(win, true);
+
+ this.synthesizeMouse(target, 2, 2, {type: "mouseover"});
+ this.synthesizeMouse(target, 4, 4, {type: "mousemove"});
+ this.synthesizeMouse(target, 6, 6, {type: "mousemove"});
+ }
+ catch (e)
+ {
+ if (FBTrace.DBG_ERRORS)
+ FBTrace.sysout("EXCEPTION " + e, e);
+ }
+ finally
+ {
+ disableNonTestMouseEvents(win, false);
+ }
+}
+
+// ********************************************************************************************* //
// Module Loader
this.getRequire = function()
diff --git a/tests/FBTest/content/FBTestTooltip.js b/tests/FBTest/content/FBTestTooltip.js
new file mode 100644
index 0000000..2ad5043
--- /dev/null
+++ b/tests/FBTest/content/FBTestTooltip.js
@@ -0,0 +1,42 @@
+/* See license.txt for terms of usage */
+
+// ********************************************************************************************* //
+// Tooltip Controller
+
+/**
+ * The object is responsible for registering 'popupshowing' listeners and safe clean up.
+ * The clean up is important since it must happen even if the test doesn't fisnish.
+ */
+var TooltipController =
+{
+ listeners: [],
+
+ addListener: function(listener)
+ {
+ var tooltip = FW.Firebug.chrome.$("fbTooltip");
+ tooltip.addEventListener("popupshowing", listener, false);
+ this.listeners.push(listener);
+ },
+
+ removeListener: function(listener)
+ {
+ var tooltip = FW.Firebug.chrome.$("fbTooltip");
+ tooltip.removeEventListener("popupshowing", listener, false);
+ FW.FBL.remove(this.listeners, listener);
+ },
+
+ cleanUp: function()
+ {
+ // Remove all listeners registered by the current test.
+ while (this.listeners.length)
+ this.removeListener(this.listeners[0]);
+ }
+};
+
+// ********************************************************************************************* //
+// Clean up
+
+window.addEventListener("unload", function testSelectionUnload()
+{
+ TooltipController.cleanUp();
+}, true);
diff --git a/tests/FBTest/content/wrapAJSFile.html b/tests/FBTest/content/wrapAJSFile.html
index 5ba8b97..128deda 100644
--- a/tests/FBTest/content/wrapAJSFile.html
+++ b/tests/FBTest/content/wrapAJSFile.html
@@ -4,6 +4,7 @@
<script type="application/x-javascript" src="chrome://fbtest/content/FBTestFirebug.js"></script>
<script type="application/x-javascript" src="chrome://fbtest/content/FBTestMutation.js"></script>
<script type="application/x-javascript" src="chrome://fbtest/content/FBTestSelection.js"></script>
+<script type="application/x-javascript" src="chrome://fbtest/content/FBTestTooltip.js"></script>
<script type="application/x-javascript" src="chrome://fbtest/content/FBTestCookies.js"></script>
<script type="application/x-javascript" src="chrome://fbtest/content/jsdiff.js"></script>
<script type="application/x-javascript">
diff --git a/tests/FBTest/modules/EventUtils.js b/tests/FBTest/modules/EventUtils.js
index 6c58fa2..c4496b6 100644
--- a/tests/FBTest/modules/EventUtils.js
+++ b/tests/FBTest/modules/EventUtils.js
@@ -575,10 +575,10 @@ function synthesizeDrop(srcElement, destElement, dragData, dropEffect, aWindow)
return dataTransfer.dropEffect;
}
-function disableNonTestMouseEvents(aDisable)
+function disableNonTestMouseEvents(aWindow, aDisable)
{
var utils =
- window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
+ aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
if (utils)
utils.disableNonTestMouseEvents(aDisable);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git
More information about the Pkg-mozext-commits
mailing list