Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
3 let gTestBrowser = null;
4 let gWrapperClickCount = 0;
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);
14 gBrowser.selectedTab = gBrowser.addTab();
15 gTestBrowser = gBrowser.selectedBrowser;
16 gTestBrowser.addEventListener("load", pageLoad, true);
17 gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug787619.html";
18 }
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 }
28 function part1() {
29 let wrapper = gTestBrowser.contentDocument.getElementById('wrapper');
30 wrapper.addEventListener('click', function() ++gWrapperClickCount, false);
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");
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 }
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 }