browser/base/content/test/plugins/browser_bug744745.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.

     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