mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 13:48:23 +02:00
--HG-- rename : browser/base/content/test/general/blockNoPlugins.xml => browser/base/content/test/plugins/blockNoPlugins.xml rename : browser/base/content/test/general/blockPluginHard.xml => browser/base/content/test/plugins/blockPluginHard.xml rename : browser/base/content/test/general/blockPluginVulnerableNoUpdate.xml => browser/base/content/test/plugins/blockPluginVulnerableNoUpdate.xml rename : browser/base/content/test/general/blockPluginVulnerableUpdatable.xml => browser/base/content/test/plugins/blockPluginVulnerableUpdatable.xml rename : browser/base/content/test/general/browser_CTP_context_menu.js => browser/base/content/test/plugins/browser_CTP_context_menu.js rename : browser/base/content/test/general/browser_CTP_crashreporting.js => browser/base/content/test/plugins/browser_CTP_crashreporting.js rename : browser/base/content/test/general/browser_CTP_data_urls.js => browser/base/content/test/plugins/browser_CTP_data_urls.js rename : browser/base/content/test/general/browser_CTP_drag_drop.js => browser/base/content/test/plugins/browser_CTP_drag_drop.js rename : browser/base/content/test/general/browser_CTP_hide_overlay.js => browser/base/content/test/plugins/browser_CTP_hide_overlay.js rename : browser/base/content/test/general/browser_CTP_multi_allow.js => browser/base/content/test/plugins/browser_CTP_multi_allow.js rename : browser/base/content/test/general/browser_CTP_nonplugins.js => browser/base/content/test/plugins/browser_CTP_nonplugins.js rename : browser/base/content/test/general/browser_CTP_notificationBar.js => browser/base/content/test/plugins/browser_CTP_notificationBar.js rename : browser/base/content/test/general/browser_CTP_outsideScrollArea.js => browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js rename : browser/base/content/test/general/browser_CTP_resize.js => browser/base/content/test/plugins/browser_CTP_resize.js rename : browser/base/content/test/general/browser_bug743421.js => browser/base/content/test/plugins/browser_bug743421.js rename : browser/base/content/test/general/browser_bug744745.js => browser/base/content/test/plugins/browser_bug744745.js rename : browser/base/content/test/general/browser_bug752516.js => browser/base/content/test/plugins/browser_bug752516.js rename : browser/base/content/test/general/browser_bug787619.js => browser/base/content/test/plugins/browser_bug787619.js rename : browser/base/content/test/general/browser_bug797677.js => browser/base/content/test/plugins/browser_bug797677.js rename : browser/base/content/test/general/browser_bug812562.js => browser/base/content/test/plugins/browser_bug812562.js rename : browser/base/content/test/general/browser_bug818118.js => browser/base/content/test/plugins/browser_bug818118.js rename : browser/base/content/test/general/browser_bug820497.js => browser/base/content/test/plugins/browser_bug820497.js rename : browser/base/content/test/general/browser_clearplugindata.html => browser/base/content/test/plugins/browser_clearplugindata.html rename : browser/base/content/test/general/browser_clearplugindata.js => browser/base/content/test/plugins/browser_clearplugindata.js rename : browser/base/content/test/general/browser_clearplugindata_noage.html => browser/base/content/test/plugins/browser_clearplugindata_noage.html rename : browser/base/content/test/general/browser_pageInfo_plugins.js => browser/base/content/test/plugins/browser_pageInfo_plugins.js rename : browser/base/content/test/general/browser_pluginCrashCommentAndURL.js => browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js rename : browser/base/content/test/general/browser_pluginnotification.js => browser/base/content/test/plugins/browser_pluginnotification.js rename : browser/base/content/test/general/browser_pluginplaypreview.js => browser/base/content/test/plugins/browser_pluginplaypreview.js rename : browser/base/content/test/general/browser_pluginplaypreview2.js => browser/base/content/test/plugins/browser_pluginplaypreview2.js rename : browser/base/content/test/general/browser_plugins_added_dynamically.js => browser/base/content/test/plugins/browser_plugins_added_dynamically.js rename : browser/base/content/test/general/plugin_add_dynamically.html => browser/base/content/test/plugins/plugin_add_dynamically.html rename : browser/base/content/test/general/plugin_alternate_content.html => browser/base/content/test/plugins/plugin_alternate_content.html rename : browser/base/content/test/general/plugin_big.html => browser/base/content/test/plugins/plugin_big.html rename : browser/base/content/test/general/plugin_both.html => browser/base/content/test/plugins/plugin_both.html rename : browser/base/content/test/general/plugin_both2.html => browser/base/content/test/plugins/plugin_both2.html rename : browser/base/content/test/general/plugin_bug744745.html => browser/base/content/test/plugins/plugin_bug744745.html rename : browser/base/content/test/general/plugin_bug749455.html => browser/base/content/test/plugins/plugin_bug749455.html rename : browser/base/content/test/general/plugin_bug752516.html => browser/base/content/test/plugins/plugin_bug752516.html rename : browser/base/content/test/general/plugin_bug787619.html => browser/base/content/test/plugins/plugin_bug787619.html rename : browser/base/content/test/general/plugin_bug797677.html => browser/base/content/test/plugins/plugin_bug797677.html rename : browser/base/content/test/general/plugin_bug820497.html => browser/base/content/test/plugins/plugin_bug820497.html rename : browser/base/content/test/general/plugin_clickToPlayAllow.html => browser/base/content/test/plugins/plugin_clickToPlayAllow.html rename : browser/base/content/test/general/plugin_clickToPlayDeny.html => browser/base/content/test/plugins/plugin_clickToPlayDeny.html rename : browser/base/content/test/general/pluginCrashCommentAndURL.html => browser/base/content/test/plugins/plugin_crashCommentAndURL.html rename : browser/base/content/test/general/plugin_data_url.html => browser/base/content/test/plugins/plugin_data_url.html rename : browser/base/content/test/general/plugin_hidden_to_visible.html => browser/base/content/test/plugins/plugin_hidden_to_visible.html rename : browser/base/content/test/general/plugin_outsideScrollArea.html => browser/base/content/test/plugins/plugin_outsideScrollArea.html rename : browser/base/content/test/general/plugin_overlayed.html => browser/base/content/test/plugins/plugin_overlayed.html rename : browser/base/content/test/general/plugin_positioned.html => browser/base/content/test/plugins/plugin_positioned.html rename : browser/base/content/test/general/plugin_small.html => browser/base/content/test/plugins/plugin_small.html rename : browser/base/content/test/general/plugin_syncRemoved.html => browser/base/content/test/plugins/plugin_syncRemoved.html rename : browser/base/content/test/general/plugin_test.html => browser/base/content/test/plugins/plugin_test.html rename : browser/base/content/test/general/plugin_test2.html => browser/base/content/test/plugins/plugin_test2.html rename : browser/base/content/test/general/plugin_test3.html => browser/base/content/test/plugins/plugin_test3.html rename : browser/base/content/test/general/plugin_two_types.html => browser/base/content/test/plugins/plugin_two_types.html rename : browser/base/content/test/general/plugin_unknown.html => browser/base/content/test/plugins/plugin_unknown.html
116 lines
4.8 KiB
JavaScript
116 lines
4.8 KiB
JavaScript
var rootDir = getRootDirectory(gTestPath);
|
|
const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://mochi.test:8888/");
|
|
|
|
var gTestBrowser = null;
|
|
var gNextTest = null;
|
|
|
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
|
|
|
function test() {
|
|
waitForExplicitFinish();
|
|
registerCleanupFunction(function() {
|
|
clearAllPluginPermissions();
|
|
Services.prefs.clearUserPref("plugins.click_to_play");
|
|
});
|
|
Services.prefs.setBoolPref("plugins.click_to_play", true);
|
|
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
|
|
|
|
var newTab = gBrowser.addTab();
|
|
gBrowser.selectedTab = newTab;
|
|
gTestBrowser = gBrowser.selectedBrowser;
|
|
gTestBrowser.addEventListener("load", pageLoad, true);
|
|
prepareTest(test1a, gTestRoot + "plugin_add_dynamically.html");
|
|
}
|
|
|
|
function finishTest() {
|
|
gTestBrowser.removeEventListener("load", pageLoad, true);
|
|
gBrowser.removeCurrentTab();
|
|
window.focus();
|
|
finish();
|
|
}
|
|
|
|
function pageLoad() {
|
|
// The plugin events are async dispatched and can come after the load event
|
|
// This just allows the events to fire before we then go on to test the states
|
|
executeSoon(gNextTest);
|
|
}
|
|
|
|
function prepareTest(nextTest, url) {
|
|
gNextTest = nextTest;
|
|
gTestBrowser.contentWindow.location = url;
|
|
}
|
|
|
|
// Tests that navigation within the page and the window.history API doesn't break click-to-play state.
|
|
function test1a() {
|
|
var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
|
|
ok(!popupNotification, "Test 1a, Should not have a click-to-play notification");
|
|
var plugin = new XPCNativeWrapper(XPCNativeWrapper.unwrap(gTestBrowser.contentWindow).addPlugin());
|
|
|
|
var condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
|
|
waitForCondition(condition, test1b, "Test 1a, Waited too long for plugin notification");
|
|
}
|
|
|
|
function test1b() {
|
|
var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
|
|
ok(popupNotification, "Test 1b, Should have a click-to-play notification");
|
|
var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0];
|
|
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
|
ok(!objLoadingContent.activated, "Test 1b, Plugin should not be activated");
|
|
|
|
// Click the activate button on doorhanger to make sure it works
|
|
popupNotification.reshow();
|
|
PopupNotifications.panel.firstChild._primaryButton.click();
|
|
|
|
ok(objLoadingContent.activated, "Test 1b, Doorhanger should activate plugin");
|
|
|
|
test1c();
|
|
}
|
|
|
|
function test1c() {
|
|
var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
|
|
ok(popupNotification, "Test 1c, Should still have a click-to-play notification");
|
|
var plugin = new XPCNativeWrapper(XPCNativeWrapper.unwrap(gTestBrowser.contentWindow).addPlugin());
|
|
|
|
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
|
var condition = function() objLoadingContent.activated;
|
|
waitForCondition(condition, test1d, "Test 1c, Waited too long for plugin activation");
|
|
}
|
|
|
|
function test1d() {
|
|
var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[1];
|
|
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
|
ok(objLoadingContent.activated, "Test 1d, Plugin should be activated");
|
|
|
|
gNextTest = test1e;
|
|
gTestBrowser.contentWindow.addEventListener("hashchange", test1e, false);
|
|
gTestBrowser.contentWindow.location += "#anchorNavigation";
|
|
}
|
|
|
|
function test1e() {
|
|
gTestBrowser.contentWindow.removeEventListener("hashchange", test1e, false);
|
|
|
|
var plugin = new XPCNativeWrapper(XPCNativeWrapper.unwrap(gTestBrowser.contentWindow).addPlugin());
|
|
|
|
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
|
var condition = function() objLoadingContent.activated;
|
|
waitForCondition(condition, test1f, "Test 1e, Waited too long for plugin activation");
|
|
}
|
|
|
|
function test1f() {
|
|
var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[2];
|
|
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
|
ok(objLoadingContent.activated, "Test 1f, Plugin should be activated");
|
|
|
|
gTestBrowser.contentWindow.history.replaceState({}, "", "replacedState");
|
|
var plugin = new XPCNativeWrapper(XPCNativeWrapper.unwrap(gTestBrowser.contentWindow).addPlugin());
|
|
var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
|
var condition = function() objLoadingContent.activated;
|
|
waitForCondition(condition, test1g, "Test 1f, Waited too long for plugin activation");
|
|
}
|
|
|
|
function test1g() {
|
|
var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[3];
|
|
var objLoadingContent2 = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
|
ok(objLoadingContent2.activated, "Test 1g, Plugin should be activated");
|
|
finishTest();
|
|
}
|