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.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 var rootDir = getRootDirectory(gTestPath);
michael@0 6 const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
michael@0 7 const Cc = Components.classes;
michael@0 8 const Ci = Components.interfaces;
michael@0 9 var gTestBrowser = null;
michael@0 10 var gConsoleErrors = 0;
michael@0 11
michael@0 12 function test() {
michael@0 13 waitForExplicitFinish();
michael@0 14 var newTab = gBrowser.addTab();
michael@0 15 gBrowser.selectedTab = newTab;
michael@0 16 gTestBrowser = gBrowser.selectedBrowser;
michael@0 17 gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
michael@0 18 var consoleService = Cc["@mozilla.org/consoleservice;1"]
michael@0 19 .getService(Ci.nsIConsoleService);
michael@0 20 var errorListener = {
michael@0 21 observe: function(aMessage) {
michael@0 22 if (aMessage.message.contains("NS_ERROR"))
michael@0 23 gConsoleErrors++;
michael@0 24 }
michael@0 25 };
michael@0 26 consoleService.registerListener(errorListener);
michael@0 27 registerCleanupFunction(function() {
michael@0 28 gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true);
michael@0 29 consoleService.unregisterListener(errorListener);
michael@0 30 gBrowser.removeCurrentTab();
michael@0 31 window.focus();
michael@0 32 });
michael@0 33 gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug797677.html";
michael@0 34 }
michael@0 35
michael@0 36 function pluginBindingAttached() {
michael@0 37 // Let browser-plugins.js handle the PluginNotFound event, then run the test
michael@0 38 executeSoon(runTest);
michael@0 39 }
michael@0 40
michael@0 41 function runTest() {
michael@0 42 var doc = gTestBrowser.contentDocument;
michael@0 43 var plugin = doc.getElementById("plugin");
michael@0 44 ok(plugin, "plugin should be in the page");
michael@0 45 is(gConsoleErrors, 0, "should have no console errors");
michael@0 46 finish();
michael@0 47 }

mercurial