Bug 787619 - Test that click events on the C2P overlay don't trigger other handlers. r=jaws
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Fri, 19 Oct 2012 15:21:19 +0200
changeset 111002 404557eb178698a43e82c9f04e244258c255e61b
parent 111001 3d23e8d2f87a59f5b344ebd0447b8b5b69fffec6
child 111003 5d03feda23009d5a79a1ed880a6ff20af57dbf2b
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersjaws
bugs787619
milestone19.0a1
Bug 787619 - Test that click events on the C2P overlay don't trigger other handlers. r=jaws
browser/base/content/test/Makefile.in
browser/base/content/test/test_bug787619.html
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -10,16 +10,17 @@ relativesrcdir  = @relativesrcdir@
 
 DIRS += \
 		newtab \
 		$(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_FILES = \
+		head.js \
 		test_feed_discovery.html \
 		feed_discovery.html \
 		test_bug395533.html \
 		bug395533-data.txt \
 		ctxmenu-image.png \
 		video.ogg \
 		test_offlineNotification.html \
 		offlineChild.html \
@@ -34,16 +35,17 @@ MOCHITEST_FILES = \
 		test_bug364677.html \
 		bug364677-data.xml \
 		bug364677-data.xml^headers^ \
 		test_offline_gzip.html \
 		gZipOfflineChild.html \
 		gZipOfflineChild.html^headers^ \
 		gZipOfflineChild.cacheManifest \
 		gZipOfflineChild.cacheManifest^headers^ \
+		test_bug787619.html \
 		$(NULL)
 
 # test_contextmenu.html is disabled on Linux due to bug 513558
 ifneq (gtk2,$(MOZ_WIDGET_TOOLKIT))
 MOCHITEST_FILES += \
 		audio.ogg \
 		test_contextmenu.html \
 		subtst_contextmenu.html \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/test_bug787619.html
@@ -0,0 +1,46 @@
+<html>
+<head>
+  <title>Test for Bug 787619</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <script type="application/javascript;version=1.7" src="head.js"></script>
+  <script>
+    SpecialPowers.setBoolPref('plugins.click_to_play', true);
+  </script>
+</head>
+<body>
+
+  <a id="wrapper">
+    <embed id="plugin" style="width: 200px; height: 200px" type="application/x-test">
+  </a>
+
+  <script class="testbody" type="application/javascript;version=1.7">
+  SimpleTest.waitForExplicitFinish();
+
+  const Ci = Components.interfaces;
+  let wrapperClickCount = 0;
+
+  function test1() {
+    let plugin = document.getElementById('plugin');
+    ok(plugin, 'got plugin element');
+    let objLC = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
+    ok(!objLC.activated, 'plugin should not be activated');
+
+    synthesizeMouseAtCenter(plugin, {});
+    waitForCondition(function() objLC.activated, test2, 
+                     'waited too long for plugin to activate');
+  }
+
+  function test2() {
+    is(wrapperClickCount, 0, 'wrapper should not have received any clicks');
+    SpecialPowers.clearUserPref('plugins.click_to_play');
+    SimpleTest.finish();
+  }
+
+  let wrapper = document.getElementById('wrapper');
+  wrapper.addEventListener('click', function() ++wrapperClickCount, false);
+  SimpleTest.waitForFocus(test1);
+  </script>
+</body>
+</html>