Bug 703210 part.2 Add test r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 30 Nov 2011 21:44:53 +0900
changeset 81813 50e07a58ee89c233c9fbffeb7018f19e9fb0f204
parent 81812 247c27bf088895a7b8fdcb9aff8f11ae4ceacbb9
child 81814 eb1badf94821a1b79db4780a36733924c69b2b33
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs703210
milestone11.0a1
Bug 703210 part.2 Add test r=smaug
layout/xul/test/Makefile.in
layout/xul/test/browser_bug703210.js
--- a/layout/xul/test/Makefile.in
+++ b/layout/xul/test/Makefile.in
@@ -58,8 +58,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug703150.xul \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
 libs:: $(_CHROME_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
+
+ifneq (mobile,$(MOZ_BUILD_APP))
+_BROWSER_FILES = \
+		browser_bug703210.js \
+		$(NULL)
+
+libs::	$(_BROWSER_FILES)
+	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
+endif
new file mode 100644
--- /dev/null
+++ b/layout/xul/test/browser_bug703210.js
@@ -0,0 +1,65 @@
+function test() {
+  waitForExplicitFinish();
+  gBrowser.selectedTab = gBrowser.addTab();
+
+  let doStopPropagation = function (aEvent)
+  {
+    aEvent.stopPropagation();
+  }
+
+  let onPopupShowing = function (aEvent)
+  {
+    is(aEvent.originalTarget.localName, "tooltip", "tooltip is showing");
+
+    let doc = gBrowser.contentDocument;
+    let win = gBrowser.contentWindow;
+    let p2 = doc.getElementById("p2");
+    setTimeout(function () {
+      EventUtils.synthesizeMouseAtCenter(p2, { type: "mousemove" }, win); }, 0);
+  }
+
+  let onPopupHiding = function (aEvent)
+  {
+    is(aEvent.originalTarget.localName, "tooltip", "tooltip is hiding");
+
+    let doc = gBrowser.contentDocument;
+
+    doc.removeEventListener("mousemove", doStopPropagation, true);
+    doc.removeEventListener("mouseenter", doStopPropagation, true);
+    doc.removeEventListener("mouseleave", doStopPropagation, true);
+    doc.removeEventListener("mouseover", doStopPropagation, true);
+    doc.removeEventListener("mouseout", doStopPropagation, true);
+    document.removeEventListener("popupshowing", onPopupShowing, true);
+    document.removeEventListener("popuphiding", onPopupHiding, true);
+
+    gBrowser.removeCurrentTab();
+    finish();
+  }
+
+  let onLoad = function (aEvent)
+  {
+    let doc = gBrowser.contentDocument;
+    let win = gBrowser.contentWindow;
+    let p1 = doc.getElementById("p1");
+    let p2 = doc.getElementById("p2");
+
+    EventUtils.synthesizeMouseAtCenter(p2, { type: "mousemove" }, win);
+
+    doc.addEventListener("mousemove", doStopPropagation, true);
+    doc.addEventListener("mouseenter", doStopPropagation, true);
+    doc.addEventListener("mouseleave", doStopPropagation, true);
+    doc.addEventListener("mouseover", doStopPropagation, true);
+    doc.addEventListener("mouseout", doStopPropagation, true);
+    document.addEventListener("popupshown", onPopupShowing, true);
+    document.addEventListener("popuphiding", onPopupHiding, true);
+
+    EventUtils.synthesizeMouseAtCenter(p1, { type: "mousemove" }, win);
+  }
+
+  gBrowser.selectedBrowser.addEventListener("load",
+    function () { setTimeout(onLoad, 0); }, true);
+
+  content.location = "data:text/html," +
+    "<p id=\"p1\" title=\"tooltip is here\">This paragraph has a tooltip.</p>" +
+    "<p id=\"p2\">This paragraph doesn't have tooltip.</p>";
+}