Bug 1353194 Remove a bunch of tests of the old startup update check r=kmag

MozReview-Commit-ID: 8xtsRlfdbMp

--HG--
extra : rebase_source : 6ebdd06c654733e99c05d0c718e9bf1a846920fb
This commit is contained in:
Andrew Swan 2017-09-08 18:37:24 -07:00
Родитель bd180901c7
Коммит 7364d7b9d9
41 изменённых файлов: 0 добавлений и 2529 удалений

Просмотреть файл

@ -1,22 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>min1max1@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Test minVersion 1 maxVersion 1</em:name>
</Description>
</RDF>

Просмотреть файл

@ -1,22 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>min1max3@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Test minVersion 1 maxVersion 3</em:name>
</Description>
</RDF>

Просмотреть файл

@ -1,22 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>min1max3b@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Another Test minVersion 1 maxVersion 3</em:name>
</Description>
</RDF>

Просмотреть файл

@ -1,23 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>override1x2-1x3@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:updateURL>http://localhost:4444/data/test_bug542391.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Test override compat from 1..2 to 1..3</em:name>
</Description>
</RDF>

Просмотреть файл

@ -1,22 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>upgradeable1x2-3@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Test min 1 max 2 upgrade to 3</em:name>
</Description>
</RDF>

Просмотреть файл

@ -1,22 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>upgradeable1x2-3@tests.mozilla.org</em:id>
<em:version>2.0</em:version>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>3</em:minVersion>
<em:maxVersion>3</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Test min 1 max 2 upgrade to 3</em:name>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-1@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon1</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-10@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>0.3</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon10</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-2@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>0.3</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon2</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-3@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>0.3</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon3</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-4@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1.0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon4</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-5@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>0.3</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon5</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-6@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>0.3</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon6</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-7@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>0.3</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon7</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-8@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>0.3</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon8</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Двоичный файл не отображается.

Просмотреть файл

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>bug557956-9@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0.3</em:minVersion>
<em:maxVersion>0.3</em:maxVersion>
</Description>
</em:targetApplication>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Front End MetaData -->
<em:name>Addon9</em:name>
<em:bootstrap>true</em:bootstrap>
</Description>
</RDF>

Просмотреть файл

@ -37,7 +37,6 @@ skip-if = buildapp == 'mulet'
[browser_dragdrop_incompat.js]
[browser_experiments.js]
[browser_list.js]
[browser_metadataTimeout.js]
[browser_sorting.js]
[browser_sorting_plugins.js]
[browser_plugin_enabled_state_locked.js]

Просмотреть файл

@ -4,7 +4,6 @@ support-files =
addons/*
addon_about.xul
addon_prefs.xul
cancelCompatCheck.sjs
discovery.html
discovery_frame.html
discovery_install.html
@ -16,10 +15,6 @@ support-files =
releaseNotes.xhtml
blockNoPlugins.xml
blockPluginHard.xml
browser_bug557956.rdf
browser_bug557956_8_2.xpi
browser_bug557956_9_2.xpi
browser_bug557956.xml
browser_bug591465.xml
browser_bug593535.xml
browser_searching.xml
@ -46,9 +41,7 @@ support-files =
!/toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi
[browser_addonrepository_performance.js]
[browser_bug557956.js]
[browser_bug616841.js]
[browser_cancelCompatCheck.js]
[browser_checkAddonCompatibility.js]
[browser_discovery_install.js]
[browser_eula.js]

Просмотреть файл

@ -1,518 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test the compatibility dialog that displays during startup when the browser
// version changes.
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url";
const PREF_MIN_APP_COMPAT = "extensions.minCompatibleAppVersion";
const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion";
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
// avoid the 'leaked window property' check
var scope = {};
Components.utils.import("resource://gre/modules/TelemetrySession.jsm", scope);
var TelemetrySession = scope.TelemetrySession;
/**
* Test add-ons:
*
* Addon minVersion maxVersion Notes
* addon1 0 *
* addon2 0 0
* addon3 0 0
* addon4 1 *
* addon5 0 0 Made compatible by update check
* addon6 0 0 Made compatible by update check
* addon7 0 0 Has a broken update available
* addon8 0 0 Has an update available
* addon9 0 0 Has an update available
*/
function test() {
requestLongerTimeout(2);
waitForExplicitFinish();
run_next_test();
}
function end_test() {
// Test generates a lot of available installs so just cancel them all
AddonManager.getAllInstalls(function(aInstalls) {
for (let install of aInstalls)
install.cancel();
Services.prefs.clearUserPref(PREF_MIN_APP_COMPAT);
Services.prefs.clearUserPref(PREF_MIN_PLATFORM_COMPAT);
finish();
});
}
function install_test_addons(aCallback) {
// Use a blank update URL
Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf");
let names = ["browser_bug557956_1",
"browser_bug557956_2",
"browser_bug557956_3",
"browser_bug557956_4",
"browser_bug557956_5",
"browser_bug557956_6",
"browser_bug557956_7",
"browser_bug557956_8_1",
"browser_bug557956_9_1",
"browser_bug557956_10"];
let installPromises = Promise.all(
names.map(name => AddonManager.getInstallForURL(`${TESTROOT}addons/${name}.xpi`,
null, "application/x-xpinstall")));
installPromises.then(installs => {
var listener = {
installCount: 0,
onInstallEnded() {
this.installCount++;
if (this.installCount == installs.length) {
// Switch to the test update URL
Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "browser_bug557956.rdf");
executeSoon(aCallback);
}
}
};
for (let install of installs) {
install.addListener(listener);
install.install();
}
});
}
function uninstall_test_addons(aCallback) {
AddonManager.getAddonsByIDs(["bug557956-1@tests.mozilla.org",
"bug557956-2@tests.mozilla.org",
"bug557956-3@tests.mozilla.org",
"bug557956-4@tests.mozilla.org",
"bug557956-5@tests.mozilla.org",
"bug557956-6@tests.mozilla.org",
"bug557956-7@tests.mozilla.org",
"bug557956-8@tests.mozilla.org",
"bug557956-9@tests.mozilla.org",
"bug557956-10@tests.mozilla.org"],
function(aAddons) {
for (let addon of aAddons) {
if (addon)
addon.uninstall();
}
aCallback();
});
}
// Open the compatibility dialog, with the list of addon IDs
// that were disabled by this "update"
function open_compatibility_window(aDisabledAddons, aCallback) {
// This will reset the longer timeout multiplier to 2 which will give each
// test that calls open_compatibility_window a minimum of 60 seconds to
// complete.
requestLongerTimeout(2);
var variant = Cc["@mozilla.org/variant;1"].
createInstance(Ci.nsIWritableVariant);
variant.setFromVariant(aDisabledAddons);
// Cannot be modal as we want to interact with it, shouldn't cause problems
// with testing though.
var features = "chrome,centerscreen,dialog,titlebar";
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var win = ww.openWindow(null, URI_EXTENSION_UPDATE_DIALOG, "", features, variant);
win.addEventListener("load", function() {
info("Compatibility dialog opened");
function page_shown(aEvent) {
if (aEvent.target.pageid)
info("Page " + aEvent.target.pageid + " shown");
}
win.addEventListener("pageshow", page_shown);
win.addEventListener("unload", function() {
win.removeEventListener("pageshow", page_shown);
info("Compatibility dialog closed");
}, {once: true});
aCallback(win);
}, {once: true});
}
function wait_for_window_close(aWindow, aCallback) {
aWindow.addEventListener("unload", function() {
aCallback();
}, {once: true});
}
function wait_for_page(aWindow, aPageId, aCallback) {
var page = aWindow.document.getElementById(aPageId);
page.addEventListener("pageshow", function() {
executeSoon(function() {
aCallback(aWindow);
});
}, {once: true});
}
function get_list_names(aList) {
var items = [];
for (let listItem of aList.childNodes)
items.push(listItem.label);
items.sort();
return items;
}
function check_telemetry({disabled, metaenabled, metadisabled, upgraded, failed, declined}) {
let ping = TelemetrySession.getPayload();
// info(JSON.stringify(ping));
let am = ping.simpleMeasurements.addonManager;
if (disabled !== undefined)
is(am.appUpdate_disabled, disabled, disabled + " add-ons disabled by version change");
if (metaenabled !== undefined)
is(am.appUpdate_metadata_enabled, metaenabled, metaenabled + " add-ons enabled by metadata");
if (metadisabled !== undefined)
is(am.appUpdate_metadata_disabled, metadisabled, metadisabled + " add-ons disabled by metadata");
if (upgraded !== undefined)
is(am.appUpdate_upgraded, upgraded, upgraded + " add-ons upgraded");
if (failed !== undefined)
is(am.appUpdate_upgradeFailed, failed, failed + " upgrades failed");
if (declined !== undefined)
is(am.appUpdate_upgradeDeclined, declined, declined + " upgrades declined");
}
add_test(function test_setup() {
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
registerCleanupFunction(function() {
Services.telemetry.canRecordExtended = oldCanRecord;
});
run_next_test();
});
// Tests that the right add-ons show up in the mismatch dialog and updates can
// be installed
add_test(function basic_mismatch() {
install_test_addons(function() {
// These add-ons become disabled
var disabledAddonIds = [
"bug557956-3@tests.mozilla.org",
"bug557956-6@tests.mozilla.org",
"bug557956-7@tests.mozilla.org",
"bug557956-8@tests.mozilla.org",
"bug557956-9@tests.mozilla.org"
];
AddonManager.getAddonsByIDs(["bug557956-5@tests.mozilla.org",
"bug557956-6@tests.mozilla.org"],
function([a5, a6]) {
// Check starting (pre-update) conditions
ok(!a5.isCompatible, "bug557956-5 should not be compatible");
ok(!a6.isCompatible, "bug557956-6 should not be compatible");
open_compatibility_window(disabledAddonIds, function(aWindow) {
var doc = aWindow.document;
wait_for_page(aWindow, "mismatch", function(aWindow) {
var items = get_list_names(doc.getElementById("mismatch.incompatible"));
// Check that compatibility updates from individual add-on update checks were applied.
is(items.length, 4, "Should have seen 4 still incompatible items");
is(items[0], "Addon3 1.0", "Should have seen addon3 still incompatible");
is(items[1], "Addon7 1.0", "Should have seen addon7 still incompatible");
is(items[2], "Addon8 1.0", "Should have seen addon8 still incompatible");
is(items[3], "Addon9 1.0", "Should have seen addon9 still incompatible");
// If it wasn't disabled by this run, we don't try to enable it
ok(!a5.isCompatible, "bug557956-5 should not be compatible");
ok(a6.isCompatible, "bug557956-6 should be compatible");
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "found", function(aWindow) {
ok(doc.getElementById("xpinstallDisabledAlert").hidden,
"Install should be allowed");
var list = doc.getElementById("found.updates");
var items = get_list_names(list);
is(items.length, 3, "Should have seen 3 updates available");
is(items[0], "Addon7 2.0", "Should have seen update for addon7");
is(items[1], "Addon8 2.0", "Should have seen update for addon8");
is(items[2], "Addon9 2.0", "Should have seen update for addon9");
ok(!doc.documentElement.getButton("next").disabled,
"Next button should be enabled");
// Uncheck all
for (let listItem of list.childNodes)
EventUtils.synthesizeMouse(listItem, 2, 2, { }, aWindow);
ok(doc.documentElement.getButton("next").disabled,
"Next button should not be enabled");
// Check the ones we want to install
for (let listItem of list.childNodes) {
if (listItem.label != "Addon7 2.0")
EventUtils.synthesizeMouse(listItem, 2, 2, { }, aWindow);
}
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "finished", function(aWindow) {
var button = doc.documentElement.getButton("finish");
ok(!button.hidden, "Finish button should not be hidden");
ok(!button.disabled, "Finish button should not be disabled");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_window_close(aWindow, function() {
AddonManager.getAddonsByIDs(["bug557956-8@tests.mozilla.org",
"bug557956-9@tests.mozilla.org"],
function([a8, a9]) {
is(a8.version, "2.0", "bug557956-8 should have updated");
is(a9.version, "2.0", "bug557956-9 should have updated");
check_telemetry({disabled: 5, metaenabled: 1, metadisabled: 0,
upgraded: 2, failed: 0, declined: 1});
uninstall_test_addons(run_next_test);
});
});
});
});
});
});
});
});
});
// Tests that the install failures show the install failed page and disabling
// xpinstall shows the right UI.
add_test(function failure_page() {
install_test_addons(function() {
// These add-ons become disabled
var disabledAddonIds = [
"bug557956-3@tests.mozilla.org",
"bug557956-6@tests.mozilla.org",
"bug557956-7@tests.mozilla.org",
"bug557956-8@tests.mozilla.org",
"bug557956-9@tests.mozilla.org"
];
Services.prefs.setBoolPref("xpinstall.enabled", false);
open_compatibility_window(disabledAddonIds, function(aWindow) {
var doc = aWindow.document;
wait_for_page(aWindow, "mismatch", function(aWindow) {
var items = get_list_names(doc.getElementById("mismatch.incompatible"));
is(items.length, 4, "Should have seen 4 still incompatible items");
is(items[0], "Addon3 1.0", "Should have seen addon3 still incompatible");
is(items[1], "Addon7 1.0", "Should have seen addon7 still incompatible");
is(items[2], "Addon8 1.0", "Should have seen addon8 still incompatible");
is(items[3], "Addon9 1.0", "Should have seen addon9 still incompatible");
// Check that compatibility updates were applied.
AddonManager.getAddonsByIDs(["bug557956-5@tests.mozilla.org",
"bug557956-6@tests.mozilla.org"],
function([a5, a6]) {
ok(!a5.isCompatible, "bug557956-5 should not be compatible");
ok(a6.isCompatible, "bug557956-6 should be compatible");
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "found", function(aWindow) {
ok(!doc.getElementById("xpinstallDisabledAlert").hidden,
"Install should not be allowed");
ok(doc.documentElement.getButton("next").disabled,
"Next button should be disabled");
var checkbox = doc.getElementById("enableXPInstall");
EventUtils.synthesizeMouse(checkbox, 2, 2, { }, aWindow);
ok(!doc.documentElement.getButton("next").disabled,
"Next button should be enabled");
var list = doc.getElementById("found.updates");
var items = get_list_names(list);
is(items.length, 3, "Should have seen 3 updates available");
is(items[0], "Addon7 2.0", "Should have seen update for addon7");
is(items[1], "Addon8 2.0", "Should have seen update for addon8");
is(items[2], "Addon9 2.0", "Should have seen update for addon9");
// Unheck the ones we don't want to install
for (let listItem of list.childNodes) {
if (listItem.label != "Addon7 2.0")
EventUtils.synthesizeMouse(listItem, 2, 2, { }, aWindow);
}
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "installerrors", function(aWindow) {
var button = doc.documentElement.getButton("finish");
ok(!button.hidden, "Finish button should not be hidden");
ok(!button.disabled, "Finish button should not be disabled");
wait_for_window_close(aWindow, function() {
uninstall_test_addons(run_next_test);
});
check_telemetry({disabled: 5, metaenabled: 1, metadisabled: 0,
upgraded: 0, failed: 1, declined: 2});
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
});
});
});
});
});
});
});
// Tests that no add-ons show up in the mismatch dialog when they are all disabled
add_test(function all_disabled() {
install_test_addons(function() {
AddonManager.getAddonsByIDs(["bug557956-1@tests.mozilla.org",
"bug557956-2@tests.mozilla.org",
"bug557956-3@tests.mozilla.org",
"bug557956-4@tests.mozilla.org",
"bug557956-5@tests.mozilla.org",
"bug557956-6@tests.mozilla.org",
"bug557956-7@tests.mozilla.org",
"bug557956-8@tests.mozilla.org",
"bug557956-9@tests.mozilla.org",
"bug557956-10@tests.mozilla.org"],
function(aAddons) {
for (let addon of aAddons)
addon.userDisabled = true;
open_compatibility_window([], function(aWindow) {
// Should close immediately on its own
wait_for_window_close(aWindow, function() {
uninstall_test_addons(run_next_test);
});
});
});
});
});
// Tests that the right UI shows for when no updates are available
add_test(function no_updates() {
install_test_addons(function() {
AddonManager.getAddonsByIDs(["bug557956-7@tests.mozilla.org",
"bug557956-8@tests.mozilla.org",
"bug557956-9@tests.mozilla.org",
"bug557956-10@tests.mozilla.org"],
function(aAddons) {
for (let addon of aAddons)
addon.uninstall();
// These add-ons were disabled by the upgrade
var inactiveAddonIds = [
"bug557956-3@tests.mozilla.org",
"bug557956-5@tests.mozilla.org",
"bug557956-6@tests.mozilla.org"
];
open_compatibility_window(inactiveAddonIds, function(aWindow) {
var doc = aWindow.document;
wait_for_page(aWindow, "mismatch", function(aWindow) {
var items = get_list_names(doc.getElementById("mismatch.incompatible"));
is(items.length, 1, "Should have seen 1 still incompatible items");
is(items[0], "Addon3 1.0", "Should have seen addon3 still incompatible");
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "noupdates", function(aWindow) {
var button = doc.documentElement.getButton("finish");
ok(!button.hidden, "Finish button should not be hidden");
ok(!button.disabled, "Finish button should not be disabled");
wait_for_window_close(aWindow, function() {
uninstall_test_addons(run_next_test);
});
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
});
});
});
});
});
});
// Tests that compatibility overrides are retrieved and affect addon
// compatibility.
add_test(function overrides_retrieved() {
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, false);
Services.prefs.setCharPref(PREF_MIN_APP_COMPAT, "0");
Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
is(AddonManager.strictCompatibility, false, "Strict compatibility should be disabled");
// Use a blank update URL
Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf");
install_test_addons(function() {
AddonManager.getAddonsByIDs(["bug557956-1@tests.mozilla.org",
"bug557956-2@tests.mozilla.org",
"bug557956-3@tests.mozilla.org",
"bug557956-4@tests.mozilla.org",
"bug557956-5@tests.mozilla.org",
"bug557956-6@tests.mozilla.org",
"bug557956-7@tests.mozilla.org",
"bug557956-8@tests.mozilla.org",
"bug557956-9@tests.mozilla.org",
"bug557956-10@tests.mozilla.org"],
function(aAddons) {
for (let addon of aAddons) {
if (addon.id == "bug557956-10@tests.mozilla.org")
is(addon.isCompatible, true, "Addon10 should be compatible before compat overrides are refreshed");
else
addon.uninstall();
}
Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_bug557956.xml");
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
open_compatibility_window([], function(aWindow) {
var doc = aWindow.document;
wait_for_page(aWindow, "mismatch", function(aWindow) {
var items = get_list_names(doc.getElementById("mismatch.incompatible"));
is(items.length, 1, "Should have seen 1 incompatible item");
is(items[0], "Addon10 1.0", "Should have seen addon10 as incompatible");
var button = doc.documentElement.getButton("next");
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
wait_for_page(aWindow, "noupdates", function(aWindow) {
var button = doc.documentElement.getButton("finish");
ok(!button.hidden, "Finish button should not be hidden");
ok(!button.disabled, "Finish button should not be disabled");
wait_for_window_close(aWindow, function() {
uninstall_test_addons(run_next_test);
});
check_telemetry({disabled: 0, metaenabled: 0, metadisabled: 1,
upgraded: 0, failed: 0, declined: 0});
EventUtils.synthesizeMouse(button, 2, 2, { }, aWindow);
});
});
});
});
});
});

Просмотреть файл

@ -1,310 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:bug557956-1@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:bug557956-2@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:bug557956-3@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:bug557956-4@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:bug557956-5@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:bug557956-6@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:bug557956-7@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<RDF:li>
<RDF:Description>
<em:version>2.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_bug557956_7_2.xpi</em:updateLink>
<em:updateHash>sha1:18674cf7ad76664e0ead6280a43cc0c681180505</em:updateHash>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_bug557956_7_2.xpi</em:updateLink>
<em:updateHash>sha1:18674cf7ad76664e0ead6280a43cc0c681180505</em:updateHash>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:bug557956-8@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<RDF:li>
<RDF:Description>
<em:version>2.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_bug557956_8_2.xpi</em:updateLink>
<em:updateHash>sha1:5691c398e55ddf93aa1076b9820619d21d40acbc</em:updateHash>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_bug557956_8_2.xpi</em:updateLink>
<em:updateHash>sha1:5691c398e55ddf93aa1076b9820619d21d40acbc</em:updateHash>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
<RDF:Description about="urn:mozilla:extension:bug557956-9@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>0</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
<RDF:li>
<RDF:Description>
<em:version>2.0</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_bug557956_9_2.xpi</em:updateLink>
<em:updateHash>sha1:1ae63bfc6f67a4503a1ff1bd02402c98fef19ae3</em:updateHash>
</RDF:Description>
</em:targetApplication>
<em:targetApplication>
<RDF:Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
<em:updateLink>http://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_bug557956_9_2.xpi</em:updateLink>
<em:updateHash>sha1:1ae63bfc6f67a4503a1ff1bd02402c98fef19ae3</em:updateHash>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

Просмотреть файл

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<searchresults total_results="1">
<addon_compatibility hosted="false">
<guid>bug557956-10@tests.mozilla.org</guid>
<name>Addon10</name>
<version_ranges>
<version_range type="incompatible">
<min_version>1.0</min_version>
<max_version>2.0</max_version>
<compatible_applications>
<application>
<min_version>0.1</min_version>
<max_version>999.0</max_version>
<appID>toolkit@mozilla.org</appID>
</application>
</compatible_applications>
</version_range>
</version_ranges>
</addon_compatibility>
</searchresults>

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -1,450 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/* eslint-disable mozilla/no-arbitrary-setTimeout */
// Test that we can cancel the add-on compatibility check while it is
// in progress (bug 772484).
// Test framework copied from browser_bug557956.js
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url";
const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion";
const PREF_METADATA_LASTUPDATE = "extensions.getAddons.cache.lastUpdate";
var repo = {};
Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm", repo);
/**
* Test add-ons:
*
* Addon minVersion maxVersion Notes
* addon1 0 *
* addon2 0 0
* addon3 0 0
* addon4 1 *
* addon5 0 0 Made compatible by update check
* addon6 0 0 Made compatible by update check
* addon7 0 0 Has a broken update available
* addon8 0 0 Has an update available
* addon9 0 0 Has an update available
* addon10 0 0 Made incompatible by override check
*/
// describe the addons
var ao1 = { file: "browser_bug557956_1", id: "bug557956-1@tests.mozilla.org"};
var ao2 = { file: "browser_bug557956_2", id: "bug557956-2@tests.mozilla.org"};
var ao3 = { file: "browser_bug557956_3", id: "bug557956-3@tests.mozilla.org"};
var ao4 = { file: "browser_bug557956_4", id: "bug557956-4@tests.mozilla.org"};
var ao5 = { file: "browser_bug557956_5", id: "bug557956-5@tests.mozilla.org"};
var ao6 = { file: "browser_bug557956_6", id: "bug557956-6@tests.mozilla.org"};
var ao7 = { file: "browser_bug557956_7", id: "bug557956-7@tests.mozilla.org"};
var ao8 = { file: "browser_bug557956_8_1", id: "bug557956-8@tests.mozilla.org"};
var ao9 = { file: "browser_bug557956_9_1", id: "bug557956-9@tests.mozilla.org"};
var ao10 = { file: "browser_bug557956_10", id: "bug557956-10@tests.mozilla.org"};
// Return a promise that resolves after the specified delay in MS
function delayMS(aDelay) {
return new Promise(resolve => {
setTimeout(resolve, aDelay);
});
}
// Return a promise that resolves when the specified observer topic is notified
function promise_observer(aTopic) {
return new Promise(resolve => {
Services.obs.addObserver(function observer(aSubject, aObsTopic, aData) {
Services.obs.removeObserver(observer, aObsTopic);
resolve([aSubject, aData]);
}, aTopic);
});
}
// Install a set of addons using a bogus update URL so that we can force
// the compatibility update to happen later
// @param aUpdateURL The real update URL to use after the add-ons are installed
function promise_install_test_addons(aAddonList, aUpdateURL) {
info("Starting add-on installs");
return new Promise(resolve => {
// Use a blank update URL
Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf");
let installPromises = Promise.all(
aAddonList.map(addon => AddonManager.getInstallForURL(`${TESTROOT}addons/${addon.file}.xpi`,
null, "application/x-xpinstall")));
installPromises.then(installs => {
var listener = {
installCount: 0,
onInstallEnded() {
this.installCount++;
if (this.installCount == installs.length) {
info("Done add-on installs");
// Switch to the test update URL
Services.prefs.setCharPref(PREF_UPDATEURL, aUpdateURL);
resolve();
}
}
};
for (let install of installs) {
install.addListener(listener);
install.install();
}
});
});
}
function promise_addons_by_ids(aAddonIDs) {
info("promise_addons_by_ids " + aAddonIDs.toSource());
return new Promise(resolve => {
AddonManager.getAddonsByIDs(aAddonIDs, resolve);
});
}
async function promise_uninstall_test_addons() {
info("Starting add-on uninstalls");
let addons = await promise_addons_by_ids([ao1.id, ao2.id, ao3.id, ao4.id, ao5.id,
ao6.id, ao7.id, ao8.id, ao9.id, ao10.id]);
await new Promise(resolve => {
let uninstallCount = addons.length;
let listener = {
onUninstalled(aAddon) {
if (aAddon) {
info("Finished uninstalling " + aAddon.id);
}
if (--uninstallCount == 0) {
info("Done add-on uninstalls");
AddonManager.removeAddonListener(listener);
resolve();
}
}};
AddonManager.addAddonListener(listener);
for (let addon of addons) {
if (addon)
addon.uninstall();
else
listener.onUninstalled(null);
}
});
}
// Returns promise{window}, resolves with a handle to the compatibility
// check window
function promise_open_compatibility_window(aInactiveAddonIds) {
return new Promise(resolve => {
// This will reset the longer timeout multiplier to 2 which will give each
// test that calls open_compatibility_window a minimum of 60 seconds to
// complete.
requestLongerTimeout(2);
var variant = Cc["@mozilla.org/variant;1"].
createInstance(Ci.nsIWritableVariant);
variant.setFromVariant(aInactiveAddonIds);
// Cannot be modal as we want to interract with it, shouldn't cause problems
// with testing though.
var features = "chrome,centerscreen,dialog,titlebar";
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var win = ww.openWindow(null, URI_EXTENSION_UPDATE_DIALOG, "", features, variant);
win.addEventListener("load", function listener() {
function page_shown(aEvent) {
if (aEvent.target.pageid)
info("Page " + aEvent.target.pageid + " shown");
}
win.removeEventListener("load", listener);
info("Compatibility dialog opened");
win.addEventListener("pageshow", page_shown);
win.addEventListener("unload", function() {
win.removeEventListener("pageshow", page_shown);
dump("Compatibility dialog closed\n");
}, {once: true});
resolve(win);
});
});
}
function promise_window_close(aWindow) {
return new Promise(resolve => {
aWindow.addEventListener("unload", function() {
resolve(aWindow);
}, {once: true});
});
}
function promise_page(aWindow, aPageId) {
return new Promise(resolve => {
var page = aWindow.document.getElementById(aPageId);
if (aWindow.document.getElementById("updateWizard").currentPage === page) {
resolve(aWindow);
} else {
page.addEventListener("pageshow", function() {
executeSoon(function() {
resolve(aWindow);
});
}, {once: true});
}
});
}
// These add-ons became inactive during the upgrade
var inactiveAddonIds = [
ao5.id,
ao6.id,
ao7.id,
ao8.id,
ao9.id
];
// Make sure the addons in the list are not installed
async function check_addons_uninstalled(aAddonList) {
let foundList = await promise_addons_by_ids(aAddonList.map(a => a.id));
for (let i = 0; i < aAddonList.length; i++) {
ok(!foundList[i], "Addon " + aAddonList[i].id + " is not installed");
}
info("Add-on uninstall check complete");
await true;
}
// Test what happens when the user cancels during AddonRepository.repopulateCache()
// Add-ons that have updates available should not update if they were disabled before
// For this test, addon8 became disabled during update and addon9 was previously disabled,
// so addon8 should update and addon9 should not
add_task(async function cancel_during_repopulate() {
let a5, a8, a9, a10;
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf");
let installsDone = promise_observer("TEST:all-updates-done");
// Don't pull compatibility data during add-on install
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
// Set up our test addons so that the server-side JS has a 500ms delay to make
// sure we cancel the dialog before we get the data we want to refill our
// AddonRepository cache
let addonList = [ao5, ao8, ao9, ao10];
await promise_install_test_addons(addonList,
TESTROOT + "cancelCompatCheck.sjs?500");
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_bug557956.xml");
[a5, a8, a9] = await promise_addons_by_ids([ao5.id, ao8.id, ao9.id]);
ok(!a5.isCompatible, "addon5 should not be compatible");
ok(!a8.isCompatible, "addon8 should not be compatible");
ok(!a9.isCompatible, "addon9 should not be compatible");
let compatWindow = await promise_open_compatibility_window([ao5.id, ao8.id]);
var doc = compatWindow.document;
await promise_page(compatWindow, "versioninfo");
// Brief delay to let the update window finish requesting all add-ons and start
// reloading the addon repository
await delayMS(50);
info("Cancel the compatibility check dialog");
var button = doc.documentElement.getButton("cancel");
EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
info("Waiting for installs to complete");
await installsDone;
ok(!repo.AddonRepository.isSearching, "Background installs are done");
// There should be no active updates
let installs = await new Promise(resolve => {
AddonManager.getAllInstalls(resolve);
});
is(installs.length, 0, "There should be no active installs after background installs are done");
// addon8 should have updated in the background,
// addon9 was listed as previously disabled so it should not have updated
[a5, a8, a9, a10] = await promise_addons_by_ids([ao5.id, ao8.id, ao9.id, ao10.id]);
ok(a5.isCompatible, "addon5 should be compatible");
ok(a8.isCompatible, "addon8 should have been upgraded");
ok(!a9.isCompatible, "addon9 should not have been upgraded");
ok(!a10.isCompatible, "addon10 should not be compatible");
info("Updates done");
await promise_uninstall_test_addons();
info("done uninstalling add-ons");
});
// User cancels after repopulateCache, while we're waiting for the addon.findUpdates()
// calls in gVersionInfoPage_onPageShow() to complete
// For this test, both addon8 and addon9 were disabled by this update, but addon8
// is set to not auto-update, so only addon9 should update in the background
add_task(async function cancel_during_findUpdates() {
let a5, a8, a9;
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
// Clear the AddonRepository-last-updated preference to ensure that it reloads
Services.prefs.clearUserPref(PREF_METADATA_LASTUPDATE);
let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated");
let installsDone = promise_observer("TEST:all-updates-done");
// Don't pull compatibility data during add-on install
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
// No delay on the .sjs this time because we want the cache to repopulate
let addonList = [ao3, ao5, ao6, ao7, ao8, ao9];
await promise_install_test_addons(addonList,
TESTROOT + "cancelCompatCheck.sjs");
[a8] = await promise_addons_by_ids([ao8.id]);
a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
let compatWindow = await promise_open_compatibility_window(inactiveAddonIds);
var doc = compatWindow.document;
await promise_page(compatWindow, "versioninfo");
info("Waiting for repository-data-updated");
await observeUpdateDone;
// Quick wait to make sure the findUpdates calls get queued
await delayMS(5);
info("Cancel the compatibility check dialog");
var button = doc.documentElement.getButton("cancel");
EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
info("Waiting for installs to complete 2");
await installsDone;
ok(!repo.AddonRepository.isSearching, "Background installs are done 2");
// addon8 should have updated in the background,
// addon9 was listed as previously disabled so it should not have updated
[a5, a8, a9] = await promise_addons_by_ids([ao5.id, ao8.id, ao9.id]);
ok(a5.isCompatible, "addon5 should be compatible");
ok(!a8.isCompatible, "addon8 should not have been upgraded");
ok(a9.isCompatible, "addon9 should have been upgraded");
let installs = await new Promise(resolve => {
AddonManager.getAllInstalls(resolve);
});
is(installs.length, 0, "There should be no active installs after the dialog is cancelled 2");
info("findUpdates done");
await promise_uninstall_test_addons();
});
// Cancelling during the 'mismatch' screen allows add-ons that can auto-update
// to continue updating in the background and cancels any other updates
// Same conditions as the previous test - addon8 and addon9 have updates available,
// addon8 is set to not auto-update so only addon9 should become compatible
add_task(async function cancel_mismatch() {
let a3, a5, a7, a8, a9;
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
// Clear the AddonRepository-last-updated preference to ensure that it reloads
Services.prefs.clearUserPref(PREF_METADATA_LASTUPDATE);
let installsDone = promise_observer("TEST:all-updates-done");
// Don't pull compatibility data during add-on install
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
// No delay on the .sjs this time because we want the cache to repopulate
let addonList = [ao3, ao5, ao6, ao7, ao8, ao9];
await promise_install_test_addons(addonList,
TESTROOT + "cancelCompatCheck.sjs");
[a8] = await promise_addons_by_ids([ao8.id]);
a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
// Check that the addons start out not compatible.
[a3, a7, a8, a9] = await promise_addons_by_ids([ao3.id, ao7.id, ao8.id, ao9.id]);
ok(!a3.isCompatible, "addon3 should not be compatible");
ok(!a7.isCompatible, "addon7 should not be compatible");
ok(!a8.isCompatible, "addon8 should not be compatible");
ok(!a9.isCompatible, "addon9 should not be compatible");
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
let compatWindow = await promise_open_compatibility_window(inactiveAddonIds);
var doc = compatWindow.document;
info("Wait for mismatch page");
await promise_page(compatWindow, "mismatch");
info("Click the Don't Check button");
var button = doc.documentElement.getButton("cancel");
EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
await promise_window_close(compatWindow);
info("Waiting for installs to complete in cancel_mismatch");
await installsDone;
// addon8 should not have updated in the background,
// addon9 was listed as previously disabled so it should not have updated
[a5, a8, a9] = await promise_addons_by_ids([ao5.id, ao8.id, ao9.id]);
ok(a5.isCompatible, "addon5 should be compatible");
ok(!a8.isCompatible, "addon8 should not have been upgraded");
ok(a9.isCompatible, "addon9 should have been upgraded");
// Make sure there are no pending addon installs
let installs = await new Promise(resolve => {
AddonManager.getAllInstalls(resolve);
});
ok(installs.length == 0, "No remaining add-on installs (" + installs.toSource() + ")");
await promise_uninstall_test_addons();
await check_addons_uninstalled(addonList);
});
// Cancelling during the 'mismatch' screen with only add-ons that have
// no updates available
add_task(async function cancel_mismatch_no_updates() {
let a3, a5, a6
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
// Don't pull compatibility data during add-on install
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
// No delay on the .sjs this time because we want the cache to repopulate
let addonList = [ao3, ao5, ao6];
await promise_install_test_addons(addonList,
TESTROOT + "cancelCompatCheck.sjs");
// Check that the addons start out not compatible.
[a3, a5, a6] = await promise_addons_by_ids([ao3.id, ao5.id, ao6.id]);
ok(!a3.isCompatible, "addon3 should not be compatible");
ok(!a5.isCompatible, "addon5 should not be compatible");
ok(!a6.isCompatible, "addon6 should not be compatible");
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
let compatWindow = await promise_open_compatibility_window([ao3.id, ao5.id, ao6.id]);
var doc = compatWindow.document;
info("Wait for mismatch page");
await promise_page(compatWindow, "mismatch");
info("Click the Don't Check button");
var button = doc.documentElement.getButton("cancel");
EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
await promise_window_close(compatWindow);
[a3, a5, a6] = await promise_addons_by_ids([ao3.id, ao5.id, ao6.id]);
ok(!a3.isCompatible, "addon3 should not be compatible");
ok(a5.isCompatible, "addon5 should have become compatible");
ok(a6.isCompatible, "addon6 should have become compatible");
// Make sure there are no pending addon installs
let installs = await new Promise(resolve => {
AddonManager.getAllInstalls(resolve);
});
ok(installs.length == 0, "No remaining add-on installs (" + installs.toSource() + ")");
await promise_uninstall_test_addons();
await check_addons_uninstalled(addonList);
});

Просмотреть файл

@ -25,9 +25,6 @@ function test() {
ok(a.isCompatible, a.type + " " + a.name + " " + a.version + " should be compatible");
allCompatible = allCompatible && a.isCompatible;
}
// Add a reminder.
if (!allCompatible)
ok(false, "As this test failed, test browser_bug557956.js should have failed, too.");
finish();
});

Просмотреть файл

@ -1,110 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Test how update window behaves when metadata ping times out
// bug 965788
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const PREF_METADATA_LASTUPDATE = "extensions.getAddons.cache.lastUpdate";
Components.utils.import("resource://gre/modules/Promise.jsm");
var repo = {};
var ARContext = Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm", repo);
// Mock out the XMLHttpRequest factory for AddonRepository so
// we can reply with a timeout
var pXHRStarted = Promise.defer();
var oldXHRConstructor = ARContext.ServiceRequest;
ARContext.ServiceRequest = function() {
this._handlers = new Map();
this.mozBackgroundRequest = false;
this.timeout = undefined;
this.open = function(aMethod, aURI, aAsync) {
this.method = aMethod;
this.uri = aURI;
this.async = aAsync;
info("Opened XHR for " + aMethod + " " + aURI);
};
this.overrideMimeType = function(aMimeType) {
this.mimeType = aMimeType;
};
this.addEventListener = function(aEvent, aHandler, aCapture) {
this._handlers.set(aEvent, aHandler);
};
this.send = function(aBody) {
info("Send XHR for " + this.method + " " + this.uri + " handlers: " + [this._handlers.keys()].join(", "));
pXHRStarted.resolve(this);
}
};
// Returns promise{window}, resolves with a handle to the compatibility
// check window
function promise_open_compatibility_window(aInactiveAddonIds) {
return new Promise(resolve => {
// This will reset the longer timeout multiplier to 2 which will give each
// test that calls open_compatibility_window a minimum of 60 seconds to
// complete.
requestLongerTimeout(2);
var variant = Cc["@mozilla.org/variant;1"].
createInstance(Ci.nsIWritableVariant);
variant.setFromVariant(aInactiveAddonIds);
// Cannot be modal as we want to interract with it, shouldn't cause problems
// with testing though.
var features = "chrome,centerscreen,dialog,titlebar";
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
var win = ww.openWindow(null, URI_EXTENSION_UPDATE_DIALOG, "", features, variant);
win.addEventListener("load", function listener() {
function page_shown(aEvent) {
if (aEvent.target.pageid)
info("Page " + aEvent.target.pageid + " shown");
}
win.removeEventListener("load", listener);
info("Compatibility dialog opened");
win.addEventListener("pageshow", page_shown);
win.addEventListener("unload", function() {
win.removeEventListener("pageshow", page_shown);
dump("Compatibility dialog closed\n");
}, {once: true});
resolve(win);
});
});
}
function promise_window_close(aWindow) {
return new Promise(resolve => {
aWindow.addEventListener("unload", function() {
resolve(aWindow);
}, {once: true});
});
}
// Start the compatibility update dialog, but use the mock XHR to respond with
// a timeout
add_task(async function amo_ping_timeout() {
Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
Services.prefs.clearUserPref(PREF_METADATA_LASTUPDATE);
let compatWindow = await promise_open_compatibility_window([]);
let xhr = await pXHRStarted.promise;
is(xhr.timeout, 30000, "XHR request should have 30 second timeout");
ok(xhr._handlers.has("timeout"), "Timeout handler set on XHR");
// call back the timeout handler
xhr._handlers.get("timeout")();
// Put the old XHR constructor back
ARContext.ServiceRequest = oldXHRConstructor;
// The window should close without further interaction
await promise_window_close(compatWindow);
});

Просмотреть файл

@ -1,43 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Delay before responding to an HTTP call attempting to read
// an addon update RDF file
function handleRequest(req, resp) {
resp.processAsync();
resp.setHeader("Cache-Control", "no-cache, no-store", false);
resp.setHeader("Content-Type", "text/xml;charset=utf-8", false);
let file = null;
getObjectState("SERVER_ROOT", function(serverRoot)
{
file = serverRoot.getFile("browser/toolkit/mozapps/extensions/test/browser/browser_bug557956.rdf");
});
dump("*** cancelCompatCheck.sjs: " + file.path + "\n");
let fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].
createInstance(Components.interfaces.nsIFileInputStream);
fstream.init(file, -1, 0, 0);
let cstream = null;
cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
createInstance(Components.interfaces.nsIConverterInputStream);
cstream.init(fstream, "UTF-8", 0, 0);
// The delay can be passed on the query string
let delay = req.queryString + 0;
timer = Components.classes["@mozilla.org/timer;1"].
createInstance(Components.interfaces.nsITimer);
timer.init(function sendFile() {
dump("cancelCompatCheck: starting to send file\n");
let str = {};
let read = 0;
do {
// read as much as we can and put it in str.value
read = cstream.readString(0xffffffff, str);
resp.write(str.value);
} while (read != 0);
cstream.close();
resp.finish();
}, delay, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
}

Просмотреть файл

@ -1,462 +0,0 @@
/* 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/.
*/
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
var Cr = Components.results;
Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver;
const profileDir = gProfD.clone();
profileDir.append("extensions");
var gInstallUpdate = false;
var gCheckUpdates = false;
// This will be called to show the compatibility update dialog.
var WindowWatcher = {
expected: false,
args: null,
openWindow(parent, url, name, features, args) {
do_check_true(Services.startup.interrupted);
do_check_eq(url, URI_EXTENSION_UPDATE_DIALOG);
do_check_true(this.expected);
this.expected = false;
this.args = args.QueryInterface(AM_Ci.nsIVariant);
var updated = !gCheckUpdates;
if (gCheckUpdates) {
AddonManager.getAddonByID("override1x2-1x3@tests.mozilla.org", function(a6) {
a6.findUpdates({
onUpdateFinished() {
AddonManagerPrivate.removeStartupChange("disabled", "override1x2-1x3@tests.mozilla.org");
updated = true;
}
}, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED);
});
}
var installed = !gInstallUpdate;
if (gInstallUpdate) {
// Simulate installing an update while in the dialog
installAllFiles([do_get_addon("upgradeable1x2-3_2")], function() {
AddonManagerPrivate.removeStartupChange("disabled", "upgradeable1x2-3@tests.mozilla.org");
AddonManagerPrivate.addStartupChange("updated", "upgradeable1x2-3@tests.mozilla.org");
installed = true;
});
}
// The dialog is meant to be opened modally and the install operation can be
// asynchronous, so we must spin an event loop (like the modal window does)
// until the install is complete
let tm = AM_Cc["@mozilla.org/thread-manager;1"].
getService(AM_Ci.nsIThreadManager);
tm.spinEventLoopUntil(() => installed && updated);
},
QueryInterface(iid) {
if (iid.equals(Ci.nsIWindowWatcher)
|| iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
}
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
function check_state_v1([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);
do_check_false(a1.appDisabled);
do_check_false(a1.userDisabled);
do_check_true(a1.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_false(a2.appDisabled);
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(a3.appDisabled);
do_check_false(a3.userDisabled);
do_check_true(a3.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_eq(a3.version, "1.0");
do_check_neq(a4, null);
do_check_false(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.appDisabled);
do_check_false(a5.userDisabled);
do_check_true(a5.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_false(a6.appDisabled);
do_check_false(a6.userDisabled);
do_check_true(a6.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a6.id));
}
function check_state_v1_2([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);
do_check_false(a1.appDisabled);
do_check_false(a1.userDisabled);
do_check_true(a1.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_false(a2.appDisabled);
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_true(a3.appDisabled);
do_check_false(a3.userDisabled);
do_check_false(a3.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
do_check_eq(a3.version, "2.0");
do_check_neq(a4, null);
do_check_false(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.appDisabled);
do_check_false(a5.userDisabled);
do_check_true(a5.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_false(a6.appDisabled);
do_check_false(a6.userDisabled);
do_check_true(a6.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a6.id));
}
function check_state_v2([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);
do_check_true(a1.appDisabled);
do_check_false(a1.userDisabled);
do_check_false(a1.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_false(a2.appDisabled);
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(a3.appDisabled);
do_check_false(a3.userDisabled);
do_check_true(a3.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_eq(a3.version, "1.0");
do_check_neq(a4, null);
do_check_false(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.appDisabled);
do_check_false(a5.userDisabled);
do_check_true(a5.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_false(a6.appDisabled);
do_check_false(a6.userDisabled);
do_check_true(a6.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a6.id));
}
function check_state_v3([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);
do_check_true(a1.appDisabled);
do_check_false(a1.userDisabled);
do_check_false(a1.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_true(a2.appDisabled);
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_true(a3.appDisabled);
do_check_false(a3.userDisabled);
do_check_false(a3.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
do_check_eq(a3.version, "1.0");
do_check_neq(a4, null);
do_check_false(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.appDisabled);
do_check_false(a5.userDisabled);
do_check_true(a5.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_false(a6.appDisabled);
do_check_false(a6.userDisabled);
do_check_true(a6.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a6.id));
}
function check_state_v3_2([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);
do_check_true(a1.appDisabled);
do_check_false(a1.userDisabled);
do_check_false(a1.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a1.id));
do_check_neq(a2, null);
do_check_true(a2.appDisabled);
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_neq(a3, null);
do_check_false(a3.appDisabled);
do_check_false(a3.userDisabled);
do_check_true(a3.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a3.id));
do_check_eq(a3.version, "2.0");
do_check_neq(a4, null);
do_check_false(a4.appDisabled);
do_check_true(a4.userDisabled);
do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_neq(a5, null);
do_check_false(a5.appDisabled);
do_check_false(a5.userDisabled);
do_check_true(a5.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a5.id));
do_check_neq(a6, null);
do_check_false(a6.appDisabled);
do_check_false(a6.userDisabled);
do_check_true(a6.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a6.id));
}
// Install all the test add-ons, disable two of them and "upgrade" the app to
// version 2 which will appDisable one.
add_task(async function init() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true);
// Add an extension to the profile to make sure the dialog doesn't show up
// on new profiles
var dest = writeInstallRDFForExtension({
id: "addon1@tests.mozilla.org",
version: "1.0",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Addon 1",
}, profileDir);
// Create and configure the HTTP server.
testserver = createHttpServer(4444);
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.registerDirectory("/addons/", do_get_file("addons"));
startupManager();
// Remove the add-on we installed directly in the profile directory;
// this should show as uninstalled on next restart
dest.remove(true);
// Load up an initial set of add-ons
await promiseInstallAllFiles([do_get_addon("min1max1"),
do_get_addon("min1max2"),
do_get_addon("upgradeable1x2-3_1"),
do_get_addon("min1max3"),
do_get_addon("min1max3b"),
do_get_addon("override1x2-1x3")]);
await promiseRestartManager();
check_startup_changes("installed", []);
check_startup_changes("updated", []);
check_startup_changes("uninstalled", ["addon1@tests.mozilla.org"]);
check_startup_changes("disabled", []);
check_startup_changes("enabled", []);
// user-disable two add-ons
let [a2, a4] = await promiseAddonsByIDs(["min1max2@tests.mozilla.org",
"min1max3@tests.mozilla.org"]);
do_check_true(a2 != null && a4 != null);
a2.userDisabled = true;
a4.userDisabled = true;
await promiseRestartManager();
check_startup_changes("installed", []);
check_startup_changes("updated", []);
check_startup_changes("uninstalled", []);
check_startup_changes("disabled", []);
check_startup_changes("enabled", []);
let addons = await promiseAddonsByIDs(["min1max1@tests.mozilla.org",
"min1max2@tests.mozilla.org",
"upgradeable1x2-3@tests.mozilla.org",
"min1max3@tests.mozilla.org",
"min1max3b@tests.mozilla.org",
"override1x2-1x3@tests.mozilla.org"]);
check_state_v1(addons);
// Restart as version 2, add-on _1 should become app-disabled
WindowWatcher.expected = true;
await promiseRestartManager("2");
check_startup_changes("installed", []);
check_startup_changes("updated", []);
check_startup_changes("uninstalled", []);
check_startup_changes("disabled", ["min1max1@tests.mozilla.org"]);
check_startup_changes("enabled", []);
do_check_false(WindowWatcher.expected);
addons = await promiseAddonsByIDs(["min1max1@tests.mozilla.org",
"min1max2@tests.mozilla.org",
"upgradeable1x2-3@tests.mozilla.org",
"min1max3@tests.mozilla.org",
"min1max3b@tests.mozilla.org",
"override1x2-1x3@tests.mozilla.org"]);
check_state_v2(addons);
});
// Upgrade to version 3 which will appDisable addons
// upgradeable1x2-3 and override1x2-1x3
// Only the newly disabled add-ons should be passed to the
// upgrade window
add_task(async function run_test_1() {
gCheckUpdates = true;
WindowWatcher.expected = true;
await promiseRestartManager("3");
check_startup_changes("installed", []);
check_startup_changes("updated", []);
check_startup_changes("uninstalled", []);
check_startup_changes("disabled", ["upgradeable1x2-3@tests.mozilla.org"]);
check_startup_changes("enabled", []);
do_check_false(WindowWatcher.expected);
gCheckUpdates = false;
let addons = await promiseAddonsByIDs(["min1max1@tests.mozilla.org",
"min1max2@tests.mozilla.org",
"upgradeable1x2-3@tests.mozilla.org",
"min1max3@tests.mozilla.org",
"min1max3b@tests.mozilla.org",
"override1x2-1x3@tests.mozilla.org"]);
check_state_v3(addons);
do_check_eq(WindowWatcher.args.length, 2);
do_check_true(WindowWatcher.args.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
do_check_true(WindowWatcher.args.indexOf("override1x2-1x3@tests.mozilla.org") >= 0);
});
// Downgrade to version 2 which will remove appDisable from two add-ons
// Still displays the compat window, because metadata is not recently updated
add_task(async function run_test_2() {
WindowWatcher.expected = true;
await promiseRestartManager("2");
check_startup_changes("installed", []);
check_startup_changes("updated", []);
check_startup_changes("uninstalled", []);
check_startup_changes("disabled", []);
check_startup_changes("enabled", ["upgradeable1x2-3@tests.mozilla.org"]);
do_check_false(WindowWatcher.expected);
let addons = await promiseAddonsByIDs(["min1max1@tests.mozilla.org",
"min1max2@tests.mozilla.org",
"upgradeable1x2-3@tests.mozilla.org",
"min1max3@tests.mozilla.org",
"min1max3b@tests.mozilla.org",
"override1x2-1x3@tests.mozilla.org"]);
check_state_v2(addons);
});
// Upgrade back to version 3 which should only appDisable
// upgradeable1x2-3, because we already have the override
// stored in our DB for override1x2-1x3. Ensure that when
// the upgrade dialog updates an add-on no restart is necessary
add_task(async function run_test_5() {
Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true);
// tell the mock compatibility window to install the available upgrade
gInstallUpdate = true;
WindowWatcher.expected = true;
await promiseRestartManager("3");
check_startup_changes("installed", []);
check_startup_changes("updated", ["upgradeable1x2-3@tests.mozilla.org"]);
check_startup_changes("uninstalled", []);
check_startup_changes("disabled", []);
check_startup_changes("enabled", []);
do_check_false(WindowWatcher.expected);
gInstallUpdate = false;
let addons = await promiseAddonsByIDs(["min1max1@tests.mozilla.org",
"min1max2@tests.mozilla.org",
"upgradeable1x2-3@tests.mozilla.org",
"min1max3@tests.mozilla.org",
"min1max3b@tests.mozilla.org",
"override1x2-1x3@tests.mozilla.org"]);
check_state_v3_2(addons);
do_check_eq(WindowWatcher.args.length, 1);
do_check_true(WindowWatcher.args.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
});
// Downgrade to version 1 which will appEnable all the add-ons
// except upgradeable1x2-3; the update we installed isn't compatible with 1
add_task(async function run_test_6() {
WindowWatcher.expected = true;
await promiseRestartManager("1");
check_startup_changes("installed", []);
check_startup_changes("updated", []);
check_startup_changes("uninstalled", []);
check_startup_changes("disabled", ["upgradeable1x2-3@tests.mozilla.org"]);
check_startup_changes("enabled", ["min1max1@tests.mozilla.org"]);
do_check_false(WindowWatcher.expected);
let addons = await promiseAddonsByIDs(["min1max1@tests.mozilla.org",
"min1max2@tests.mozilla.org",
"upgradeable1x2-3@tests.mozilla.org",
"min1max3@tests.mozilla.org",
"min1max3b@tests.mozilla.org",
"override1x2-1x3@tests.mozilla.org"]);
check_state_v1_2(addons);
});

Просмотреть файл

@ -1,159 +0,0 @@
/* 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/.
*/
/*
* Test whether we need to block start-up to check add-on compatibility,
* based on how long since the last succesful metadata ping.
* All tests depend on having one add-on installed in the profile
*/
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
// Constants copied from AddonRepository.jsm
const PREF_METADATA_LASTUPDATE = "extensions.getAddons.cache.lastUpdate";
const PREF_METADATA_UPDATETHRESHOLD_SEC = "extensions.getAddons.cache.updateThreshold";
const DEFAULT_METADATA_UPDATETHRESHOLD_SEC = 172800; // two days
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
// None of this works without the add-on repository cache
Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", true);
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
var Cr = Components.results;
Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver;
const profileDir = gProfD.clone();
profileDir.append("extensions");
// This will be called to show the compatibility update dialog.
var WindowWatcher = {
expected: false,
openWindow(parent, url, name, features, args) {
do_check_true(Services.startup.interrupted);
do_check_eq(url, URI_EXTENSION_UPDATE_DIALOG);
do_check_true(this.expected);
this.expected = false;
},
QueryInterface(iid) {
if (iid.equals(Ci.nsIWindowWatcher)
|| iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
}
MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
// Return Date.now() in seconds, rounded
function now() {
return Math.round(Date.now() / 1000);
}
// First time with a new profile, so we don't have a cache.lastUpdate pref
add_task(async function checkFirstMetadata() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true);
// Create and configure the HTTP server.
testserver = createHttpServer();
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.registerDirectory("/addons/", do_get_file("addons"));
gPort = testserver.identity.primaryPort;
const BASE_URL = "http://localhost:" + gPort;
const GETADDONS_RESULTS = BASE_URL + "/data/test_AddonRepository_cache.xml";
Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, GETADDONS_RESULTS);
// Put an add-on in our profile so the metadata check will have something to do
var min1max2 = {
id: "min1max2@tests.mozilla.org",
version: "1.0",
name: "Test addon compatible with v1->v2",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "2"
}]
};
writeInstallRDFForExtension(min1max2, profileDir);
startupManager();
// Make sure that updating metadata for the first time sets the lastUpdate preference
await AddonRepository.repopulateCache();
do_print("Update done, getting last update");
let lastUpdate = Services.prefs.getIntPref(PREF_METADATA_LASTUPDATE);
do_check_true(lastUpdate > 0);
// Make sure updating metadata again updates the preference
let oldUpdate = lastUpdate - 2 * DEFAULT_METADATA_UPDATETHRESHOLD_SEC;
Services.prefs.setIntPref(PREF_METADATA_LASTUPDATE, oldUpdate);
await AddonRepository.repopulateCache();
do_check_neq(oldUpdate, Services.prefs.getIntPref(PREF_METADATA_LASTUPDATE));
});
// First upgrade with no lastUpdate pref and no add-ons changing shows UI
add_task(async function upgrade_no_lastupdate() {
Services.prefs.clearUserPref(PREF_METADATA_LASTUPDATE);
WindowWatcher.expected = true;
await promiseRestartManager("2");
do_check_false(WindowWatcher.expected);
});
// Upgrade with lastUpdate more than default threshold and no add-ons changing shows UI
add_task(async function upgrade_old_lastupdate() {
let oldEnough = now() - DEFAULT_METADATA_UPDATETHRESHOLD_SEC - 1000;
Services.prefs.setIntPref(PREF_METADATA_LASTUPDATE, oldEnough);
WindowWatcher.expected = true;
// upgrade, downgrade, it has the same effect on the code path under test
await promiseRestartManager("1");
do_check_false(WindowWatcher.expected);
});
// Upgrade with lastUpdate less than default threshold and no add-ons changing doesn't show
add_task(async function upgrade_young_lastupdate() {
let notOldEnough = now() - DEFAULT_METADATA_UPDATETHRESHOLD_SEC + 1000;
Services.prefs.setIntPref(PREF_METADATA_LASTUPDATE, notOldEnough);
WindowWatcher.expected = false;
await promiseRestartManager("2");
do_check_false(WindowWatcher.expected);
});
// Repeat more-than and less-than but with updateThreshold preference set
// Upgrade with lastUpdate more than pref threshold and no add-ons changing shows UI
const TEST_UPDATETHRESHOLD_SEC = 50000;
add_task(async function upgrade_old_pref_lastupdate() {
Services.prefs.setIntPref(PREF_METADATA_UPDATETHRESHOLD_SEC, TEST_UPDATETHRESHOLD_SEC);
let oldEnough = now() - TEST_UPDATETHRESHOLD_SEC - 1000;
Services.prefs.setIntPref(PREF_METADATA_LASTUPDATE, oldEnough);
WindowWatcher.expected = true;
await promiseRestartManager("1");
do_check_false(WindowWatcher.expected);
});
// Upgrade with lastUpdate less than pref threshold and no add-ons changing doesn't show
add_task(async function upgrade_young_pref_lastupdate() {
let notOldEnough = now() - TEST_UPDATETHRESHOLD_SEC + 1000;
Services.prefs.setIntPref(PREF_METADATA_LASTUPDATE, notOldEnough);
WindowWatcher.expected = false;
await promiseRestartManager("2");
do_check_false(WindowWatcher.expected);
});

Просмотреть файл

@ -137,8 +137,6 @@ tags = blocklist
[test_bug521905.js]
[test_bug526598.js]
[test_bug541420.js]
[test_bug542391.js]
run-sequentially = Uses hardcoded ports in xpi files.
[test_bug554133.js]
[test_bug559800.js]
[test_bug564030.js]

Просмотреть файл

@ -22,7 +22,6 @@ run-if = addon_signing
skip-if = appname != "firefox"
[test_hotfix_cert.js]
[test_isReady.js]
[test_metadata_update.js]
[test_pluginInfoURL.js]
tags = blocklist
[test_provider_markSafe.js]