browser/base/content/test/plugins/browser_bug797677.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 rootDir = getRootDirectory(gTestPath);
     6 const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
     7 const Cc = Components.classes;
     8 const Ci = Components.interfaces;
     9 var gTestBrowser = null;
    10 var gConsoleErrors = 0;
    12 function test() {
    13   waitForExplicitFinish();
    14   var newTab = gBrowser.addTab();
    15   gBrowser.selectedTab = newTab;
    16   gTestBrowser = gBrowser.selectedBrowser;
    17   gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
    18   var consoleService = Cc["@mozilla.org/consoleservice;1"]
    19                          .getService(Ci.nsIConsoleService);
    20   var errorListener = {
    21     observe: function(aMessage) {
    22       if (aMessage.message.contains("NS_ERROR"))
    23         gConsoleErrors++;
    24     }
    25   };
    26   consoleService.registerListener(errorListener);
    27   registerCleanupFunction(function() {
    28     gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true);
    29     consoleService.unregisterListener(errorListener);
    30     gBrowser.removeCurrentTab();
    31     window.focus();
    32   });
    33   gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug797677.html";
    34 }
    36 function pluginBindingAttached() {
    37   // Let browser-plugins.js handle the PluginNotFound event, then run the test
    38   executeSoon(runTest);
    39 }
    41 function runTest() {
    42   var doc = gTestBrowser.contentDocument;
    43   var plugin = doc.getElementById("plugin");
    44   ok(plugin, "plugin should be in the page");
    45   is(gConsoleErrors, 0, "should have no console errors");
    46   finish();
    47 }

mercurial