From 4fb11cd5966461bccc3ed1599b808237be6b0de9 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 10 Feb 2018 02:49:12 -0500 Subject: Move WebExtensions enabled Add-ons Manager --- .../test/browser/browser_sorting_plugins.js | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 toolkit/mozapps/webextensions/test/browser/browser_sorting_plugins.js (limited to 'toolkit/mozapps/webextensions/test/browser/browser_sorting_plugins.js') diff --git a/toolkit/mozapps/webextensions/test/browser/browser_sorting_plugins.js b/toolkit/mozapps/webextensions/test/browser/browser_sorting_plugins.js new file mode 100644 index 000000000..2bb6b4ba4 --- /dev/null +++ b/toolkit/mozapps/webextensions/test/browser/browser_sorting_plugins.js @@ -0,0 +1,95 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// Tests that sorting of plugins works correctly +// (this test checks that plugins with "ask to activate" state appear after those with +// "always activate" and before those with "never activate") + +var gManagerWindow; +var gProvider; + +function test() { + waitForExplicitFinish(); + + gProvider = new MockProvider(); + gProvider.createAddons([{ + // enabledInstalled group + // * Always activate + // * Ask to activate + // * Never activate + id: "test1@tests.mozilla.org", + name: "Java Applet Plug-in Java 7 Update 51", + description: "foo", + type: "plugin", + isActive: true, + userDisabled: AddonManager.STATE_ASK_TO_ACTIVATE + }, { + id: "test2@tests.mozilla.org", + name: "Quick Time Plug-in", + description: "foo", + type: "plugin", + isActive: true, + userDisabled: false + }, { + id: "test3@tests.mozilla.org", + name: "Shockwave Flash", + description: "foo", + type: "plugin", + isActive: false, + userDisabled: true + }, { + id: "test4@tests.mozilla.org", + name: "Adobe Reader Plug-in", + description: "foo", + type: "plugin", + isActive: true, + userDisabled: AddonManager.STATE_ASK_TO_ACTIVATE + }, { + id: "test5@tests.mozilla.org", + name: "3rd Party Plug-in", + description: "foo", + type: "plugin", + isActive: true, + userDisabled: false + }]); + + open_manager("addons://list/plugin", function(aWindow) { + gManagerWindow = aWindow; + run_next_test(); + }); +} + +function end_test() { + close_manager(gManagerWindow, function() { + finish(); + }); +} + +function check_order(aExpectedOrder) { + var order = []; + var list = gManagerWindow.document.getElementById("addon-list"); + var node = list.firstChild; + while (node) { + var id = node.getAttribute("value"); + if (id && id.endsWith("@tests.mozilla.org")) + order.push(node.getAttribute("value")); + node = node.nextSibling; + } + + is(order.toSource(), aExpectedOrder.toSource(), "Should have seen the right order"); +} + +// Tests that ascending name ordering was the default +add_test(function() { + + check_order([ + "test5@tests.mozilla.org", + "test2@tests.mozilla.org", + "test4@tests.mozilla.org", + "test1@tests.mozilla.org", + "test3@tests.mozilla.org" + ]); + + run_next_test(); +}); -- cgit v1.2.3