|
1 const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); |
|
2 |
|
3 let gTestBrowser = null; |
|
4 let gWrapperClickCount = 0; |
|
5 |
|
6 function test() { |
|
7 waitForExplicitFinish(); |
|
8 registerCleanupFunction(function() { |
|
9 Services.prefs.clearUserPref("plugins.click_to_play"); |
|
10 }); |
|
11 Services.prefs.setBoolPref("plugins.click_to_play", true); |
|
12 setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); |
|
13 |
|
14 gBrowser.selectedTab = gBrowser.addTab(); |
|
15 gTestBrowser = gBrowser.selectedBrowser; |
|
16 gTestBrowser.addEventListener("load", pageLoad, true); |
|
17 gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug787619.html"; |
|
18 } |
|
19 |
|
20 function pageLoad() { |
|
21 // Due to layout being async, "PluginBindAttached" may trigger later. |
|
22 // This forces a layout flush, thus triggering it, and schedules the |
|
23 // test so it is definitely executed afterwards. |
|
24 gTestBrowser.contentDocument.getElementById('plugin').clientTop; |
|
25 executeSoon(part1); |
|
26 } |
|
27 |
|
28 function part1() { |
|
29 let wrapper = gTestBrowser.contentDocument.getElementById('wrapper'); |
|
30 wrapper.addEventListener('click', function() ++gWrapperClickCount, false); |
|
31 |
|
32 let plugin = gTestBrowser.contentDocument.getElementById('plugin'); |
|
33 ok(plugin, 'got plugin element'); |
|
34 ok(!plugin.activated, 'plugin should not be activated'); |
|
35 ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Doorhanger should not be open"); |
|
36 |
|
37 EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow); |
|
38 let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; |
|
39 waitForCondition(condition, part2, |
|
40 'waited too long for plugin to activate'); |
|
41 } |
|
42 |
|
43 function part2() { |
|
44 is(gWrapperClickCount, 0, 'wrapper should not have received any clicks'); |
|
45 gTestBrowser.removeEventListener("load", pageLoad, true); |
|
46 gBrowser.removeCurrentTab(); |
|
47 window.focus(); |
|
48 finish(); |
|
49 } |