1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/plugins/browser_bug797677.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 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 rootDir = getRootDirectory(gTestPath); 1.9 +const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); 1.10 +const Cc = Components.classes; 1.11 +const Ci = Components.interfaces; 1.12 +var gTestBrowser = null; 1.13 +var gConsoleErrors = 0; 1.14 + 1.15 +function test() { 1.16 + waitForExplicitFinish(); 1.17 + var newTab = gBrowser.addTab(); 1.18 + gBrowser.selectedTab = newTab; 1.19 + gTestBrowser = gBrowser.selectedBrowser; 1.20 + gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true); 1.21 + var consoleService = Cc["@mozilla.org/consoleservice;1"] 1.22 + .getService(Ci.nsIConsoleService); 1.23 + var errorListener = { 1.24 + observe: function(aMessage) { 1.25 + if (aMessage.message.contains("NS_ERROR")) 1.26 + gConsoleErrors++; 1.27 + } 1.28 + }; 1.29 + consoleService.registerListener(errorListener); 1.30 + registerCleanupFunction(function() { 1.31 + gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true); 1.32 + consoleService.unregisterListener(errorListener); 1.33 + gBrowser.removeCurrentTab(); 1.34 + window.focus(); 1.35 + }); 1.36 + gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug797677.html"; 1.37 +} 1.38 + 1.39 +function pluginBindingAttached() { 1.40 + // Let browser-plugins.js handle the PluginNotFound event, then run the test 1.41 + executeSoon(runTest); 1.42 +} 1.43 + 1.44 +function runTest() { 1.45 + var doc = gTestBrowser.contentDocument; 1.46 + var plugin = doc.getElementById("plugin"); 1.47 + ok(plugin, "plugin should be in the page"); 1.48 + is(gConsoleErrors, 0, "should have no console errors"); 1.49 + finish(); 1.50 +}