michael@0: var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); michael@0: var gTestBrowser = null; michael@0: michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: registerCleanupFunction(function() { michael@0: Services.prefs.clearUserPref("plugins.click_to_play"); michael@0: gTestBrowser.removeEventListener("load", pageLoad, true); michael@0: }); michael@0: michael@0: Services.prefs.setBoolPref("plugins.click_to_play", true); michael@0: setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gTestBrowser = gBrowser.selectedBrowser; michael@0: gTestBrowser.addEventListener("load", pageLoad, true); michael@0: gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_both.html"; michael@0: } michael@0: michael@0: function pageLoad(aEvent) { michael@0: // Due to layout being async, "PluginBindAttached" may trigger later. michael@0: // This forces a layout flush, thus triggering it, and schedules the michael@0: // test so it is definitely executed afterwards. michael@0: gTestBrowser.contentDocument.getElementById('test').clientTop; michael@0: executeSoon(actualTest); michael@0: } michael@0: michael@0: function actualTest() { michael@0: var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(popupNotification, "should have a click-to-play notification"); michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(plugin, "should have known plugin in page"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "plugin fallback type should be PLUGIN_CLICK_TO_PLAY"); michael@0: ok(!objLoadingContent.activated, "plugin should not be activated"); michael@0: michael@0: var unknown = gTestBrowser.contentDocument.getElementById("unknown"); michael@0: ok(unknown, "should have unknown plugin in page"); michael@0: michael@0: gBrowser.removeCurrentTab(); michael@0: window.focus(); michael@0: finish(); michael@0: }