michael@0: const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); michael@0: michael@0: let gTestBrowser = null; michael@0: let gWrapperClickCount = 0; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: registerCleanupFunction(function() { michael@0: Services.prefs.clearUserPref("plugins.click_to_play"); michael@0: }); michael@0: Services.prefs.setBoolPref("plugins.click_to_play", true); michael@0: setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gTestBrowser = gBrowser.selectedBrowser; michael@0: gTestBrowser.addEventListener("load", pageLoad, true); michael@0: gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug787619.html"; michael@0: } michael@0: michael@0: function pageLoad() { michael@0: // Due to layout being async, "PluginBindAttached" may trigger later. michael@0: // This forces a layout flush, thus triggering it, and schedules the michael@0: // test so it is definitely executed afterwards. michael@0: gTestBrowser.contentDocument.getElementById('plugin').clientTop; michael@0: executeSoon(part1); michael@0: } michael@0: michael@0: function part1() { michael@0: let wrapper = gTestBrowser.contentDocument.getElementById('wrapper'); michael@0: wrapper.addEventListener('click', function() ++gWrapperClickCount, false); michael@0: michael@0: let plugin = gTestBrowser.contentDocument.getElementById('plugin'); michael@0: ok(plugin, 'got plugin element'); michael@0: ok(!plugin.activated, 'plugin should not be activated'); michael@0: ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Doorhanger should not be open"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow); michael@0: let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; michael@0: waitForCondition(condition, part2, michael@0: 'waited too long for plugin to activate'); michael@0: } michael@0: michael@0: function part2() { michael@0: is(gWrapperClickCount, 0, 'wrapper should not have received any clicks'); michael@0: gTestBrowser.removeEventListener("load", pageLoad, true); michael@0: gBrowser.removeCurrentTab(); michael@0: window.focus(); michael@0: finish(); michael@0: }