Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | const kWidgetId = "test-addonbar-migration"; |
michael@0 | 8 | const kWidgetId2 = "test-addonbar-migration2"; |
michael@0 | 9 | |
michael@0 | 10 | let addonbar = document.getElementById(CustomizableUI.AREA_ADDONBAR); |
michael@0 | 11 | let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); |
michael@0 | 12 | |
michael@0 | 13 | let btn; |
michael@0 | 14 | let btn2; |
michael@0 | 15 | |
michael@0 | 16 | // Check we migrate normal stuff to the navbar |
michael@0 | 17 | add_task(function() { |
michael@0 | 18 | btn = createDummyXULButton(kWidgetId, "Test"); |
michael@0 | 19 | btn2 = createDummyXULButton(kWidgetId2, "Test2"); |
michael@0 | 20 | addonbar.insertItem(btn.id); |
michael@0 | 21 | ok(btn.parentNode == navbar.customizationTarget, "Button should end up in navbar"); |
michael@0 | 22 | let migrationArray = addonbar.getMigratedItems(); |
michael@0 | 23 | is(migrationArray.length, 1, "Should have migrated 1 item"); |
michael@0 | 24 | is(migrationArray[0], kWidgetId, "Should have migrated our 1 item"); |
michael@0 | 25 | |
michael@0 | 26 | addonbar.currentSet = addonbar.currentSet + "," + kWidgetId2; |
michael@0 | 27 | ok(btn2.parentNode == navbar.customizationTarget, "Second button should end up in the navbar"); |
michael@0 | 28 | migrationArray = addonbar.getMigratedItems(); |
michael@0 | 29 | is(migrationArray.length, 2, "Should have migrated 2 items"); |
michael@0 | 30 | isnot(migrationArray.indexOf(kWidgetId2), -1, "Should have migrated our second item"); |
michael@0 | 31 | |
michael@0 | 32 | let otherWindow = yield openAndLoadWindow(undefined, true); |
michael@0 | 33 | try { |
michael@0 | 34 | let addonBar = otherWindow.document.getElementById("addon-bar"); |
michael@0 | 35 | let otherMigrationArray = addonBar.getMigratedItems(); |
michael@0 | 36 | is(migrationArray.length, otherMigrationArray.length, |
michael@0 | 37 | "Other window should have the same number of migrated items."); |
michael@0 | 38 | if (migrationArray.length == otherMigrationArray.length) { |
michael@0 | 39 | for (let widget of migrationArray) { |
michael@0 | 40 | isnot(otherMigrationArray.indexOf(widget), -1, |
michael@0 | 41 | "Migrated widget " + widget + " should also be listed as migrated in the other window."); |
michael@0 | 42 | } |
michael@0 | 43 | } |
michael@0 | 44 | } finally { |
michael@0 | 45 | yield promiseWindowClosed(otherWindow); |
michael@0 | 46 | } |
michael@0 | 47 | btn.remove(); |
michael@0 | 48 | btn2.remove(); |
michael@0 | 49 | CustomizableUI.reset(); |
michael@0 | 50 | }); |