michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: var gTestBrowser = null; michael@0: var gNumPluginBindingsAttached = 0; 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("PluginBindingAttached", pluginBindingAttached, true, true); michael@0: gBrowser.removeCurrentTab(); michael@0: window.focus(); 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("PluginBindingAttached", pluginBindingAttached, true, true); michael@0: var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); michael@0: gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug744745.html"; michael@0: } michael@0: michael@0: function pluginBindingAttached() { michael@0: gNumPluginBindingsAttached++; michael@0: michael@0: if (gNumPluginBindingsAttached == 1) { michael@0: var doc = gTestBrowser.contentDocument; michael@0: var testplugin = doc.getElementById("test"); michael@0: ok(testplugin, "should have test plugin"); michael@0: var style = getComputedStyle(testplugin); michael@0: ok('opacity' in style, "style should have opacity set"); michael@0: is(style.opacity, 1, "opacity should be 1"); michael@0: finish(); michael@0: } else { michael@0: ok(false, "if we've gotten here, something is quite wrong"); michael@0: } michael@0: }