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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/plugins/browser_bug744745.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + *  License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +var gTestBrowser = null;
     1.9 +var gNumPluginBindingsAttached = 0;
    1.10 +
    1.11 +Components.utils.import("resource://gre/modules/Services.jsm");
    1.12 +
    1.13 +function test() {
    1.14 +  waitForExplicitFinish();
    1.15 +  registerCleanupFunction(function() {
    1.16 +    Services.prefs.clearUserPref("plugins.click_to_play");
    1.17 +    gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
    1.18 +    gBrowser.removeCurrentTab();
    1.19 +    window.focus();
    1.20 +  });
    1.21 +
    1.22 +  Services.prefs.setBoolPref("plugins.click_to_play", true);
    1.23 +  setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
    1.24 +
    1.25 +  gBrowser.selectedTab = gBrowser.addTab();
    1.26 +  gTestBrowser = gBrowser.selectedBrowser;
    1.27 +  gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
    1.28 +  var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
    1.29 +  gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug744745.html";
    1.30 +}
    1.31 +
    1.32 +function pluginBindingAttached() {
    1.33 +  gNumPluginBindingsAttached++;
    1.34 +
    1.35 +  if (gNumPluginBindingsAttached == 1) {
    1.36 +    var doc = gTestBrowser.contentDocument;
    1.37 +    var testplugin = doc.getElementById("test");
    1.38 +    ok(testplugin, "should have test plugin");
    1.39 +    var style = getComputedStyle(testplugin);
    1.40 +    ok('opacity' in style, "style should have opacity set");
    1.41 +    is(style.opacity, 1, "opacity should be 1");
    1.42 +    finish();
    1.43 +  } else {
    1.44 +    ok(false, "if we've gotten here, something is quite wrong");
    1.45 +  }
    1.46 +}

mercurial