Bug 1246044 - Part 3 - Add unit tests for uninstall bug. r=kmag

MozReview-Commit-ID: JA10PnhFObL

--HG--
extra : rebase_source : 45880d9ba40671d259d086b853e5c4b1efd29d07
This commit is contained in:
Matthew Wein 2016-07-05 16:56:52 -07:00
parent 930e6de010
commit ad9292df1f
2 changed files with 85 additions and 0 deletions

View File

@ -30,6 +30,7 @@ support-files =
[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]

View File

@ -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);
});