| author | Benjamin Smedberg <benjamin@smedbergs.us> |
| Mon, 24 Jun 2013 08:51:07 -0400 | |
| changeset 136244 | 3da4f4ddc8334c0475b9603b22d44faf3a3f5225 |
| parent 136243 | 501a4ba3506a93225fba24655c3e5f2b95ea9d5e |
| child 136245 | 50332b66c7a16858f074ee71218a497b06d814b2 |
| push id | 24869 |
| push user | bsmedberg@mozilla.com |
| push date | Mon, 24 Jun 2013 12:52:42 +0000 |
| treeherder | mozilla-central@50332b66c7a1 [default view] [failures only] |
| perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
| bugs | 880735, 751809, 743421, 752516, 818009, 820497 |
| milestone | 24.0a1 |
| first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
| last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -186,17 +186,16 @@ MOCHITEST_BROWSER_FILES = \ browser_overflowScroll.js \ browser_locationBarCommand.js \ browser_locationBarExternalLoad.js \ browser_page_style_menu.js \ browser_pinnedTabs.js \ browser_plainTextLinks.js \ browser_pluginnotification.js \ browser_plugins_added_dynamically.js \ - browser_CTPScriptPlugin.js \ browser_CTP_drag_drop.js \ browser_pluginplaypreview.js \ browser_pluginplaypreview2.js \ browser_private_browsing_window.js \ browser_relatedTabs.js \ browser_removeTabsToTheEnd.js \ browser_sanitize-passwordDisabledHosts.js \ browser_sanitize-sitepermissions.js \ @@ -260,35 +259,27 @@ MOCHITEST_BROWSER_FILES = \ video.ogg \ test_bug435035.html \ test_bug462673.html \ page_style_sample.html \ plugin_unknown.html \ plugin_test.html \ plugin_test2.html \ plugin_test3.html \ - plugin_test_noScriptNoPopup.html \ - plugin_test_scriptedPopup1.html \ - plugin_test_scriptedPopup2.html \ - plugin_test_scriptedPopup3.html \ - plugin_test_scriptedNoPopup1.html \ - plugin_test_scriptedNoPopup2.html \ - plugin_test_scriptedNoPopup3.html \ plugin_alternate_content.html \ plugin_both.html \ plugin_both2.html \ plugin_add_dynamically.html \ plugin_clickToPlayAllow.html \ plugin_clickToPlayDeny.html \ plugin_bug744745.html \ plugin_bug749455.html \ plugin_bug752516.html \ plugin_bug787619.html \ plugin_bug797677.html \ - plugin_bug818009.html \ plugin_bug820497.html \ plugin_hidden_to_visible.html \ plugin_two_types.html \ alltabslistener.html \ zoom_test.html \ dummy_page.html \ file_bug550565_popup.html \ file_bug550565_favicon.ico \ @@ -308,17 +299,16 @@ MOCHITEST_BROWSER_FILES = \ browser_middleMouse_inherit.js \ redirect_bug623155.sjs \ browser_tabDrop.js \ browser_lastAccessedTab.js \ browser_bug734076.js \ browser_bug744745.js \ browser_bug787619.js \ browser_bug812562.js \ - browser_bug818009.js \ browser_bug818118.js \ browser_bug820497.js \ blockPluginVulnerableUpdatable.xml \ blockPluginVulnerableNoUpdate.xml \ blockNoPlugins.xml \ blockPluginHard.xml \ browser_utilityOverlay.js \ browser_bug676619.js \
deleted file mode 100644 --- a/browser/base/content/test/browser_CTPScriptPlugin.js +++ /dev/null @@ -1,159 +0,0 @@ -const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); -const EXPECTED_PLUGINSCRIPTED_EVENT_COUNT = 6; - -var gTestBrowser = null; -var gNextTestList = []; -var gNextTest = null; -var gPluginScriptedFired = false; -var gPluginScriptedFiredCount = 0; - -Components.utils.import("resource://gre/modules/Services.jsm"); - -function test() { - waitForExplicitFinish(); - registerCleanupFunction(function() { - Services.prefs.clearUserPref("plugins.click_to_play"); - var plugin = getTestPlugin(); - plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED; - gTestBrowser.removeEventListener("load", pageLoad, true); - gTestBrowser.removeEventListener("PluginScripted", pluginScripted, true); - }); - Services.prefs.setBoolPref("plugins.click_to_play", true); - var plugin = getTestPlugin(); - plugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; - - gBrowser.selectedTab = gBrowser.addTab(); - gTestBrowser = gBrowser.selectedBrowser; - gTestBrowser.addEventListener("load", pageLoad, true); - gTestBrowser.addEventListener("PluginScripted", pluginScripted, true); - - // This list is iterated in reverse order, since it uses Array.pop to get the next test. - gNextTestList = [ - // Doesn't show a popup since not the first instance of a small plugin - { func: testExpectNoPopupPart1, - url: gHttpTestRoot + "plugin_test_scriptedPopup1.html" }, - // Doesn't show a popup since not the first instance of a small plugin - { func: testExpectNoPopupPart1, - url: gHttpTestRoot + "plugin_test_scriptedPopup2.html" }, - // Shows a popup since it is the first instance of a small plugin - { func: testExpectPopupPart1, - url: gHttpTestRoot + "plugin_test_scriptedPopup3.html" }, - { func: testExpectNoPopupPart1, - url: gHttpTestRoot + "plugin_test_scriptedNoPopup1.html" }, - { func: testExpectNoPopupPart1, - url: gHttpTestRoot + "plugin_test_scriptedNoPopup2.html" }, - { func: testExpectNoPopupPart1, - url: gHttpTestRoot + "plugin_test_scriptedNoPopup3.html" } - ]; - - prepareTest(testNoEventFired, gHttpTestRoot + "plugin_test_noScriptNoPopup.html"); -} - -function getCurrentTestLocation() { - var loc = gTestBrowser.contentWindow.location.toString(); - return loc.replace(gHttpTestRoot, ""); -} - -function runNextTest() { - var nextTest = gNextTestList.pop(); - if (nextTest) { - gPluginScriptedFired = false; - prepareTest(nextTest.func, nextTest.url); - } - else { - finishTest(); - } -} - -function finishTest() { - is(gPluginScriptedFiredCount, EXPECTED_PLUGINSCRIPTED_EVENT_COUNT, "PluginScripted event count is correct"); - gBrowser.removeCurrentTab(); - window.focus(); - finish(); -} - -function pluginScripted() { - gPluginScriptedFired = true; - gPluginScriptedFiredCount++; -} - -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; -} - -function testNoEventFired() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(notification, "should have a click-to-play notification (" + getCurrentTestLocation() + ")"); - ok(notification.dismissed, "notification should not be showing (" + getCurrentTestLocation() + ")"); - ok(!gPluginScriptedFired, "PluginScripted should not have fired (" + getCurrentTestLocation() + ")"); - - prepareTest(testDenyPermissionPart1, gHttpTestRoot + "plugin_test_noScriptNoPopup.html"); -} - -function testDenyPermissionPart1() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(notification, "test deny permission: should have a click-to-play notification"); - // Simulate clicking the "Deny Always" button. - notification.secondaryActions[1].callback(); - gPluginScriptedFired = false; - prepareTest(testDenyPermissionPart2, gHttpTestRoot + "plugin_test_scriptedPopup1.html"); -} - -function testDenyPermissionPart2() { - var condition = function() XPCNativeWrapper.unwrap(gTestBrowser.contentWindow).gScriptingFinished; - waitForCondition(condition, testDenyPermissionPart3, "test deny permission: waited too long for PluginScripted event"); -} - -function testDenyPermissionPart3() { - ok(!gPluginScriptedFired, "Should not fire plugin-scripted event for disabled plugins"); - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!notification, "test deny permission: should not have a click-to-play notification"); - - var pluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost); - Services.perms.remove("127.0.0.1:8888", pluginHost.getPermissionStringForType("application/x-test")); - - runNextTest(); -} - -function testExpectNoPopupPart1() { - var condition = function() gPluginScriptedFired; - waitForCondition(condition, testExpectNoPopupPart2, "waited too long for PluginScripted event (" + getCurrentTestLocation() + ")"); -} - -function testExpectNoPopupPart2() { - var condition = function() gTestBrowser._pluginScriptedState == gPluginHandler.PLUGIN_SCRIPTED_STATE_DONE; - waitForCondition(condition, testExpectNoPopupPart3, "waited too long for PluginScripted event handling (" + getCurrentTestLocation() + ")"); -} - -function testExpectNoPopupPart3() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(notification, "should have a click-to-play notification (" + getCurrentTestLocation() + ")"); - ok(notification.dismissed, "notification should not be showing (" + getCurrentTestLocation() + ")"); - - runNextTest(); -} - -function testExpectPopupPart1() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(notification, "should have a click-to-play notification (" + getCurrentTestLocation() + ")"); - - var condition = function() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - return !notification.dismissed; - }; - waitForCondition(condition, testExpectPopupPart2, "waited too long for popup notification to show (" + getCurrentTestLocation() + ")"); -} - -function testExpectPopupPart2() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!notification.dismissed, "notification should be showing (" + getCurrentTestLocation() + ")"); - - runNextTest(); -}
--- a/browser/base/content/test/browser_CTP_drag_drop.js +++ b/browser/base/content/test/browser_CTP_drag_drop.js @@ -6,16 +6,17 @@ let gHttpTestRoot = getRootDirectory(gTe let gNextTest = null; let gNewWindow = null; Components.utils.import("resource://gre/modules/Services.jsm"); function test() { waitForExplicitFinish(); registerCleanupFunction(function() { + clearAllPluginPermissions(); 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; @@ -81,96 +82,23 @@ function part7() { ok(PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser), "Should have a click-to-play notification in the tab in the new window"); ok(!PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should not have a click-to-play notification in the old window now"); let plugin = gNewWindow.gBrowser.selectedBrowser.contentDocument.getElementById("test"); let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(!objLoadingContent.activated, "plugin should not be activated"); EventUtils.synthesizeMouseAtCenter(plugin, {}, gNewWindow.gBrowser.selectedBrowser.contentWindow); - let condition = function() objLoadingContent.activated; + let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser).dismissed; waitForCondition(condition, part8, "waited too long for plugin to activate"); } function part8() { - ok(!PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser), "Should not have a click-to-play notification in the tab in the new window now"); + // Click the activate button on doorhanger to make sure it works + gNewWindow.PopupNotifications.panel.firstChild._primaryButton.click(); + let plugin = gNewWindow.gBrowser.selectedBrowser.contentDocument.getElementById("test"); let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(objLoadingContent.activated, "plugin should be activated now"); gNewWindow.close(); - gBrowser.selectedTab = gBrowser.addTab(); - gNextTest = part9; - gBrowser.selectedBrowser.addEventListener("PluginBindingAttached", handleEvent, true, true); - // This test page contains an "invisible" plugin. It doesn't script it, - // but when we do later in this test, it will trigger the popup notification. - gBrowser.selectedBrowser.contentDocument.location = gHttpTestRoot + "plugin_test_noScriptNoPopup.html"; -} - -function part9() { - gBrowser.selectedBrowser.removeEventListener("PluginBindingAttached", handleEvent); - ok(PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should have a click-to-play notification in the initial tab"); - - gNextTest = part10; - gNewWindow = gBrowser.replaceTabWithWindow(gBrowser.selectedTab); - gNewWindow.addEventListener("load", handleEvent, true); -} - -function part10() { - gNewWindow.removeEventListener("load", handleEvent); - let condition = function() PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser); - waitForCondition(condition, part11, "Waited too long for click-to-play notification"); -} - -function part11() { - ok(!PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should not have a click-to-play notification in the old window now"); - let notification = PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser); - ok(notification, "Should have a click-to-play notification in the tab in the new window"); - // we have to actually show the panel to get the bindings to instantiate - notification.options.eventCallback = part12; - // this scripts the plugin, triggering the popup notification - try { - gNewWindow.gBrowser.selectedBrowser.contentDocument.getElementById("test").wrappedJSObject.getObjectValue(); - } catch (e) {} -} - -function part12(type) { - if (type != "shown") { - return; - } - let notification = PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser); - notification.options.eventCallback = null; - let centerAction = null; - for (let action of notification.options.centerActions) { - if (action.message == "Test") { - centerAction = action; - break; - } - } - ok(centerAction, "Found center action for the Test plugin"); - - let centerItem = null; - for (let item of centerAction.popupnotification.childNodes) { - if (item.action == centerAction) { - centerItem = item; - break; - } - } - ok(centerItem, "Found center item for the Test plugin"); - - // "click" the button to activate the Test plugin - centerItem.runCallback.apply(centerItem); - - let plugin = gNewWindow.gBrowser.selectedBrowser.contentDocument.getElementById("test"); - let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - let condition = function() objLoadingContent.activated; - waitForCondition(condition, part13, "Waited too long for plugin to activate via center action"); -} - -function part13() { - ok(!PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser), "Should not have a click-to-play notification in the tab in the new window"); - let plugin = gNewWindow.gBrowser.selectedBrowser.contentDocument.getElementById("test"); - let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Plugin should be activated via center action"); - - gNewWindow.close(); finish(); }
--- a/browser/base/content/test/browser_bug743421.js +++ b/browser/base/content/test/browser_bug743421.js @@ -1,19 +1,19 @@ -var rootDir = getRootDirectory(gTestPath); -const gTestRoot = rootDir; +const gTestRoot = "http://mochi.test:8888/browser/browser/base/content/test/"; 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"); var plugin = getTestPlugin(); plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED; }); Services.prefs.setBoolPref("plugins.click_to_play", true); var plugin = getTestPlugin(); plugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; @@ -41,80 +41,78 @@ 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 = gTestBrowser.contentWindow.addPlugin(); + 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"); - popupNotification.mainAction.callback(); + // 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 not have a click-to-play notification"); - var plugin = gTestBrowser.contentWindow.addPlugin(); + 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 popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 1d, Should not have a click-to-play notification"); 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 popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 1e, Should not have a click-to-play notification"); - var plugin = gTestBrowser.contentWindow.addPlugin(); + + 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 popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 1f, Should not have a click-to-play notification"); 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 = gTestBrowser.contentWindow.addPlugin(); + 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 popupNotification2 = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification2, "Test 1g, Should not have a click-to-play notification after replaceState"); var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[3]; var objLoadingContent2 = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(objLoadingContent2.activated, "Test 1g, Plugin should be activated"); finishTest(); }
--- a/browser/base/content/test/browser_bug752516.js +++ b/browser/base/content/test/browser_bug752516.js @@ -32,15 +32,15 @@ function tabLoad() { // The plugin events are async dispatched and can come after the load event // This just allows the events to fire before we proceed executeSoon(actualTest); } function actualTest() { let doc = gTestBrowser.contentDocument; let plugin = doc.getElementById("test"); - let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Plugin should not be activated"); + 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() objLoadingContent.activated; - waitForCondition(condition, finish, "Waited too long for plugin to activate"); + let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; + waitForCondition(condition, finish, "Waited too long for plugin doorhanger to activate"); }
--- a/browser/base/content/test/browser_bug787619.js +++ b/browser/base/content/test/browser_bug787619.js @@ -25,21 +25,22 @@ function pageLoad() { } 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'); - let objLC = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLC.activated, 'plugin should not be activated'); + 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); - waitForCondition(function() objLC.activated, part2, + 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();
deleted file mode 100644 --- a/browser/base/content/test/browser_bug818009.js +++ /dev/null @@ -1,51 +0,0 @@ -var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); -var gTestBrowser = null; - -Components.utils.import("resource://gre/modules/Services.jsm"); - -function test() { - waitForExplicitFinish(); - registerCleanupFunction(function() { - Services.prefs.clearUserPref("plugins.click_to_play"); - var plugin = getTestPlugin(); - plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED; - gTestBrowser.removeEventListener("load", pageLoad, true); - }); - Services.prefs.setBoolPref("plugins.click_to_play", true); - var 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_bug818009.html"; -} - -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(actualTest); -} - -function actualTest() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(notification, "should have a click-to-play notification"); - is(notification.options.centerActions.length, 1, "should have only one type of plugin in the notification"); - is(notification.options.centerActions[0].message, "Test", "the one type of plugin should be the 'Test' plugin"); - - var doc = gTestBrowser.contentDocument; - var inner = doc.getElementById("inner"); - ok(inner, "should have 'inner' plugin"); - var innerObjLC = inner.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!innerObjLC.activated, "inner plugin shouldn't be activated"); - is(innerObjLC.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "inner plugin fallback type should be PLUGIN_CLICK_TO_PLAY"); - var outer = doc.getElementById("outer"); - ok(outer, "should have 'outer' plugin"); - var outerObjLC = outer.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!outerObjLC.activated, "outer plugin shouldn't be activated"); - is(outerObjLC.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_ALTERNATE, "outer plugin fallback type should be PLUGIN_ALTERNATE"); - - gBrowser.removeCurrentTab(); - window.focus(); - finish(); -}
--- a/browser/base/content/test/browser_bug820497.js +++ b/browser/base/content/test/browser_bug820497.js @@ -35,23 +35,27 @@ function pluginBindingAttached() { if (gNumPluginBindingsAttached == 1) { var doc = gTestBrowser.contentDocument; var testplugin = doc.getElementById("test"); ok(testplugin, "should have test plugin"); var secondtestplugin = doc.getElementById("secondtest"); ok(!secondtestplugin, "should not yet have second test plugin"); var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(notification, "should have popup notification"); + // We don't set up the action list until the notification is shown + notification.reshow(); is(notification.options.centerActions.length, 1, "should be 1 type of plugin in the popup notification"); + XPCNativeWrapper.unwrap(gTestBrowser.contentWindow).addSecondPlugin(); } else if (gNumPluginBindingsAttached == 2) { var doc = gTestBrowser.contentDocument; var testplugin = doc.getElementById("test"); ok(testplugin, "should have test plugin"); var secondtestplugin = doc.getElementById("secondtest"); ok(secondtestplugin, "should have second test plugin"); var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(notification, "should have popup notification"); + notification.reshow(); is(notification.options.centerActions.length, 2, "should be 2 types of plugin in the popup notification"); finish(); } else { ok(false, "if we've gotten here, something is quite wrong"); } }
--- a/browser/base/content/test/browser_pluginnotification.js +++ b/browser/base/content/test/browser_pluginnotification.js @@ -1,16 +1,14 @@ var rootDir = getRootDirectory(gTestPath); const gTestRoot = rootDir; const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); var gTestBrowser = null; var gNextTest = null; -var gClickToPlayPluginActualEvents = 0; -var gClickToPlayPluginExpectedEvents = 5; var gPluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost); Components.utils.import("resource://gre/modules/Services.jsm"); // This listens for the next opened tab and checks it is of the right url. // opencallback is called when the new tab is fully loaded // closecallback is called when the tab is closed function TabOpenListener(url, opencallback, closecallback) { @@ -55,65 +53,55 @@ TabOpenListener.prototype = { } } }; function test() { waitForExplicitFinish(); requestLongerTimeout(2); registerCleanupFunction(function() { + clearAllPluginPermissions(); Services.prefs.clearUserPref("extensions.blocklist.suppressUI"); - Services.prefs.clearUserPref("plugins.click_to_play"); getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED; getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_ENABLED; }); - Services.prefs.setBoolPref("plugins.click_to_play", false); Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true); var plugin = getTestPlugin(); plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED; var newTab = gBrowser.addTab(); gBrowser.selectedTab = newTab; gTestBrowser = gBrowser.selectedBrowser; gTestBrowser.addEventListener("load", pageLoad, true); - gTestBrowser.addEventListener("PluginBindingAttached", handleBindingAttached, true, true); prepareTest(test1, gTestRoot + "plugin_unknown.html"); } function finishTest() { + clearAllPluginPermissions(); gTestBrowser.removeEventListener("load", pageLoad, true); - gTestBrowser.removeEventListener("PluginBindingAttached", handleBindingAttached, true, true); gBrowser.removeCurrentTab(); window.focus(); finish(); } -function handleBindingAttached(evt) { - evt.target instanceof Ci.nsIObjectLoadingContent; - if (evt.target.pluginFallbackType == Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY) - gClickToPlayPluginActualEvents++; -} - 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 a page with an unknown plugin in it. function test1() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); ok(PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 1, Should have displayed the missing plugin notification"); - ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 1, Should not have displayed the blocked plugin notification"); ok(gTestBrowser.missingPlugins, "Test 1, Should be a missing plugin list"); ok(gTestBrowser.missingPlugins.has("application/x-unknown"), "Test 1, Should know about application/x-unknown"); ok(!gTestBrowser.missingPlugins.has("application/x-test"), "Test 1, Should not know about application/x-test"); var pluginNode = gTestBrowser.contentDocument.getElementById("unknown"); ok(pluginNode, "Test 1, Found plugin in page"); var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_UNSUPPORTED, "Test 1, plugin fallback type should be PLUGIN_UNSUPPORTED"); @@ -121,32 +109,28 @@ function test1() { var plugin = getTestPlugin(); ok(plugin, "Should have a test plugin"); plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED; prepareTest(test2, gTestRoot + "plugin_test.html"); } // Tests a page with a working plugin in it. function test2() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 2, Should not have displayed the missing plugin notification"); - ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 2, Should not have displayed the blocked plugin notification"); ok(!gTestBrowser.missingPlugins, "Test 2, Should not be a missing plugin list"); var plugin = getTestPlugin(); ok(plugin, "Should have a test plugin"); plugin.enabledState = Ci.nsIPluginTag.STATE_DISABLED; prepareTest(test3, gTestRoot + "plugin_test.html"); } // Tests a page with a disabled plugin in it. function test3() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 3, Should not have displayed the missing plugin notification"); - ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 3, Should not have displayed the blocked plugin notification"); ok(!gTestBrowser.missingPlugins, "Test 3, Should not be a missing plugin list"); new TabOpenListener("about:addons", test4, prepareTest5); var pluginNode = gTestBrowser.contentDocument.getElementById("test"); ok(pluginNode, "Test 3, Found plugin in page"); var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_DISABLED, "Test 3, plugin fallback type should be PLUGIN_DISABLED"); @@ -170,191 +154,75 @@ function prepareTest5() { info("prepareTest5 callback"); prepareTest(test5, gTestRoot + "plugin_test.html"); }); } // Tests a page with a blocked plugin in it. function test5() { info("test5"); - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 5, Should not have displayed the missing plugin notification"); - ok(notificationBox.getNotificationWithValue("blocked-plugins"), "Test 5, Should have displayed the blocked plugin notification"); - ok(gTestBrowser.missingPlugins, "Test 5, Should be a missing plugin list"); - ok(gTestBrowser.missingPlugins.has("application/x-test"), "Test 5, Should know about application/x-test"); - ok(!gTestBrowser.missingPlugins.has("application/x-unknown"), "Test 5, Should not know about application/x-unknown"); + let notification = PopupNotifications.getNotification("click-to-play-plugins"); + ok(notification, "Test 5: There should be a plugin notification for blocked plugins"); + ok(notification.dismissed, "Test 5: The plugin notification should be dismissed by default"); + + notification.reshow(); + is(notification.options.centerActions.length, 1, "Test 5: Only the blocked plugin should be present in the notification"); + ok(PopupNotifications.panel.firstChild._buttonContainer.hidden, "Part 5: The blocked plugins notification should not have any buttons visible."); + + ok(!gTestBrowser.missingPlugins, "Test 5, Should not be a missing plugin list"); var pluginNode = gTestBrowser.contentDocument.getElementById("test"); ok(pluginNode, "Test 5, Found plugin in page"); var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_BLOCKLISTED, "Test 5, plugin fallback type should be PLUGIN_BLOCKLISTED"); prepareTest(test6, gTestRoot + "plugin_both.html"); } // Tests a page with a blocked and unknown plugin in it. function test6() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); ok(PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 6, Should have displayed the missing plugin notification"); - ok(notificationBox.getNotificationWithValue("blocked-plugins"), "Test 6, Should have displayed the blocked plugin notification"); ok(gTestBrowser.missingPlugins, "Test 6, Should be a missing plugin list"); ok(gTestBrowser.missingPlugins.has("application/x-unknown"), "Test 6, Should know about application/x-unknown"); - ok(gTestBrowser.missingPlugins.has("application/x-test"), "Test 6, Should know about application/x-test"); + ok(!gTestBrowser.missingPlugins.has("application/x-test"), "Test 6, application/x-test should not be a missing plugin"); prepareTest(test7, gTestRoot + "plugin_both2.html"); } // Tests a page with a blocked and unknown plugin in it (alternate order to above). function test7() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); ok(PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 7, Should have displayed the missing plugin notification"); - ok(notificationBox.getNotificationWithValue("blocked-plugins"), "Test 7, Should have displayed the blocked plugin notification"); ok(gTestBrowser.missingPlugins, "Test 7, Should be a missing plugin list"); ok(gTestBrowser.missingPlugins.has("application/x-unknown"), "Test 7, Should know about application/x-unknown"); - ok(gTestBrowser.missingPlugins.has("application/x-test"), "Test 7, Should know about application/x-test"); + ok(!gTestBrowser.missingPlugins.has("application/x-test"), "Test 7, application/x-test should not be a missing plugin"); - Services.prefs.setBoolPref("plugins.click_to_play", true); var plugin = getTestPlugin(); plugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml", function() { prepareTest(test8, gTestRoot + "plugin_test.html"); }); } // Tests a page with a working plugin that is click-to-play function test8() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 8, Should not have displayed the missing plugin notification"); - ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 8, Should not have displayed the blocked plugin notification"); ok(!gTestBrowser.missingPlugins, "Test 8, Should not be a missing plugin list"); ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser), "Test 8, Should have a click-to-play notification"); var pluginNode = gTestBrowser.contentDocument.getElementById("test"); ok(pluginNode, "Test 8, Found plugin in page"); var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Test 8, plugin fallback type should be PLUGIN_CLICK_TO_PLAY"); - prepareTest(test9a, gTestRoot + "plugin_test2.html"); -} - -// Tests that activating one click-to-play plugin will activate only that plugin (part 1/3) -function test9a() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); - ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 9a, Should not have displayed the missing plugin notification"); - ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 9a, Should not have displayed the blocked plugin notification"); - ok(!gTestBrowser.missingPlugins, "Test 9a, Should not be a missing plugin list"); - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(notification, "Test 9a, Should have a click-to-play notification"); - ok(notification.options.centerActions.length == 1, "Test 9a, Should have only one type of plugin in the notification"); - - var doc = gTestBrowser.contentDocument; - var plugin1 = doc.getElementById("test1"); - var rect = doc.getAnonymousElementByAttribute(plugin1, "class", "mainBox").getBoundingClientRect(); - ok(rect.width == 200, "Test 9a, Plugin with id=" + plugin1.id + " overlay rect should have 200px width before being clicked"); - ok(rect.height == 200, "Test 9a, Plugin with id=" + plugin1.id + " overlay rect should have 200px height before being clicked"); - var objLoadingContent = plugin1.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 9a, Plugin with id=" + plugin1.id + " should not be activated"); - - var plugin2 = doc.getElementById("test2"); - var rect = doc.getAnonymousElementByAttribute(plugin2, "class", "mainBox").getBoundingClientRect(); - ok(rect.width == 200, "Test 9a, Plugin with id=" + plugin2.id + " overlay rect should have 200px width before being clicked"); - ok(rect.height == 200, "Test 9a, Plugin with id=" + plugin2.id + " overlay rect should have 200px height before being clicked"); - var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 9a, Plugin with id=" + plugin2.id + " should not be activated"); - - EventUtils.synthesizeMouseAtCenter(plugin1, {}, gTestBrowser.contentWindow); - var objLoadingContent = plugin1.QueryInterface(Ci.nsIObjectLoadingContent); - var condition = function() objLoadingContent.activated; - waitForCondition(condition, test9b, "Test 9a, Waited too long for plugin to activate"); + prepareTest(test11a, gTestRoot + "plugin_test3.html"); } -// Tests that activating one click-to-play plugin will activate only that plugin (part 2/3) -function test9b() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); - ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 9b, Should not have displayed the missing plugin notification"); - ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 9b, Should not have displayed the blocked plugin notification"); - ok(!gTestBrowser.missingPlugins, "Test 9b, Should not be a missing plugin list"); - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(notification, "Test 9b, Click to play notification should not be removed now"); - ok(notification.options.centerActions.length == 1, "Test 9b, Should have only one type of plugin in the notification"); - - var doc = gTestBrowser.contentDocument; - var plugin1 = doc.getElementById("test1"); - var pluginRect1 = doc.getAnonymousElementByAttribute(plugin1, "class", "mainBox").getBoundingClientRect(); - ok(pluginRect1.width == 0, "Test 9b, Plugin with id=" + plugin1.id + " should have click-to-play overlay with zero width"); - ok(pluginRect1.height == 0, "Test 9b, Plugin with id=" + plugin1.id + " should have click-to-play overlay with zero height"); - var objLoadingContent = plugin1.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 9b, Plugin with id=" + plugin1.id + " should be activated"); - - var plugin2 = doc.getElementById("test2"); - var pluginRect2 = doc.getAnonymousElementByAttribute(plugin2, "class", "mainBox").getBoundingClientRect(); - ok(pluginRect2.width != 0, "Test 9b, Plugin with id=" + plugin2.id + " should not have click-to-play overlay with zero width"); - ok(pluginRect2.height != 0, "Test 9b, Plugin with id=" + plugin2.id + " should not have click-to-play overlay with zero height"); - var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 9b, Plugin with id=" + plugin2.id + " should not be activated"); - - EventUtils.synthesizeMouseAtCenter(plugin2, {}, gTestBrowser.contentWindow); - var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent); - var condition = function() objLoadingContent.activated; - waitForCondition(condition, test9c, "Test 9b, Waited too long for plugin to activate"); -} - -// -// Tests that activating one click-to-play plugin will activate only that plugin (part 3/3) -function test9c() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); - ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 9c, Should not have displayed the missing plugin notification"); - ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 9c, Should not have displayed the blocked plugin notification"); - ok(!gTestBrowser.missingPlugins, "Test 9c, Should not be a missing plugin list"); - ok(!PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser), "Test 9c, Click to play notification should be removed now"); - - var doc = gTestBrowser.contentDocument; - var plugin1 = doc.getElementById("test1"); - var pluginRect1 = doc.getAnonymousElementByAttribute(plugin1, "class", "mainBox").getBoundingClientRect(); - ok(pluginRect1.width == 0, "Test 9c, Plugin with id=" + plugin1.id + " should have click-to-play overlay with zero width"); - ok(pluginRect1.height == 0, "Test 9c, Plugin with id=" + plugin1.id + " should have click-to-play overlay with zero height"); - var objLoadingContent = plugin1.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 9c, Plugin with id=" + plugin1.id + " should be activated"); - - var plugin2 = doc.getElementById("test1"); - var pluginRect2 = doc.getAnonymousElementByAttribute(plugin2, "class", "mainBox").getBoundingClientRect(); - ok(pluginRect2.width == 0, "Test 9c, Plugin with id=" + plugin2.id + " should have click-to-play overlay with zero width"); - ok(pluginRect2.height == 0, "Test 9c, Plugin with id=" + plugin2.id + " should have click-to-play overlay with zero height"); - var objLoadingContent = plugin2.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 9c, Plugin with id=" + plugin2.id + " should be activated"); - - prepareTest(test10a, gTestRoot + "plugin_test3.html"); -} - -// Tests that activating a hidden click-to-play plugin through the notification works (part 1/2) -function test10a() { - var notificationBox = gBrowser.getNotificationBox(gTestBrowser); - ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 10a, Should not have displayed the missing plugin notification"); - ok(!notificationBox.getNotificationWithValue("blocked-plugins"), "Test 10a, Should not have displayed the blocked plugin notification"); - ok(!gTestBrowser.missingPlugins, "Test 10a, Should not be a missing plugin list"); - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(popupNotification, "Test 10a, Should have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 10a, Plugin should not be activated"); - - popupNotification.mainAction.callback(); - var condition = function() objLoadingContent.activated; - waitForCondition(condition, test10b, "Test 10a, Waited too long for plugin to activate"); -} - -// Tests that activating a hidden click-to-play plugin through the notification works (part 2/2) -function test10b() { - var plugin = gTestBrowser.contentDocument.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 10b, Plugin should be activated"); - - prepareTest(test11a, gTestRoot + "plugin_test3.html"); -} +// Tests 9 & 10 removed // Tests that the going back will reshow the notification for click-to-play plugins (part 1/4) function test11a() { var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(popupNotification, "Test 11a, Should have a click-to-play notification"); prepareTest(test11b, "about:blank"); } @@ -374,243 +242,86 @@ function test11c() { var condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); waitForCondition(condition, test11d, "Test 11c, waited too long for click-to-play-plugin notification"); } // Tests that the going back will reshow the notification for click-to-play plugins (part 4/4) function test11d() { var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(popupNotification, "Test 11d, Should have a click-to-play notification"); - is(gClickToPlayPluginActualEvents, gClickToPlayPluginExpectedEvents, - "There should be a PluginClickToPlay event for each plugin that was " + - "blocked due to the plugins.click_to_play pref"); prepareTest(test12a, gHttpTestRoot + "plugin_clickToPlayAllow.html"); } -// Tests that the "Allow Always" permission works for click-to-play plugins (part 1/3) +// Tests that the "Allow Always" permission works for click-to-play plugins function test12a() { var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(popupNotification, "Test 12a, Should have a click-to-play notification"); var plugin = gTestBrowser.contentDocument.getElementById("test"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(!objLoadingContent.activated, "Test 12a, Plugin should not be activated"); // Simulate clicking the "Allow Always" button. - popupNotification.secondaryActions[0].callback(); + popupNotification.reshow(); + PopupNotifications.panel.firstChild._primaryButton.click(); + var condition = function() objLoadingContent.activated; waitForCondition(condition, test12b, "Test 12a, Waited too long for plugin to activate"); } -// Tests that the "Always" permission works for click-to-play plugins (part 2/3) function test12b() { var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 12b, Should not have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 12b, Plugin should be activated"); - - prepareTest(test12c, gHttpTestRoot + "plugin_clickToPlayAllow.html"); -} - -// Tests that the "Always" permission works for click-to-play plugins (part 3/3) -function test12c() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 12c, Should not have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 12c, Plugin should be activated"); - - prepareTest(test12d, gHttpTestRoot + "plugin_two_types.html"); + ok(popupNotification, "Test 12d, Should have a click-to-play notification"); + prepareTest(test12c, gHttpTestRoot + "plugin_two_types.html"); } // Test that the "Always" permission, when set for just the Test plugin, // does not also allow the Second Test plugin. -function test12d() { +function test12c() { var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(popupNotification, "Test 12d, Should have a click-to-play notification"); var test = gTestBrowser.contentDocument.getElementById("test"); var secondtestA = gTestBrowser.contentDocument.getElementById("secondtestA"); var secondtestB = gTestBrowser.contentDocument.getElementById("secondtestB"); - var objLoadingContent = test.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 12d, Test plugin should be activated"); - var objLoadingContent = secondtestA.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 12d, Second Test plugin (A) should not be activated"); - var objLoadingContent = secondtestB.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 12d, Second Test plugin (B) should not be activated"); - - Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test")); - prepareTest(test13a, gHttpTestRoot + "plugin_clickToPlayDeny.html"); -} - -// Tests that the "Deny Always" permission works for click-to-play plugins (part 1/3) -function test13a() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(popupNotification, "Test 13a, Should have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 13a, Plugin should not be activated"); - - // Simulate clicking the "Deny Always" button. - popupNotification.secondaryActions[1].callback(); - test13b(); -} - -// Tests that the "Deny Always" permission works for click-to-play plugins (part 2/3) -function test13b() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 13b, Should not have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 13b, Plugin should not be activated"); - var overlay = gTestBrowser.contentDocument.getAnonymousElementByAttribute(plugin, "class", "mainBox"); - ok(overlay.style.visibility == "hidden", "Test 13b, Plugin should not have visible overlay"); - - gNextTest = test13c; - gTestBrowser.reload(); -} - -// Tests that the "Deny Always" permission works for click-to-play plugins (part 3/3) -function test13c() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 13c, Should not have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 13c, Plugin should not be activated"); - is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_DISABLED, "Test 13c, Plugin should be disabled"); - - var overlay = gTestBrowser.contentDocument.getAnonymousElementByAttribute(plugin, "class", "mainBox"); - ok(overlay.style.visibility != "visible", "Test 13c, Plugin should have visible overlay"); + ok(test.activated, "Test 12d, Test plugin should be activated"); + ok(!secondtestA.activated, "Test 12d, Second Test plugin (A) should not be activated"); + ok(!secondtestB.activated, "Test 12d, Second Test plugin (B) should not be activated"); - prepareTest(test13d, gHttpTestRoot + "plugin_two_types.html"); -} - -// Test that the "Deny Always" permission, when set for just the Test plugin, -// does not also block the Second Test plugin (i.e. it gets an overlay and -// there's a notification and everything). -function test13d() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(popupNotification, "Test 13d, Should have a click-to-play notification"); - - var test = gTestBrowser.contentDocument.getElementById("test"); - var objLoadingContent = test.QueryInterface(Ci.nsIObjectLoadingContent); - var overlay = gTestBrowser.contentDocument.getAnonymousElementByAttribute(test, "class", "mainBox"); - ok(overlay.style.visibility != "hidden", "Test 13d, Test plugin should have visible overlay"); - ok(!objLoadingContent.activated, "Test 13d, Test plugin should not be activated"); - is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_DISABLED, "Test 13d, Test plugin should be disabled"); - - var secondtestA = gTestBrowser.contentDocument.getElementById("secondtestA"); - var objLoadingContent = secondtestA.QueryInterface(Ci.nsIObjectLoadingContent); - var overlay = gTestBrowser.contentDocument.getAnonymousElementByAttribute(secondtestA, "class", "mainBox"); - ok(overlay.style.visibility != "hidden", "Test 13d, Test plugin should have visible overlay"); - ok(!objLoadingContent.activated, "Test 13d, Second Test plugin (A) should not be activated"); - is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Test 13d, Test plugin should be disabled"); - - var secondtestB = gTestBrowser.contentDocument.getElementById("secondtestB"); - var objLoadingContent = secondtestB.QueryInterface(Ci.nsIObjectLoadingContent); - var overlay = gTestBrowser.contentDocument.getAnonymousElementByAttribute(secondtestB, "class", "mainBox"); - ok(overlay.style.visibility != "hidden", "Test 13d, Test plugin should have visible overlay"); - ok(!objLoadingContent.activated, "Test 13d, Second Test plugin (B) should not be activated"); - - var condition = function() objLoadingContent.activated; - // "click" "Activate All Plugins" - popupNotification.mainAction.callback(); - waitForCondition(condition, test13e, "Test 13d, Waited too long for plugin to activate"); -} - -// Test that clicking "Activate All Plugins" won't activate plugins that -// have previously been "Deny Always"-ed. -function test13e() { - var test = gTestBrowser.contentDocument.getElementById("test"); - var objLoadingContent = test.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 13e, Test plugin should not be activated"); - - var secondtestA = gTestBrowser.contentDocument.getElementById("secondtestA"); - var objLoadingContent = secondtestA.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 13e, Second Test plugin (A) should be activated"); - - var secondtestB = gTestBrowser.contentDocument.getElementById("secondtestB"); - var objLoadingContent = secondtestB.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 13e, Second Test plugin (B) should be activated"); - - Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test")); - Services.prefs.setBoolPref("plugins.click_to_play", false); + clearAllPluginPermissions(); var plugin = getTestPlugin(); plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED; prepareTest(test14, gTestRoot + "plugin_test2.html"); } +// Test 13 removed + // Tests that the plugin's "activated" property is true for working plugins with click-to-play disabled. function test14() { var plugin = gTestBrowser.contentDocument.getElementById("test1"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(objLoadingContent.activated, "Test 14, Plugin should be activated"); - Services.prefs.setBoolPref("plugins.click_to_play", true); var plugin = getTestPlugin(); plugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; prepareTest(test15, gTestRoot + "plugin_alternate_content.html"); } // Tests that the overlay is shown instead of alternate content when // plugins are click to play function test15() { var plugin = gTestBrowser.contentDocument.getElementById("test"); var doc = gTestBrowser.contentDocument; var mainBox = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox"); ok(mainBox, "Test 15, Plugin with id=" + plugin.id + " overlay should exist"); - prepareTest(test16a, gTestRoot + "plugin_add_dynamically.html"); -} - -// Tests that a plugin dynamically added to a page after one plugin is clicked -// to play (which removes the notification) gets its own notification (1/4) -function test16a() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 16a, Should not have a click-to-play notification"); - var plugin = gTestBrowser.contentWindow.addPlugin(); - var condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - waitForCondition(condition, test16b, "Test 16a, Waited too long for click-to-play-plugin notification"); + prepareTest(test17, gTestRoot + "plugin_bug749455.html"); } -// 2/4 -function test16b() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(popupNotification, "Test 16b, Should have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0]; - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 16b, Plugin should not be activated"); - EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow); - var condition = function() objLoadingContent.activated; - waitForCondition(condition, test16c, "Test 16b, Waited too long for plugin to activate"); -} - -// 3/4 -function test16c() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 16c, Should not have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0]; - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 16c, Plugin should be activated"); - var plugin = gTestBrowser.contentWindow.addPlugin(); - var condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - waitForCondition(condition, test16d, "Test 16c, Waited too long for click-to-play-plugin notification"); -} - -// 4/4 -function test16d() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(popupNotification, "Test 16d, Should have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[1]; - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 16d, Plugin should not be activated"); - - prepareTest(test17, gTestRoot + "plugin_bug749455.html"); -} +// Test 16 removed // Tests that mContentType is used for click-to-play plugins, and not the // inspected type. function test17() { var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(clickToPlayNotification, "Test 17, Should have a click-to-play notification"); var missingNotification = PopupNotifications.getNotification("missing-plugins", gTestBrowser); ok(!missingNotification, "Test 17, Should not have a missing plugin notification"); @@ -675,41 +386,39 @@ function test18c() { is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE, "Test 18c, plugin fallback type should be PLUGIN_VULNERABLE_NO_UPDATE"); ok(!objLoadingContent.activated, "Test 18c, Plugin should not be activated"); var overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox"); ok(overlay.style.visibility != "hidden", "Test 18c, Plugin overlay should exist, not be hidden"); var updateLink = doc.getAnonymousElementByAttribute(plugin, "class", "checkForUpdatesLink"); ok(updateLink.style.display != "block", "Test 18c, Plugin should not have an update link"); // check that click "Always allow" works with blocklisted plugins - clickToPlayNotification.secondaryActions[0].callback(); + clickToPlayNotification.reshow(); + PopupNotifications.panel.firstChild._primaryButton.click(); + var condition = function() objLoadingContent.activated; waitForCondition(condition, test18d, "Test 18d, Waited too long for plugin to activate"); } // continue testing "Always allow" function test18d() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 18d, Should not have a click-to-play notification"); var plugin = gTestBrowser.contentDocument.getElementById("test"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(objLoadingContent.activated, "Test 18d, Plugin should be activated"); prepareTest(test18e, gHttpTestRoot + "plugin_test.html"); } // continue testing "Always allow" function test18e() { - var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "Test 18e, Should not have a click-to-play notification"); var plugin = gTestBrowser.contentDocument.getElementById("test"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(objLoadingContent.activated, "Test 18e, Plugin should be activated"); - Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test")); + clearAllPluginPermissions(); prepareTest(test18f, gHttpTestRoot + "plugin_test.html"); } // clicking the in-content overlay of a vulnerable plugin should bring // up the notification and not directly activate the plugin function test18f() { var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(notification, "Test 18f, Should have a click-to-play notification"); @@ -736,79 +445,69 @@ function test18g() { setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml", function() { resetBlocklist(); prepareTest(test19a, gTestRoot + "plugin_test.html"); }); } -// Tests that clicking the icon of the overlay activates the plugin +// Tests that clicking the icon of the overlay activates the doorhanger function test19a() { var doc = gTestBrowser.contentDocument; var plugin = doc.getElementById("test"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(!objLoadingContent.activated, "Test 19a, Plugin should not be activated"); + ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Test 19a, Doorhanger should start out dismissed"); var icon = doc.getAnonymousElementByAttribute(plugin, "class", "icon"); EventUtils.synthesizeMouseAtCenter(icon, {}, gTestBrowser.contentWindow); - var condition = function() objLoadingContent.activated; - waitForCondition(condition, test19b, "Test 19a, Waited too long for plugin to activate"); + let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; + waitForCondition(condition, test19b, "Test 19a, Waited too long for doorhanger to activate"); } function test19b() { - var doc = gTestBrowser.contentDocument; - var plugin = doc.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 19b, Plugin should be activated"); - prepareTest(test19c, gTestRoot + "plugin_test.html"); } // Tests that clicking the text of the overlay activates the plugin function test19c() { var doc = gTestBrowser.contentDocument; var plugin = doc.getElementById("test"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(!objLoadingContent.activated, "Test 19c, Plugin should not be activated"); + ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Test 19c, Doorhanger should start out dismissed"); + var text = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgClickToPlay"); EventUtils.synthesizeMouseAtCenter(text, {}, gTestBrowser.contentWindow); - var condition = function() objLoadingContent.activated; - waitForCondition(condition, test19d, "Test 19c, Waited too long for plugin to activate"); + let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; + waitForCondition(condition, test19d, "Test 19c, Waited too long for doorhanger to activate"); } function test19d() { - var doc = gTestBrowser.contentDocument; - var plugin = doc.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 19d, Plugin should be activated"); - prepareTest(test19e, gTestRoot + "plugin_test.html"); } -// Tests that clicking the box of the overlay activates the plugin +// Tests that clicking the box of the overlay activates the doorhanger // (just to be thorough) function test19e() { var doc = gTestBrowser.contentDocument; var plugin = doc.getElementById("test"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(!objLoadingContent.activated, "Test 19e, Plugin should not be activated"); + ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Test 19e, Doorhanger should start out dismissed"); + EventUtils.synthesizeMouse(plugin, 50, 50, {}, gTestBrowser.contentWindow); - var condition = function() objLoadingContent.activated; + let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; waitForCondition(condition, test19f, "Test 19e, Waited too long for plugin to activate"); } function test19f() { - var doc = gTestBrowser.contentDocument; - var plugin = doc.getElementById("test"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 19f, Plugin should be activated"); - prepareTest(test20a, gTestRoot + "plugin_hidden_to_visible.html"); } // Tests that a plugin in a div that goes from style="display: none" to // "display: block" can be clicked to activate. function test20a() { var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(!clickToPlayNotification, "Test 20a, Should not have a click-to-play notification"); @@ -838,93 +537,101 @@ function test20b() { var doc = gTestBrowser.contentDocument; var plugin = doc.getElementById("plugin"); var pluginRect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect(); ok(pluginRect.width == 200, "Test 20b, plugin should have an overlay with 200px width"); ok(pluginRect.height == 200, "Test 20b, plugin should have an overlay with 200px height"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(!objLoadingContent.activated, "Test 20b, plugin should not be activated"); + ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Test 20b, Doorhanger should start out dismissed"); + EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow); - var condition = function() objLoadingContent.activated; + let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; waitForCondition(condition, test20c, "Test 20b, Waited too long for plugin to activate"); } function test20c() { + PopupNotifications.panel.firstChild._primaryButton.click(); + var doc = gTestBrowser.contentDocument; + var plugin = doc.getElementById("plugin"); + let condition = function() plugin.activated; + waitForCondition(condition, test20d, "Test 20c", "Waiting for plugin to activate"); +} + +function test20d() { var doc = gTestBrowser.contentDocument; var plugin = doc.getElementById("plugin"); var pluginRect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect(); - ok(pluginRect.width == 0, "Test 20c, plugin should have click-to-play overlay with zero width"); - ok(pluginRect.height == 0, "Test 20c, plugin should have click-to-play overlay with zero height"); + ok(pluginRect.width == 0, "Test 20d, plugin should have click-to-play overlay with zero width"); + ok(pluginRect.height == 0, "Test 20d, plugin should have click-to-play overlay with zero height"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 20c, plugin should be activated"); + ok(objLoadingContent.activated, "Test 20d, plugin should be activated"); + + clearAllPluginPermissions(); prepareTest(test21a, gTestRoot + "plugin_two_types.html"); } // Test having multiple different types of plugin on one page function test21a() { var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(notification, "Test 21a, Should have a click-to-play notification"); - ok(notification.options.centerActions.length == 2, "Test 21a, Should have two types of plugin in the notification"); var doc = gTestBrowser.contentDocument; var ids = ["test", "secondtestA", "secondtestB"]; for (var id of ids) { var plugin = doc.getElementById(id); var rect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect(); ok(rect.width == 200, "Test 21a, Plugin with id=" + plugin.id + " overlay rect should have 200px width before being clicked"); ok(rect.height == 200, "Test 21a, Plugin with id=" + plugin.id + " overlay rect should have 200px height before being clicked"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(!objLoadingContent.activated, "Test 21a, Plugin with id=" + plugin.id + " should not be activated"); } // we have to actually show the panel to get the bindings to instantiate - notification.options.eventCallback = test21b; notification.reshow(); -} + is(notification.options.centerActions.length, 2, "Test 21a, Should have two types of plugin in the notification"); -function test21b(type) { - if (type != "shown") { - return; - } - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - notification.options.eventCallback = null; var centerAction = null; for (var action of notification.options.centerActions) { - if (action.message == "Test") { + if (action.pluginName == "Test") { centerAction = action; break; } } ok(centerAction, "Test 21b, found center action for the Test plugin"); var centerItem = null; - for (var item of centerAction.popupnotification.childNodes) { + for (var item of PopupNotifications.panel.firstChild.childNodes) { + is(item.value, "block", "Test 21b, all plugins should start out blocked"); if (item.action == centerAction) { centerItem = item; break; } } ok(centerItem, "Test 21b, found center item for the Test plugin"); // "click" the button to activate the Test plugin - centerItem.runCallback.apply(centerItem); + centerItem.value = "allownow"; + PopupNotifications.panel.firstChild._primaryButton.click(); var doc = gTestBrowser.contentDocument; var plugin = doc.getElementById("test"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); var condition = function() objLoadingContent.activated; waitForCondition(condition, test21c, "Test 21b, Waited too long for plugin to activate"); } function test21c() { var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(notification, "Test 21c, Should have a click-to-play notification"); - ok(notification.options.centerActions.length == 1, "Test 21c, Should have one type of plugin in the notification"); + + notification.reshow(); + ok(notification.options.centerActions.length == 2, "Test 21c, Should have one type of plugin in the notification"); var doc = gTestBrowser.contentDocument; var plugin = doc.getElementById("test"); var rect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect(); ok(rect.width == 0, "Test 21c, Plugin with id=" + plugin.id + " overlay rect should have 0px width after being clicked"); ok(rect.height == 0, "Test 21c, Plugin with id=" + plugin.id + " overlay rect should have 0px height after being clicked"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(objLoadingContent.activated, "Test 21c, Plugin with id=" + plugin.id + " should be activated"); @@ -934,74 +641,66 @@ function test21c() { var plugin = doc.getElementById(id); var rect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect(); ok(rect.width == 200, "Test 21c, Plugin with id=" + plugin.id + " overlay rect should have 200px width before being clicked"); ok(rect.height == 200, "Test 21c, Plugin with id=" + plugin.id + " overlay rect should have 200px height before being clicked"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(!objLoadingContent.activated, "Test 21c, Plugin with id=" + plugin.id + " should not be activated"); } - // we have to actually show the panel to get the bindings to instantiate - notification.options.eventCallback = test21d; - notification.reshow(); -} - -function test21d(type) { - if (type != "shown") { - return; - } - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - notification.options.eventCallback = null; - var centerAction = null; for (var action of notification.options.centerActions) { - if (action.message == "Second Test") { + if (action.pluginName == "Second Test") { centerAction = action; break; } } ok(centerAction, "Test 21d, found center action for the Second Test plugin"); var centerItem = null; - for (var item of centerAction.popupnotification.childNodes) { + for (var item of PopupNotifications.panel.firstChild.childNodes) { if (item.action == centerAction) { + is(item.value, "block", "Test 21d, test plugin 2 should start blocked"); centerItem = item; break; } + else { + is(item.value, "allownow", "Test 21d, test plugin should be enabled"); + } } ok(centerItem, "Test 21d, found center item for the Second Test plugin"); // "click" the button to activate the Second Test plugins - centerItem.runCallback.apply(centerItem); + centerItem.value = "allownow"; + PopupNotifications.panel.firstChild._primaryButton.click(); var doc = gTestBrowser.contentDocument; var plugin = doc.getElementById("secondtestA"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); var condition = function() objLoadingContent.activated; waitForCondition(condition, test21e, "Test 21d, Waited too long for plugin to activate"); } function test21e() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!notification, "Test 21e, Should not have a click-to-play notification"); - var doc = gTestBrowser.contentDocument; var ids = ["test", "secondtestA", "secondtestB"]; for (var id of ids) { var plugin = doc.getElementById(id); var rect = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox").getBoundingClientRect(); ok(rect.width == 0, "Test 21e, Plugin with id=" + plugin.id + " overlay rect should have 0px width after being clicked"); ok(rect.height == 0, "Test 21e, Plugin with id=" + plugin.id + " overlay rect should have 0px height after being clicked"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(objLoadingContent.activated, "Test 21e, Plugin with id=" + plugin.id + " should be activated"); } - Services.prefs.setBoolPref("plugins.click_to_play", true); getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; + + clearAllPluginPermissions(); + prepareTest(test22, gTestRoot + "plugin_test.html"); } // Tests that a click-to-play plugin retains its activated state upon reloading function test22() { ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser), "Test 22, Should have a click-to-play notification"); // Plugin should start as CTP @@ -1069,24 +768,23 @@ function test24a() { ok(notification, "Test 24a, Should have a click-to-play notification"); var plugin = gTestBrowser.contentDocument.getElementById("test"); ok(plugin, "Test 24a, Found plugin in page"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Test 24a, Plugin should be click-to-play"); ok(!objLoadingContent.activated, "Test 24a, plugin should not be activated"); // simulate "always allow" - notification.secondaryActions[0].callback(); + notification.reshow(); + PopupNotifications.panel.firstChild._primaryButton.click(); prepareTest(test24b, gHttpTestRoot + "plugin_test.html"); } // did the "always allow" work as intended? function test24b() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!notification, "Test 24b, Should not have a click-to-play notification"); var plugin = gTestBrowser.contentDocument.getElementById("test"); ok(plugin, "Test 24b, Found plugin in page"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(objLoadingContent.activated, "Test 24b, plugin should be activated"); setAndUpdateBlocklist(gHttpTestRoot + "blockPluginVulnerableUpdatable.xml", function() { prepareTest(test24c, gHttpTestRoot + "plugin_test.html"); }); @@ -1098,91 +796,30 @@ function test24c() { ok(notification, "Test 24c, Should have a click-to-play notification"); var plugin = gTestBrowser.contentDocument.getElementById("test"); ok(plugin, "Test 24c, Found plugin in page"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE, "Test 24c, Plugin should be vulnerable/updatable"); ok(!objLoadingContent.activated, "Test 24c, plugin should not be activated"); // simulate "always allow" - notification.secondaryActions[0].callback(); + notification.reshow(); + PopupNotifications.panel.firstChild._primaryButton.click(); + prepareTest(test24d, gHttpTestRoot + "plugin_test.html"); } // We should still be able to always allow a plugin after we've seen that it's // blocklisted. function test24d() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!notification, "Test 24d, Should not have a click-to-play notification"); var plugin = gTestBrowser.contentDocument.getElementById("test"); ok(plugin, "Test 24d, Found plugin in page"); var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(objLoadingContent.activated, "Test 24d, plugin should be activated"); // this resets the vulnerable plugin permission - Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test")); setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml", function() { - // this resets the normal plugin permission - Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test")); + clearAllPluginPermissions(); resetBlocklist(); - prepareTest(test25a, gHttpTestRoot + "plugin_test.html"); + finishTest(); }); } - -// Test that clicking "always allow" or "always deny" doesn't affect plugins -// that already have permission given to them -function test25a() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(notification, "Test 25a, Should have a click-to-play notification"); - var plugin = gTestBrowser.contentDocument.getElementById("test"); - ok(plugin, "Test 25a, Found plugin in page"); - var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 25a, plugin should not be activated"); - - // simulate "always allow" - notification.secondaryActions[0].callback(); - prepareTest(test25b, gHttpTestRoot + "plugin_two_types.html"); -} - -function test25b() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(notification, "Test 25b, Should have a click-to-play notification"); - - var test = gTestBrowser.contentDocument.getElementById("test"); - ok(test, "Test 25b, Found test plugin in page"); - var objLoadingContent = test.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 25b, test plugin should be activated"); - - var secondtest = gTestBrowser.contentDocument.getElementById("secondtestA"); - ok(secondtest, "Test 25b, Found second test plugin in page"); - var objLoadingContent = secondtest.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 25b, second test plugin should not be activated"); - - // simulate "always deny" - notification.secondaryActions[1].callback(); - prepareTest(test25c, gHttpTestRoot + "plugin_two_types.html"); -} - -// we should have one plugin allowed to activate and the other plugin(s) denied -// (so it should have an invisible overlay) -function test25c() { - var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!notification, "Test 25c, Should not have a click-to-play notification"); - - var test = gTestBrowser.contentDocument.getElementById("test"); - ok(test, "Test 25c, Found test plugin in page"); - var objLoadingContent = test.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "Test 25c, test plugin should be activated"); - - var secondtest = gTestBrowser.contentDocument.getElementById("secondtestA"); - ok(secondtest, "Test 25c, Found second test plugin in page"); - var objLoadingContent = secondtest.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "Test 25c, second test plugin should not be activated"); - is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_DISABLED, "Test 25c, second test plugin should be disabled"); - var overlay = gTestBrowser.contentDocument.getAnonymousElementByAttribute(secondtest, "class", "mainBox"); - ok(overlay.style.visibility != "hidden", "Test 25c, second test plugin should have visible overlay"); - - Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-test")); - Services.perms.remove("127.0.0.1:8888", gPluginHost.getPermissionStringForType("application/x-second-test")); - - finishTest(); -}
--- a/browser/base/content/test/browser_plugins_added_dynamically.js +++ b/browser/base/content/test/browser_plugins_added_dynamically.js @@ -1,32 +1,39 @@ -const gTestRoot = getRootDirectory(gTestPath); +const gTestRoot = "http://mochi.test:8888/browser/browser/base/content/test/"; let gTestBrowser = null; let gNextTest = null; let gPluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost); Components.utils.import("resource://gre/modules/Services.jsm"); +// Let's do the XPCNativeWrapper dance! +function addPlugin(browser, type) { + let contentWindow = XPCNativeWrapper.unwrap(browser.contentWindow); + contentWindow.addPlugin(type); +} + function test() { waitForExplicitFinish(); registerCleanupFunction(function() { + clearAllPluginPermissions(); Services.prefs.clearUserPref("plugins.click_to_play"); getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED; getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_ENABLED; }); Services.prefs.setBoolPref("plugins.click_to_play", true); getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; let newTab = gBrowser.addTab(); gBrowser.selectedTab = newTab; gTestBrowser = gBrowser.selectedBrowser; gTestBrowser.addEventListener("load", pageLoad, true); - prepareTest(testActivateAllPart1, gTestRoot + "plugin_add_dynamically.html"); + prepareTest(testActivateAddSameTypePart1, gTestRoot + "plugin_add_dynamically.html"); } function finishTest() { gTestBrowser.removeEventListener("load", pageLoad, true); gBrowser.removeCurrentTab(); window.focus(); finish(); } @@ -37,216 +44,136 @@ function pageLoad() { executeSoon(gNextTest); } function prepareTest(nextTest, url) { gNextTest = nextTest; gTestBrowser.contentWindow.location = url; } -// "Activate All Plugins" -> plugin of any type dynamically added to the page -// should automatically play -function testActivateAllPart1() { - let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(!popupNotification, "testActivateAllPart1: should not have a click-to-play notification"); - gTestBrowser.contentWindow.addPlugin(); - let condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - waitForCondition(condition, testActivateAllPart2, "testActivateAllPart1: waited too long for click-to-play-plugin notification"); -} - -function testActivateAllPart2() { - let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - ok(popupNotification, "testActivateAllPart2: should have a click-to-play notification"); - let plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0]; - let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "testActivateAllPart2: plugin should not be activated"); - // "click" "Activate All Plugins" - popupNotification.mainAction.callback(); - let condition = function() objLoadingContent.activated; - waitForCondition(condition, testActivateAllPart3, "testActivateAllPart2: waited too long for plugin to activate"); -} - -function testActivateAllPart3() { - let plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0]; - let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "testActivateAllPart3: plugin should be activated"); - - gTestBrowser.contentWindow.addPlugin("application/x-second-test"); - let condition = function() { - let embeds = gTestBrowser.contentDocument.getElementsByTagName("embed"); - for (let embed of embeds) { - let objLoadingContent = embed.QueryInterface(Ci.nsIObjectLoadingContent); - if (embed.type == "application/x-second-test" && objLoadingContent.activated) - return true; - } - return false; - }; - waitForCondition(condition, testActivateAllPart4, "testActivateAllPart3: waited too long for second plugin to activate"); -} - -function testActivateAllPart4() { - let embeds = gTestBrowser.contentDocument.getElementsByTagName("embed"); - for (let embed of embeds) { - let objLoadingContent = embed.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "testActivateAllPart4: all plugins should be activated"); - } - - prepareTest(testActivateAddSameTypePart1, gTestRoot + "plugin_add_dynamically.html"); -} - // "Activate" of a given type -> plugins of that type dynamically added should // automatically play. function testActivateAddSameTypePart1() { let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(!popupNotification, "testActivateAddSameTypePart1: should not have a click-to-play notification"); - gTestBrowser.contentWindow.addPlugin(); + addPlugin(gTestBrowser); let condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); waitForCondition(condition, testActivateAddSameTypePart2, "testActivateAddSameTypePart1: waited too long for click-to-play-plugin notification"); } function testActivateAddSameTypePart2() { let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(popupNotification, "testActivateAddSameTypePart2: should have a click-to-play notification"); - // we have to actually show the panel to get the bindings to instantiate - popupNotification.options.eventCallback = testActivateAddSameTypePart3; popupNotification.reshow(); + testActivateAddSameTypePart3(); } -function testActivateAddSameTypePart3(type) { - if (type != "shown") { - return; - } +function testActivateAddSameTypePart3() { let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - popupNotification.options.eventCallback = null; let centerAction = null; for (let action of popupNotification.options.centerActions) { - if (action.message == "Test") { + if (action.pluginName == "Test") { centerAction = action; break; } } ok(centerAction, "testActivateAddSameTypePart3: found center action for the Test plugin"); let centerItem = null; - for (let item of centerAction.popupnotification.childNodes) { + for (let item of PopupNotifications.panel.firstChild.childNodes) { if (item.action && item.action == centerAction) { centerItem = item; break; } } ok(centerItem, "testActivateAddSameTypePart3: found center item for the Test plugin"); let plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0]; - let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "testActivateAddSameTypePart3: plugin should not be activated"); + ok(!plugin.activated, "testActivateAddSameTypePart3: plugin should not be activated"); - // "click" the button to activate the Test plugin - centerItem.runCallback.apply(centerItem); + // Change the state and click the ok button to activate the Test plugin + centerItem.value = "allownow"; + PopupNotifications.panel.firstChild._primaryButton.click(); - let condition = function() objLoadingContent.activated; + let condition = function() plugin.activated; waitForCondition(condition, testActivateAddSameTypePart4, "testActivateAddSameTypePart3: waited too long for plugin to activate"); } function testActivateAddSameTypePart4() { let plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0]; - let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "testActivateAddSameTypePart4: plugin should be activated"); + ok(plugin.activated, "testActivateAddSameTypePart4: plugin should be activated"); - gTestBrowser.contentWindow.addPlugin(); + addPlugin(gTestBrowser); let condition = function() { let embeds = gTestBrowser.contentDocument.getElementsByTagName("embed"); let allActivated = true; for (let embed of embeds) { - let objLoadingContent = embed.QueryInterface(Ci.nsIObjectLoadingContent); - if (!objLoadingContent.activated) + if (!embed.activated) allActivated = false; } return allActivated && embeds.length == 2; }; waitForCondition(condition, testActivateAddSameTypePart5, "testActivateAddSameTypePart4: waited too long for second plugin to activate"); } function testActivateAddSameTypePart5() { let embeds = gTestBrowser.contentDocument.getElementsByTagName("embed"); for (let embed of embeds) { - let objLoadingContent = embed.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "testActivateAddSameTypePart5: all plugins should be activated"); + ok(embed.activated, "testActivateAddSameTypePart5: all plugins should be activated"); } + clearAllPluginPermissions(); prepareTest(testActivateAddDifferentTypePart1, gTestRoot + "plugin_add_dynamically.html"); } // "Activate" of a given type -> plugins of other types dynamically added // should not automatically play. function testActivateAddDifferentTypePart1() { let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(!popupNotification, "testActivateAddDifferentTypePart1: should not have a click-to-play notification"); - gTestBrowser.contentWindow.addPlugin(); + addPlugin(gTestBrowser); let condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); waitForCondition(condition, testActivateAddDifferentTypePart2, "testActivateAddDifferentTypePart1: waited too long for click-to-play-plugin notification"); } function testActivateAddDifferentTypePart2() { let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); ok(popupNotification, "testActivateAddDifferentTypePart2: should have a click-to-play notification"); // we have to actually show the panel to get the bindings to instantiate - popupNotification.options.eventCallback = testActivateAddDifferentTypePart3; popupNotification.reshow(); + testActivateAddDifferentTypePart3(); } -function testActivateAddDifferentTypePart3(type) { - if (type != "shown") { - return; - } +function testActivateAddDifferentTypePart3() { let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); - popupNotification.options.eventCallback = null; - let centerAction = null; - for (let action of popupNotification.options.centerActions) { - if (action.message == "Test") { - centerAction = action; - break; - } - } - ok(centerAction, "testActivateAddDifferentTypePart3: found center action for the Test plugin"); - - let centerItem = null; - for (let item of centerAction.popupnotification.childNodes) { - if (item.action && item.action == centerAction) { - centerItem = item; - break; - } - } - ok(centerItem, "testActivateAddDifferentTypePart3: found center item for the Test plugin"); + is(popupNotification.options.centerActions.length, 1, "Should be one plugin action"); let plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0]; - let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(!objLoadingContent.activated, "testActivateAddDifferentTypePart3: plugin should not be activated"); + ok(!plugin.activated, "testActivateAddDifferentTypePart3: plugin should not be activated"); // "click" the button to activate the Test plugin - centerItem.runCallback.apply(centerItem); + PopupNotifications.panel.firstChild._primaryButton.click(); - let condition = function() objLoadingContent.activated; + let condition = function() plugin.activated; waitForCondition(condition, testActivateAddDifferentTypePart4, "testActivateAddDifferentTypePart3: waited too long for plugin to activate"); } function testActivateAddDifferentTypePart4() { let plugin = gTestBrowser.contentDocument.getElementsByTagName("embed")[0]; - let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); - ok(objLoadingContent.activated, "testActivateAddDifferentTypePart4: plugin should be activated"); + ok(plugin.activated, "testActivateAddDifferentTypePart4: plugin should be activated"); - gTestBrowser.contentWindow.addPlugin("application/x-second-test"); + addPlugin(gTestBrowser); let condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); waitForCondition(condition, testActivateAddDifferentTypePart5, "testActivateAddDifferentTypePart5: waited too long for popup notification"); } function testActivateAddDifferentTypePart5() { ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser), "testActivateAddDifferentTypePart5: should have popup notification"); let embeds = gTestBrowser.contentDocument.getElementsByTagName("embed"); for (let embed of embeds) { - let objLoadingContent = embed.QueryInterface(Ci.nsIObjectLoadingContent); if (embed.type == "application/x-test") - ok(objLoadingContent.activated, "testActivateAddDifferentTypePart5: Test plugin should be activated"); + ok(embed.activated, "testActivateAddDifferentTypePart5: Test plugin should be activated"); else if (embed.type == "application/x-second-test") - ok(!objLoadingContent.activated, "testActivateAddDifferentTypePart5: Second Test plugin should not be activated"); + ok(!embed.activated, "testActivateAddDifferentTypePart5: Second Test plugin should not be activated"); } finishTest(); }
--- a/browser/base/content/test/head.js +++ b/browser/base/content/test/head.js @@ -106,16 +106,28 @@ function getTestPlugin(aName) { for (var i = 0; i < tags.length; i++) { if (tags[i].name == pluginName) return tags[i]; } ok(false, "Unable to find plugin"); return null; } +// after a test is done using the plugin doorhanger, we should just clear +// any permissions that may have crept in +function clearAllPluginPermissions() { + let perms = Services.perms.enumerator; + while (perms.hasMoreElements()) { + let perm = perms.getNext(); + if (perm.type.startsWith('plugin')) { + Services.perms.remove(perm.host, perm.type); + } + } +} + function updateBlocklist(aCallback) { var blocklistNotifier = Cc["@mozilla.org/extensions/blocklist;1"] .getService(Ci.nsITimerCallback); var observer = function() { Services.obs.removeObserver(observer, "blocklist-updated"); SimpleTest.executeSoon(aCallback); }; Services.obs.addObserver(observer, "blocklist-updated", false);
deleted file mode 100644 --- a/browser/base/content/test/plugin_bug818009.html +++ /dev/null @@ -1,8 +0,0 @@ -<!DOCTYPE html> -<head><meta charset="utf8"/></head> -<body> -<object id="outer" width="200" height="200"> - <embed id="inner" width="200" height="200" type="application/x-test"/> -</object> -</body> -</html>
--- a/browser/base/content/test/plugin_bug820497.html +++ b/browser/base/content/test/plugin_bug820497.html @@ -1,12 +1,12 @@ <!DOCTYPE html> <html> <head><meta charset="utf-8"/></head> -<body onload="addSecondPlugin()"> +<body> <object id="test" type="application/x-test" width=200 height=200></object> <script> function addSecondPlugin() { var object = document.createElement("object"); object.type = "application/x-second-test"; object.width = 200; object.height = 200; object.id = "secondtest";
deleted file mode 100644 --- a/browser/base/content/test/plugin_test_noScriptNoPopup.html +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE html> -<html> -<head><meta charset="utf-8"></head> -<body> -<embed id="test" type="application/x-test"/> -</body> -</html>
deleted file mode 100644 --- a/browser/base/content/test/plugin_test_scriptedNoPopup1.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE html> -<html> -<head><meta charset="utf-8"></head> -<body onload="scriptPlugin()"> -<embed id="test" type="application/x-test"/> -<embed id="test-visible" type="application/x-test" width=200 height=200/> -<script> - function scriptPlugin() { - try { - document.getElementById("test").getObjectValue(); - } - catch (e) {} - } -</script> -</body> -</html>
deleted file mode 100644 --- a/browser/base/content/test/plugin_test_scriptedNoPopup2.html +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE html> -<html> -<head><meta charset="utf-8"></head> -<body onload="scriptPlugin()"> -<div style="width: 200px; height: 200px;"> - <embed id="test" style="width: inherit; height: inherit;" type="application/x-test"/> -</div> -<script> - function scriptPlugin() { - try { - document.getElementById("test").getObjectValue(); - } - catch (e) {} - } -</script> -</body> -</html>
deleted file mode 100644 --- a/browser/base/content/test/plugin_test_scriptedNoPopup3.html +++ /dev/null @@ -1,23 +0,0 @@ -<!DOCTYPE html> -<html> -<head><meta charset="utf-8"></head> -<body onload="scriptPlugin()"> -<div id="container" style="width: 0px; height: 0px;"> - <embed id="test" style="width: inherit; height: inherit;" type="application/x-test"/> -</div> -<script> - function scriptPlugin() { - try { - document.getElementById("test").getObjectValue(); - } - catch (e) {} - - setTimeout(function() { - var container = document.getElementById("container"); - container.style.width = "200px"; - container.style.height = "200px"; - }, 10); - } -</script> -</body> -</html>
deleted file mode 100644 --- a/browser/base/content/test/plugin_test_scriptedPopup1.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE html> -<html> -<head><meta charset="utf-8"></head> -<body onload="scriptPlugin()"> -<embed id="test" type="application/x-test"/> -<script> - var gScriptingFinished = false; - function scriptPlugin() { - try { - document.getElementById("test").getObjectValue(); - } - catch (e) { - setTimeout(function() { gScriptingFinished = true; }, 0); - } - } -</script> -</body> -</html>
deleted file mode 100644 --- a/browser/base/content/test/plugin_test_scriptedPopup2.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE html> -<html> -<head><meta charset="utf-8"></head> -<body onload="scriptPlugin()"> -<embed id="test" type="application/x-test" width=0 height=0/> -<embed id="test2" type="application/x-test" width=1 height=1/> -<script> - function scriptPlugin() { - try { - document.getElementById("test").getObjectValue(); - } - catch (e) {} - } -</script> -</body> -</html>
deleted file mode 100644 --- a/browser/base/content/test/plugin_test_scriptedPopup3.html +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE html> -<html> -<head><meta charset="utf-8"></head> -<body onload="scriptPlugin()"> -<div id="container" style="width: 0px; height: 0px;"> - <embed id="test" style="width: inherit; height: inherit;" type="application/x-test"/> -</div> -<script> - function scriptPlugin() { - try { - document.getElementById("test").getObjectValue(); - } - catch (e) {} - } -</script> -</body> -</html>
--- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -1475,16 +1475,20 @@ link.hidden = true; } ]]></constructor> <property name="value"> <getter> return document.getAnonymousElementByAttribute(this, "anonid", "center-item-menulist").value; </getter> + <setter><!-- This should be used only in automated tests --> + document.getAnonymousElementByAttribute(this, "anonid", + "center-item-menulist").value = val; + </setter> </property> </implementation> </binding> <binding id="click-to-play-plugins-notification" extends="chrome://global/content/bindings/notification.xml#popup-notification"> <content align="start" class="click-to-play-plugins-notification-content"> <xul:vbox flex="1" align="stretch" class="popup-notification-main-box" xbl:inherits="popupid">
--- a/dom/plugins/test/mochitest/test_bug751809.html +++ b/dom/plugins/test/mochitest/test_bug751809.html @@ -58,18 +58,19 @@ var objLoadingContent = SpecialPowers.wrap(plugin); ok(!objLoadingContent.activated, "plugin should not be activated"); SimpleTest.waitForFocus(afterWindowFocus); } function afterWindowFocus() { var plugin = document.getElementById('plugin'); + var objLoadingContent = SpecialPowers.wrap(plugin); - synthesizeMouseAtCenter(plugin, {}); + objLoadingContent.playPlugin(); var condition = function() plugin.setColor !== undefined; waitForCondition(condition, afterPluginActivation, "Waited too long for plugin to activate"); } function afterPluginActivation() { var plugin = document.getElementById('plugin'); var objLoadingContent = SpecialPowers.wrap(plugin); ok(objLoadingContent.activated, "plugin should be activated now");
--- a/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js +++ b/toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js @@ -113,17 +113,17 @@ function part6() { neverActivateItem.doCommand(); gBrowser.selectedTab = gBrowser.addTab(); gPluginBrowser = gBrowser.selectedBrowser; gPluginBrowser.addEventListener("PluginBindingAttached", part7, true, true); gPluginBrowser.contentWindow.location = gHttpTestRoot + "plugin_test.html"; } function part7() { - ok(!PopupNotifications.getNotification("click-to-play-plugins", gPluginBrowser), "part7: should not have a click-to-play notification"); + ok(PopupNotifications.getNotification("click-to-play-plugins", gPluginBrowser), "part7: disabled plugins still show a notification"); let testPlugin = gPluginBrowser.contentDocument.getElementById("test"); ok(testPlugin, "part7: should have a plugin element in the page"); let objLoadingContent = testPlugin.QueryInterface(Ci.nsIObjectLoadingContent); ok(!objLoadingContent.activated, "part7: plugin should not be activated"); gPluginBrowser.removeEventListener("PluginBindingAttached", part7); gBrowser.removeCurrentTab();