|
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/. */ |
|
4 |
|
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; |
|
11 |
|
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 } |
|
35 |
|
36 function pluginBindingAttached() { |
|
37 // Let browser-plugins.js handle the PluginNotFound event, then run the test |
|
38 executeSoon(runTest); |
|
39 } |
|
40 |
|
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 } |