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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:6c54696c81f5
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 var gTestBrowser = null;
6 var gNumPluginBindingsAttached = 0;
7
8 Components.utils.import("resource://gre/modules/Services.jsm");
9
10 function test() {
11 waitForExplicitFinish();
12 registerCleanupFunction(function() {
13 Services.prefs.clearUserPref("plugins.click_to_play");
14 gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
15 gBrowser.removeCurrentTab();
16 window.focus();
17 });
18
19 Services.prefs.setBoolPref("plugins.click_to_play", true);
20 setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
21
22 gBrowser.selectedTab = gBrowser.addTab();
23 gTestBrowser = gBrowser.selectedBrowser;
24 gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
25 var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
26 gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug744745.html";
27 }
28
29 function pluginBindingAttached() {
30 gNumPluginBindingsAttached++;
31
32 if (gNumPluginBindingsAttached == 1) {
33 var doc = gTestBrowser.contentDocument;
34 var testplugin = doc.getElementById("test");
35 ok(testplugin, "should have test plugin");
36 var style = getComputedStyle(testplugin);
37 ok('opacity' in style, "style should have opacity set");
38 is(style.opacity, 1, "opacity should be 1");
39 finish();
40 } else {
41 ok(false, "if we've gotten here, something is quite wrong");
42 }
43 }

mercurial