1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/customizableui/test/browser_943683_migration_test.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +const kWidgetId = "test-addonbar-migration"; 1.11 +const kWidgetId2 = "test-addonbar-migration2"; 1.12 + 1.13 +let addonbar = document.getElementById(CustomizableUI.AREA_ADDONBAR); 1.14 +let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR); 1.15 + 1.16 +let btn; 1.17 +let btn2; 1.18 + 1.19 +// Check we migrate normal stuff to the navbar 1.20 +add_task(function() { 1.21 + btn = createDummyXULButton(kWidgetId, "Test"); 1.22 + btn2 = createDummyXULButton(kWidgetId2, "Test2"); 1.23 + addonbar.insertItem(btn.id); 1.24 + ok(btn.parentNode == navbar.customizationTarget, "Button should end up in navbar"); 1.25 + let migrationArray = addonbar.getMigratedItems(); 1.26 + is(migrationArray.length, 1, "Should have migrated 1 item"); 1.27 + is(migrationArray[0], kWidgetId, "Should have migrated our 1 item"); 1.28 + 1.29 + addonbar.currentSet = addonbar.currentSet + "," + kWidgetId2; 1.30 + ok(btn2.parentNode == navbar.customizationTarget, "Second button should end up in the navbar"); 1.31 + migrationArray = addonbar.getMigratedItems(); 1.32 + is(migrationArray.length, 2, "Should have migrated 2 items"); 1.33 + isnot(migrationArray.indexOf(kWidgetId2), -1, "Should have migrated our second item"); 1.34 + 1.35 + let otherWindow = yield openAndLoadWindow(undefined, true); 1.36 + try { 1.37 + let addonBar = otherWindow.document.getElementById("addon-bar"); 1.38 + let otherMigrationArray = addonBar.getMigratedItems(); 1.39 + is(migrationArray.length, otherMigrationArray.length, 1.40 + "Other window should have the same number of migrated items."); 1.41 + if (migrationArray.length == otherMigrationArray.length) { 1.42 + for (let widget of migrationArray) { 1.43 + isnot(otherMigrationArray.indexOf(widget), -1, 1.44 + "Migrated widget " + widget + " should also be listed as migrated in the other window."); 1.45 + } 1.46 + } 1.47 + } finally { 1.48 + yield promiseWindowClosed(otherWindow); 1.49 + } 1.50 + btn.remove(); 1.51 + btn2.remove(); 1.52 + CustomizableUI.reset(); 1.53 +});