fune/browser/components/customizableui/test/browser_943683_migration_test.js
Jared Wein 3f6801477a Bug 1242137 - Fix eslint errors in /browser/components/customizableui. r=gijs
--HG--
extra : commitid : CTMv8KOMjRK
extra : rebase_source : 768fb80e4652c1f0e14eea9e32da8eff795f1659
extra : amend_source : bd695a57c00c8004b048ccd4673465d66bea22c6
extra : histedit_source : ca0c6fcb719d0e7f0895de1bd429fa9804833f65
2016-01-23 14:55:27 -05:00

50 lines
2 KiB
JavaScript

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