gecko/browser/base/content/test/browser_bug787619.js
Benjamin Smedberg d0ea1dfb67 Bug 880735 test fixups:
* Add a test-only setter to the center-item XBL binding
* add a head.js function to remove plugin permissions for use in cleanup functions
* browser_pluginnotification.js - lots of fixes for the core feature tests
* Alter test_bug751809 not to assume that clicking the page overlay will directly activate the plugin
* Alter browser_CTP_plugins.js because disabled plugins now do show up in the plugin doorhanger
* remove browser_CTPScriptPlugin.js and supporting files because we no longer auto-pop based on scripting
* fix browser_CTP_drag_drop.js so that active plugins still show the doorhanger icon, and other fixup
* fix browser_bug743421.js to expect the doorhanger all the time and activate it correctly
* fix browser_bug752516.js to check for doorhanger activation instead of plugin activation
* remove browser_bug818009.js and supporting files because they are testing something that no longer exists
* alter browser_bug820497.js so that it shows the popup notification before checking .centerActions, since we populate that data lazily now
* browser_plugins_added_dynamically.js: remove the "activate all" tests which are no longer relevant and fix the rest to match the new doorhanger structure.
2013-06-24 08:51:07 -04:00

49 lines
1.8 KiB
JavaScript

const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
let gTestBrowser = null;
let gWrapperClickCount = 0;
function test() {
waitForExplicitFinish();
registerCleanupFunction(function() {
Services.prefs.clearUserPref("plugins.click_to_play");
let plugin = getTestPlugin();
plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED;
});
Services.prefs.setBoolPref("plugins.click_to_play", true);
let plugin = getTestPlugin();
plugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
gBrowser.selectedTab = gBrowser.addTab();
gTestBrowser = gBrowser.selectedBrowser;
gTestBrowser.addEventListener("load", pageLoad, true);
gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug787619.html";
}
function pageLoad() {
executeSoon(part1);
}
function part1() {
let wrapper = gTestBrowser.contentDocument.getElementById('wrapper');
wrapper.addEventListener('click', function() ++gWrapperClickCount, false);
let plugin = gTestBrowser.contentDocument.getElementById('plugin');
ok(plugin, 'got plugin element');
ok(!plugin.activated, 'plugin should not be activated');
ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Doorhanger should not be open");
EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow);
let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed;
waitForCondition(condition, part2,
'waited too long for plugin to activate');
}
function part2() {
is(gWrapperClickCount, 0, 'wrapper should not have received any clicks');
gTestBrowser.removeEventListener("load", pageLoad, true);
gBrowser.removeCurrentTab();
window.focus();
finish();
}