Bug 1110887 - Update browser_globalplugin_crashinfobar.js to work with e10s changes. r=felipe.
authorMike Conley <mconley@mozilla.com>
Fri, 27 Mar 2015 23:22:47 -0400
changeset 257367 c29695f586bba38b1046dbee9f5dfc3085bf8483
parent 257366 db237a68215f8706c3e8528a36b7ea08161de4f3
child 257368 21d7e9b0c0dbd61e385384004e2c05b1fe9afdc3
push id8007
push userraliiev@mozilla.com
push dateMon, 11 May 2015 19:23:16 +0000
treeherdermozilla-aurora@e2ce1aac996e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs1110887
milestone40.0a1
Bug 1110887 - Update browser_globalplugin_crashinfobar.js to work with e10s changes. r=felipe.
browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
--- a/browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
+++ b/browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
@@ -1,62 +1,40 @@
 /* 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/. */
 
-let gTestBrowser = null;
-
-let crashedEventProperties = {
-  pluginName: "GlobalTestPlugin",
-  pluginDumpID: "1234",
-  browserDumpID: "5678",
-  submittedCrashReport: false,
-  bubbles: true,
-  cancelable: true
-}
-
-// Test that plugin crash submissions still work properly after
-// click-to-play activation.
-
-function test() {
-  waitForExplicitFinish();
-  let tab = gBrowser.loadOneTab("about:blank", { inBackground: false });
-  gTestBrowser = gBrowser.getBrowserForTab(tab);
-  gTestBrowser.addEventListener("PluginCrashed", onCrash, false);
-  gTestBrowser.addEventListener("load", onPageLoad, true);
-
-  registerCleanupFunction(function cleanUp() {
-    gTestBrowser.removeEventListener("PluginCrashed", onCrash, false);
-    gTestBrowser.removeEventListener("load", onPageLoad, true);
-    gBrowser.removeTab(tab);
-  });
-}
+/**
+ * Test that plugin crash submissions still work properly after
+ * click-to-play activation.
+ */
+add_task(function*() {
+  yield BrowserTestUtils.withNewTab({
+    gBrowser,
+    url: "about:blank",
+  }, function* (browser) {
+    yield ContentTask.spawn(browser, null, function* () {
+      const GMP_CRASH_EVENT = {
+        pluginName: "GlobalTestPlugin",
+        pluginDumpID: "1234",
+        browserDumpID: "5678",
+        submittedCrashReport: false,
+        bubbles: true,
+        cancelable: true,
+        gmpPlugin: true,
+      };
 
-function onPageLoad() {
-  executeSoon(generateCrashEvent);
-}
+      let crashEvent = new content.PluginCrashedEvent("PluginCrashed",
+                                                      GMP_CRASH_EVENT);
+      content.dispatchEvent(crashEvent);
+    });
 
-function generateCrashEvent() {
-  let window = gTestBrowser.contentWindow;
-  let crashedEvent = new window.PluginCrashedEvent("PluginCrashed", crashedEventProperties);
-
-  window.dispatchEvent(crashedEvent);
-}
-
+    let notification = yield waitForNotificationBar("plugin-crashed", browser);
 
-function onCrash(event) {
-  let target = event.target;
-  is (target, gTestBrowser.contentWindow, "Event target is the window.");
-
-  for (let [name, val] of Iterator(crashedEventProperties)) {
-    let propVal = event[name];
-
-    is (propVal, val, "Correct property: " + name + ".");
-  }
-
-  waitForNotificationBar("plugin-crashed", gTestBrowser, (notification) => {
-    let notificationBox = gBrowser.getNotificationBox(gTestBrowser);
+    let notificationBox = gBrowser.getNotificationBox(browser);
     ok(notification, "Infobar was shown.");
-    is(notification.priority, notificationBox.PRIORITY_WARNING_MEDIUM, "Correct priority.");
-    is(notification.getAttribute("label"), "The GlobalTestPlugin plugin has crashed.", "Correct message.");
-    finish();
+    is(notification.priority, notificationBox.PRIORITY_WARNING_MEDIUM,
+       "Correct priority.");
+    is(notification.getAttribute("label"),
+       "The GlobalTestPlugin plugin has crashed.",
+       "Correct message.");
   });
-}
+});