1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/plugins/browser_bug787619.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); 1.5 + 1.6 +let gTestBrowser = null; 1.7 +let gWrapperClickCount = 0; 1.8 + 1.9 +function test() { 1.10 + waitForExplicitFinish(); 1.11 + registerCleanupFunction(function() { 1.12 + Services.prefs.clearUserPref("plugins.click_to_play"); 1.13 + }); 1.14 + Services.prefs.setBoolPref("plugins.click_to_play", true); 1.15 + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); 1.16 + 1.17 + gBrowser.selectedTab = gBrowser.addTab(); 1.18 + gTestBrowser = gBrowser.selectedBrowser; 1.19 + gTestBrowser.addEventListener("load", pageLoad, true); 1.20 + gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug787619.html"; 1.21 +} 1.22 + 1.23 +function pageLoad() { 1.24 + // Due to layout being async, "PluginBindAttached" may trigger later. 1.25 + // This forces a layout flush, thus triggering it, and schedules the 1.26 + // test so it is definitely executed afterwards. 1.27 + gTestBrowser.contentDocument.getElementById('plugin').clientTop; 1.28 + executeSoon(part1); 1.29 +} 1.30 + 1.31 +function part1() { 1.32 + let wrapper = gTestBrowser.contentDocument.getElementById('wrapper'); 1.33 + wrapper.addEventListener('click', function() ++gWrapperClickCount, false); 1.34 + 1.35 + let plugin = gTestBrowser.contentDocument.getElementById('plugin'); 1.36 + ok(plugin, 'got plugin element'); 1.37 + ok(!plugin.activated, 'plugin should not be activated'); 1.38 + ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Doorhanger should not be open"); 1.39 + 1.40 + EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow); 1.41 + let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; 1.42 + waitForCondition(condition, part2, 1.43 + 'waited too long for plugin to activate'); 1.44 +} 1.45 + 1.46 +function part2() { 1.47 + is(gWrapperClickCount, 0, 'wrapper should not have received any clicks'); 1.48 + gTestBrowser.removeEventListener("load", pageLoad, true); 1.49 + gBrowser.removeCurrentTab(); 1.50 + window.focus(); 1.51 + finish(); 1.52 +}