michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: var rootDir = getRootDirectory(gTestPath); michael@0: const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: var gTestBrowser = null; michael@0: var gConsoleErrors = 0; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: var newTab = gBrowser.addTab(); michael@0: gBrowser.selectedTab = newTab; michael@0: gTestBrowser = gBrowser.selectedBrowser; michael@0: gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true); michael@0: var consoleService = Cc["@mozilla.org/consoleservice;1"] michael@0: .getService(Ci.nsIConsoleService); michael@0: var errorListener = { michael@0: observe: function(aMessage) { michael@0: if (aMessage.message.contains("NS_ERROR")) michael@0: gConsoleErrors++; michael@0: } michael@0: }; michael@0: consoleService.registerListener(errorListener); michael@0: registerCleanupFunction(function() { michael@0: gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true); michael@0: consoleService.unregisterListener(errorListener); michael@0: gBrowser.removeCurrentTab(); michael@0: window.focus(); michael@0: }); michael@0: gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug797677.html"; michael@0: } michael@0: michael@0: function pluginBindingAttached() { michael@0: // Let browser-plugins.js handle the PluginNotFound event, then run the test michael@0: executeSoon(runTest); michael@0: } michael@0: michael@0: function runTest() { michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("plugin"); michael@0: ok(plugin, "plugin should be in the page"); michael@0: is(gConsoleErrors, 0, "should have no console errors"); michael@0: finish(); michael@0: }