michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const kWidgetId = "test-addonbar-migration"; michael@0: const kWidgetId2 = "test-addonbar-migration2"; michael@0: michael@0: let addonbar = document.getElementById(CustomizableUI.AREA_ADDONBAR); michael@0: let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); michael@0: michael@0: let btn; michael@0: let btn2; michael@0: michael@0: // Check we migrate normal stuff to the navbar michael@0: add_task(function() { michael@0: btn = createDummyXULButton(kWidgetId, "Test"); michael@0: btn2 = createDummyXULButton(kWidgetId2, "Test2"); michael@0: addonbar.insertItem(btn.id); michael@0: ok(btn.parentNode == navbar.customizationTarget, "Button should end up in navbar"); michael@0: let migrationArray = addonbar.getMigratedItems(); michael@0: is(migrationArray.length, 1, "Should have migrated 1 item"); michael@0: is(migrationArray[0], kWidgetId, "Should have migrated our 1 item"); michael@0: michael@0: addonbar.currentSet = addonbar.currentSet + "," + kWidgetId2; michael@0: ok(btn2.parentNode == navbar.customizationTarget, "Second button should end up in the navbar"); michael@0: migrationArray = addonbar.getMigratedItems(); michael@0: is(migrationArray.length, 2, "Should have migrated 2 items"); michael@0: isnot(migrationArray.indexOf(kWidgetId2), -1, "Should have migrated our second item"); michael@0: michael@0: let otherWindow = yield openAndLoadWindow(undefined, true); michael@0: try { michael@0: let addonBar = otherWindow.document.getElementById("addon-bar"); michael@0: let otherMigrationArray = addonBar.getMigratedItems(); michael@0: is(migrationArray.length, otherMigrationArray.length, michael@0: "Other window should have the same number of migrated items."); michael@0: if (migrationArray.length == otherMigrationArray.length) { michael@0: for (let widget of migrationArray) { michael@0: isnot(otherMigrationArray.indexOf(widget), -1, michael@0: "Migrated widget " + widget + " should also be listed as migrated in the other window."); michael@0: } michael@0: } michael@0: } finally { michael@0: yield promiseWindowClosed(otherWindow); michael@0: } michael@0: btn.remove(); michael@0: btn2.remove(); michael@0: CustomizableUI.reset(); michael@0: });