Bug 798237 - Add test for bug 797677. r=jaws, a=test-only
authorDavid Keeler <dkeeler@mozilla.com>
Mon, 08 Oct 2012 10:01:19 -0700
changeset 117050 03f06a061206c6a5e28cbe7493ac02d983bc3fa0
parent 117049 0996d275581dabdee6f9c37980de2151137055b4
child 117051 fc9677f8a2f653326147dc52fde22b81d41a2699
push id1730
push userryanvm@gmail.com
push dateWed, 21 Nov 2012 23:19:47 +0000
treeherdermozilla-beta@9b66328a0d4e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, test-only
bugs798237, 797677
milestone18.0
Bug 798237 - Add test for bug 797677. r=jaws, a=test-only
browser/base/content/test/Makefile.in
browser/base/content/test/browser_bug797677.js
browser/base/content/test/plugin_bug797677.html
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -155,16 +155,17 @@ endif
                  browser_bug719271.js \
                  browser_bug724239.js \
                  browser_bug735471.js \
                  browser_bug743421.js \
                  browser_bug749738.js \
                  browser_bug763468.js \
                  browser_bug767836.js \
                  browser_bug783614.js \
+                 browser_bug797677.js \
                  browser_canonizeURL.js \
                  browser_customize.js \
                  browser_findbarClose.js \
                  browser_homeDrop.js \
                  browser_keywordBookmarklets.js \
                  browser_contextSearchTabPosition.js \
                  browser_ctrlTab.js \
                  browser_customize_popupNotification.js \
@@ -237,16 +238,17 @@ endif
                  plugin_test3.html \
                  plugin_alternate_content.html \
                  plugin_both.html \
                  plugin_both2.html \
                  plugin_bug743421.html \
                  plugin_clickToPlayAllow.html \
                  plugin_clickToPlayDeny.html \
                  plugin_bug749455.html \
+                 plugin_bug797677.html \
                  plugin_hidden_to_visible.html \
                  plugin_two_types.html \
                  alltabslistener.html \
                  zoom_test.html \
                  dummy_page.html \
                  browser_tabMatchesInAwesomebar.js \
                  file_bug550565_popup.html \
                  file_bug550565_favicon.ico \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_bug797677.js
@@ -0,0 +1,47 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ *  License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var rootDir = getRootDirectory(gTestPath);
+const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+var gTestBrowser = null;
+var gConsoleErrors = 0;
+
+function test() {
+  waitForExplicitFinish();
+  var newTab = gBrowser.addTab();
+  gBrowser.selectedTab = newTab;
+  gTestBrowser = gBrowser.selectedBrowser;
+  gTestBrowser.addEventListener("PluginNotFound", pluginNotFound, true);
+  var consoleService = Cc["@mozilla.org/consoleservice;1"]
+                         .getService(Ci.nsIConsoleService);
+  var errorListener = {
+    observe: function(aMessage) {
+      if (aMessage.message.contains("NS_ERROR"))
+        gConsoleErrors++;
+    }
+  };
+  consoleService.registerListener(errorListener);
+  registerCleanupFunction(function() {
+    gTestBrowser.removeEventListener("PluginNotFound", pluginNotFound, true);
+    consoleService.unregisterListener(errorListener);
+    gBrowser.removeCurrentTab();
+    window.focus();
+  });
+  gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug797677.html";
+}
+
+function pluginNotFound() {
+  // Let browser-plugins.js handle the PluginNotFound event, then run the test
+  executeSoon(runTest);
+}
+
+function runTest() {
+  var doc = gTestBrowser.contentDocument;
+  var plugin = doc.getElementById("plugin");
+  ok(plugin, "plugin should be in the page");
+  is(gConsoleErrors, 0, "should have no console errors");
+  finish();
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/plugin_bug797677.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<html>
+<head><meta charset="utf-8"/></head>
+<body><embed id="plugin" type="9000"></embed></body>
+</html>