browser/base/content/test/plugins/browser_bug818118.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial