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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     5 var gTestBrowser = null;
     6 var gNumPluginBindingsAttached = 0;
     8 Components.utils.import("resource://gre/modules/Services.jsm");
    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   });
    19   Services.prefs.setBoolPref("plugins.click_to_play", true);
    20   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
    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 }
    29 function pluginBindingAttached() {
    30   gNumPluginBindingsAttached++;
    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