1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/plugins/browser_bug818118.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,45 @@ 1.4 +var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); 1.5 +var gTestBrowser = null; 1.6 + 1.7 +Components.utils.import("resource://gre/modules/Services.jsm"); 1.8 + 1.9 +function test() { 1.10 + waitForExplicitFinish(); 1.11 + registerCleanupFunction(function() { 1.12 + Services.prefs.clearUserPref("plugins.click_to_play"); 1.13 + gTestBrowser.removeEventListener("load", pageLoad, true); 1.14 + }); 1.15 + 1.16 + Services.prefs.setBoolPref("plugins.click_to_play", true); 1.17 + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); 1.18 + 1.19 + gBrowser.selectedTab = gBrowser.addTab(); 1.20 + gTestBrowser = gBrowser.selectedBrowser; 1.21 + gTestBrowser.addEventListener("load", pageLoad, true); 1.22 + gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_both.html"; 1.23 +} 1.24 + 1.25 +function pageLoad(aEvent) { 1.26 + // Due to layout being async, "PluginBindAttached" may trigger later. 1.27 + // This forces a layout flush, thus triggering it, and schedules the 1.28 + // test so it is definitely executed afterwards. 1.29 + gTestBrowser.contentDocument.getElementById('test').clientTop; 1.30 + executeSoon(actualTest); 1.31 +} 1.32 + 1.33 +function actualTest() { 1.34 + var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); 1.35 + ok(popupNotification, "should have a click-to-play notification"); 1.36 + var plugin = gTestBrowser.contentDocument.getElementById("test"); 1.37 + ok(plugin, "should have known plugin in page"); 1.38 + var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); 1.39 + is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "plugin fallback type should be PLUGIN_CLICK_TO_PLAY"); 1.40 + ok(!objLoadingContent.activated, "plugin should not be activated"); 1.41 + 1.42 + var unknown = gTestBrowser.contentDocument.getElementById("unknown"); 1.43 + ok(unknown, "should have unknown plugin in page"); 1.44 + 1.45 + gBrowser.removeCurrentTab(); 1.46 + window.focus(); 1.47 + finish(); 1.48 +}