|
1 var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); |
|
2 var gTestBrowser = null; |
|
3 |
|
4 Components.utils.import("resource://gre/modules/Services.jsm"); |
|
5 |
|
6 function test() { |
|
7 waitForExplicitFinish(); |
|
8 registerCleanupFunction(function() { |
|
9 Services.prefs.clearUserPref("plugins.click_to_play"); |
|
10 gTestBrowser.removeEventListener("load", pageLoad, true); |
|
11 }); |
|
12 |
|
13 Services.prefs.setBoolPref("plugins.click_to_play", true); |
|
14 setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); |
|
15 |
|
16 gBrowser.selectedTab = gBrowser.addTab(); |
|
17 gTestBrowser = gBrowser.selectedBrowser; |
|
18 gTestBrowser.addEventListener("load", pageLoad, true); |
|
19 gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_both.html"; |
|
20 } |
|
21 |
|
22 function pageLoad(aEvent) { |
|
23 // Due to layout being async, "PluginBindAttached" may trigger later. |
|
24 // This forces a layout flush, thus triggering it, and schedules the |
|
25 // test so it is definitely executed afterwards. |
|
26 gTestBrowser.contentDocument.getElementById('test').clientTop; |
|
27 executeSoon(actualTest); |
|
28 } |
|
29 |
|
30 function actualTest() { |
|
31 var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); |
|
32 ok(popupNotification, "should have a click-to-play notification"); |
|
33 var plugin = gTestBrowser.contentDocument.getElementById("test"); |
|
34 ok(plugin, "should have known plugin in page"); |
|
35 var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); |
|
36 is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "plugin fallback type should be PLUGIN_CLICK_TO_PLAY"); |
|
37 ok(!objLoadingContent.activated, "plugin should not be activated"); |
|
38 |
|
39 var unknown = gTestBrowser.contentDocument.getElementById("unknown"); |
|
40 ok(unknown, "should have unknown plugin in page"); |
|
41 |
|
42 gBrowser.removeCurrentTab(); |
|
43 window.focus(); |
|
44 finish(); |
|
45 } |