Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
2 var gTestBrowser = null;
4 Components.utils.import("resource://gre/modules/Services.jsm");
6 function test() {
7 waitForExplicitFinish();
8 registerCleanupFunction(function() {
9 Services.prefs.clearUserPref("plugins.click_to_play");
10 gTestBrowser.removeEventListener("load", pageLoad, true);
11 });
13 Services.prefs.setBoolPref("plugins.click_to_play", true);
14 setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
16 gBrowser.selectedTab = gBrowser.addTab();
17 gTestBrowser = gBrowser.selectedBrowser;
18 gTestBrowser.addEventListener("load", pageLoad, true);
19 gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_both.html";
20 }
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 }
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");
39 var unknown = gTestBrowser.contentDocument.getElementById("unknown");
40 ok(unknown, "should have unknown plugin in page");
42 gBrowser.removeCurrentTab();
43 window.focus();
44 finish();
45 }