browser/base/content/test/plugins/browser_bug787619.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial