Bug 561733 - Mouse click event in iframe doesn't fire (tests) [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Wed, 28 Apr 2010 09:47:58 -0400
changeset 66179 8ba0a12654483aecc434ff55895e18205365f524
parent 66178 81a07876476dad610d92bb2e348ac47e1b7b4e4d
child 66180 c9c9dba79ef23e8e237a702e6b28717f0dd702c5
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs561733
Bug 561733 - Mouse click event in iframe doesn't fire (tests) [r=mfinkle]
mobile/chrome/tests/Makefile.in
mobile/chrome/tests/browser_click_content.html
mobile/chrome/tests/browser_click_content.js
--- a/mobile/chrome/tests/Makefile.in
+++ b/mobile/chrome/tests/Makefile.in
@@ -48,21 +48,23 @@ include $(topsrcdir)/config/rules.mk
   head.js \
   browser_mainui.js \
   browser_tabs.js \
   browser_bookmarks.js \
   browser_bookmarks_star.js \
   browser_bookmarks_tags.js \
   browser_select.js \
   browser_rect.js \
+  browser_click_content.js \
   browser_FormAssistant.js \
   browser_viewport.js \
   browser_blank_01.html \
   browser_blank_02.html \
   browser_select.html \
+  browser_click_content.html \
   browser_FormAssistant.html \
   browser_viewport_00.html \
   browser_viewport_01.html \
   browser_viewport_02.html \
   browser_viewport_03.html \
   browser_viewport_04.html \
   browser_viewport_05.html \
   browser_viewport_06.html \
new file mode 100644
--- /dev/null
+++ b/mobile/chrome/tests/browser_click_content.html
@@ -0,0 +1,6 @@
+<html>
+<title>Browser Click Page 01</title>
+<body>
+<iframe src="data:,test test" width="100" height="100"><iframe>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/mobile/chrome/tests/browser_click_content.js
@@ -0,0 +1,51 @@
+let testURL_click = "chrome://mochikit/content/browser/mobile/chrome/browser_click_content.html";
+
+let newTab;
+let element;
+let isClickFired = false;
+
+//------------------------------------------------------------------------------
+// Entry point (must be named "test")
+function test() {
+  // This test is async
+  waitForExplicitFinish();
+
+  // Add new tab
+  newTab = Browser.addTab(testURL_click, true);
+  ok(newTab, "Tab Opened");
+
+  // Wait for tab load (need to check the tab "loading", not the document "loading")
+  waitFor(testClick, function() { return newTab.isLoading() == false; });
+}
+
+function clickFired() {
+  isClickFired = true;
+}
+
+function testClick() {
+  // Do sanity tests
+  let uri = newTab.browser.currentURI.spec;
+  is(uri, testURL_click, "URL Matches newly created Tab");
+
+  // Check click
+  element = newTab.browser.contentDocument.querySelector("iframe");
+  element.addEventListener("click", clickFired, true);
+  EventUtils.synthesizeMouseForContent(element, 1, 1, {}, window);
+  waitFor(checkClick, function() { return isClickFired });
+}
+
+function checkClick() {
+  ok(isClickFired, "Click handler fired");
+  close();
+}
+
+function close() {
+  // Close the tab
+  Browser.closeTab(newTab);
+
+  // Remove the listener
+  element.removeEventListener("click", clickFired, true);
+
+  // We must finialize the tests
+  finish();
+}