Bug 1246044 - Part 3 - Add unit tests for uninstall bug. r=kmag
authorMatthew Wein <mwein@mozilla.com>
Tue, 05 Jul 2016 16:56:52 -0700
changeset 304224 db20be5bef8a1449096d781eed91ecd95ca6c755
parent 304223 2eb259ef14485698685bff5b4b6c0961a1e0739c
child 304225 811b5f9b7ae8548ca59f692e64f9e64bfdac132c
push id30418
push userkwierso@gmail.com
push dateFri, 08 Jul 2016 22:02:34 +0000
treeherdermozilla-central@bbb29a9b88dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1246044
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1246044 - Part 3 - Add unit tests for uninstall bug. r=kmag MozReview-Commit-ID: JA10PnhFObL
browser/components/extensions/test/browser/browser.ini
browser/components/extensions/test/browser/browser_ext_contextMenus_uninstall.js
--- a/browser/components/extensions/test/browser/browser.ini
+++ b/browser/components/extensions/test/browser/browser.ini
@@ -25,16 +25,17 @@ support-files =
 [browser_ext_browserAction_simple.js]
 [browser_ext_commands_execute_page_action.js]
 [browser_ext_commands_getAll.js]
 [browser_ext_commands_onCommand.js]
 [browser_ext_contentscript_connect.js]
 [browser_ext_contextMenus.js]
 [browser_ext_contextMenus_checkboxes.js]
 [browser_ext_contextMenus_radioGroups.js]
+[browser_ext_contextMenus_uninstall.js]
 [browser_ext_currentWindow.js]
 [browser_ext_getViews.js]
 [browser_ext_history.js]
 [browser_ext_incognito_popup.js]
 [browser_ext_lastError.js]
 [browser_ext_optionsPage_privileges.js]
 [browser_ext_pageAction_context.js]
 [browser_ext_pageAction_popup.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/test/browser/browser_ext_contextMenus_uninstall.js
@@ -0,0 +1,84 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+add_task(function* () {
+  let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser,
+    "http://mochi.test:8888/browser/browser/components/extensions/test/browser/context.html");
+
+  // Install an extension.
+  let extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      "permissions": ["contextMenus"],
+    },
+
+    background: function() {
+      browser.contextMenus.create({title: "a"});
+      browser.contextMenus.create({title: "b"});
+      browser.test.notifyPass("contextmenus-icons");
+    },
+  });
+
+  yield extension.startup();
+  yield extension.awaitFinish("contextmenus-icons");
+
+  // Open the context menu.
+  let contextMenu = yield openContextMenu("#img1");
+
+  // Confirm that the extension menu item exists.
+  let topLevelExtensionMenuItems = contextMenu.getElementsByAttribute("ext-type", "top-level-menu");
+  is(topLevelExtensionMenuItems.length, 1, "the top level extension menu item exists");
+
+  yield closeContextMenu();
+
+  // Uninstall the extension.
+  yield extension.unload();
+
+  // Open the context menu.
+  contextMenu = yield openContextMenu("#img1");
+
+  // Confirm that the extension menu item has been removed.
+  topLevelExtensionMenuItems = contextMenu.getElementsByAttribute("ext-type", "top-level-menu");
+  is(topLevelExtensionMenuItems.length, 0, "no top level extension menu items should exist");
+
+  yield closeContextMenu();
+
+  // Install a new extension.
+  extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      "permissions": ["contextMenus"],
+    },
+    background: function() {
+      browser.contextMenus.create({title: "c"});
+      browser.contextMenus.create({title: "d"});
+      browser.test.notifyPass("contextmenus-uninstall-second-extension");
+    },
+  });
+
+  yield extension.startup();
+  yield extension.awaitFinish("contextmenus-uninstall-second-extension");
+
+  // Open the context menu.
+  contextMenu = yield openContextMenu("#img1");
+
+  // Confirm that only the new extension menu item is in the context menu.
+  topLevelExtensionMenuItems = contextMenu.getElementsByAttribute("ext-type", "top-level-menu");
+  is(topLevelExtensionMenuItems.length, 1, "only one top level extension menu item should exist");
+
+  // Close the context menu.
+  yield closeContextMenu();
+
+  // Uninstall the extension.
+  yield extension.unload();
+
+  // Open the context menu.
+  contextMenu = yield openContextMenu("#img1");
+
+  // Confirm that no extension menu items exist.
+  topLevelExtensionMenuItems = contextMenu.getElementsByAttribute("ext-type", "top-level-menu");
+  is(topLevelExtensionMenuItems.length, 0, "no top level extension menu items should exist");
+
+  yield closeContextMenu();
+
+  yield BrowserTestUtils.removeTab(tab1);
+});