mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 675372 - Allow resource protocol mappings in chrome.manifest files of bootstrapped add-ons; r=Unfocused
This commit is contained in:
parent
53d60d7b4e
commit
5f61d9e5c4
@ -4445,6 +4445,13 @@ this.XPIProvider = {
|
||||
if (aMethod == "shutdown" && aReason != BOOTSTRAP_REASONS.APP_SHUTDOWN) {
|
||||
logger.debug("Removing manifest for " + aFile.path);
|
||||
Components.manager.removeBootstrappedManifestLocation(aFile);
|
||||
|
||||
let manifest = getURIForResourceInFile(aFile, "chrome.manifest");
|
||||
for (let line of ChromeManifestParser.parseSync(manifest)) {
|
||||
if (line.type == "resource") {
|
||||
ResProtocolHandler.setSubstitution(line.args[0], null);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.setTelemetry(aAddon.id, aMethod + "_MS", new Date() - timeStart);
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
resource test-addon-1 .
|
@ -0,0 +1,24 @@
|
||||
<?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>addon6@tests.mozilla.org</em:id>
|
||||
<em:version>1.0</em:version>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Test 6</em:name>
|
||||
<em:description>Test Description</em:description>
|
||||
<em:bootstrap>true</em:bootstrap>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>2</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
@ -0,0 +1,56 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that resource protocol substitutions are set and unset for bootstrapped add-ons.
|
||||
|
||||
const profileDir = gProfD.clone();
|
||||
profileDir.append("extensions");
|
||||
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
|
||||
|
||||
let resourceProtocol = Services.io.getProtocolHandler("resource")
|
||||
.QueryInterface(Components.interfaces.nsIResProtocolHandler);
|
||||
startupManager();
|
||||
|
||||
installAllFiles([do_get_addon("test_chromemanifest_6")],
|
||||
function() {
|
||||
|
||||
AddonManager.getAddonByID("addon6@tests.mozilla.org", function(addon) {
|
||||
do_check_neq(addon, null);
|
||||
do_check_true(addon.isActive);
|
||||
do_check_true(resourceProtocol.hasSubstitution("test-addon-1"));
|
||||
|
||||
prepare_test({
|
||||
"addon6@tests.mozilla.org": [
|
||||
["onDisabling", false],
|
||||
"onDisabled"
|
||||
]
|
||||
});
|
||||
|
||||
do_check_eq(addon.operationsRequiringRestart &
|
||||
AddonManager.OP_NEEDS_RESTART_DISABLE, 0);
|
||||
addon.userDisabled = true;
|
||||
ensure_test_completed();
|
||||
do_check_false(resourceProtocol.hasSubstitution("test-addon-1"))
|
||||
|
||||
prepare_test({
|
||||
"addon6@tests.mozilla.org": [
|
||||
["onEnabling", false],
|
||||
"onEnabled"
|
||||
]
|
||||
});
|
||||
|
||||
do_check_eq(addon.operationsRequiringRestart &
|
||||
AddonManager.OP_NEEDS_RESTART_ENABLE, 0);
|
||||
addon.userDisabled = false;
|
||||
ensure_test_completed();
|
||||
do_check_true(resourceProtocol.hasSubstitution("test-addon-1"));
|
||||
|
||||
do_execute_soon(do_test_finished);
|
||||
});
|
||||
});
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
// This verifies that flushing the zipreader cache happens when appropriate
|
||||
|
||||
var gExpectedFile = null;
|
||||
var gCacheFlushed = false;
|
||||
var gCacheFlushCount = 0;
|
||||
|
||||
var CacheFlushObserver = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
@ -15,16 +15,11 @@ var CacheFlushObserver = {
|
||||
do_check_true(gExpectedFile != null);
|
||||
do_check_true(aSubject instanceof AM_Ci.nsIFile);
|
||||
do_check_eq(aSubject.path, gExpectedFile.path);
|
||||
gCacheFlushed = true;
|
||||
gExpectedFile = null;
|
||||
gCacheFlushCount++;
|
||||
}
|
||||
};
|
||||
|
||||
function run_test() {
|
||||
// This test only makes sense when leaving extensions packed
|
||||
if (Services.prefs.getBoolPref("extensions.alwaysUnpack"))
|
||||
return;
|
||||
|
||||
do_test_pending();
|
||||
Services.obs.addObserver(CacheFlushObserver, "flush-cache-entry", false);
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "2");
|
||||
@ -45,8 +40,9 @@ function run_test_1() {
|
||||
gExpectedFile.append("addon1@tests.mozilla.org.xpi");
|
||||
aInstall.cancel();
|
||||
|
||||
do_check_true(gCacheFlushed);
|
||||
gCacheFlushed = false;
|
||||
do_check_eq(gCacheFlushCount, 1);
|
||||
gExpectedFile = null;
|
||||
gCacheFlushCount = 0;
|
||||
|
||||
run_test_2();
|
||||
});
|
||||
@ -62,18 +58,24 @@ function run_test_2() {
|
||||
gExpectedFile.append("staged");
|
||||
gExpectedFile.append("addon1@tests.mozilla.org.xpi");
|
||||
restartManager();
|
||||
do_check_true(gCacheFlushed);
|
||||
gCacheFlushed = false;
|
||||
do_check_eq(gCacheFlushCount, 1);
|
||||
gExpectedFile = null;
|
||||
gCacheFlushCount = 0;
|
||||
|
||||
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
|
||||
// We should flush the installed XPI when uninstalling
|
||||
do_check_true(a1 != null);
|
||||
a1.uninstall();
|
||||
do_check_eq(gCacheFlushCount, 0);
|
||||
|
||||
gExpectedFile = gProfD.clone();
|
||||
gExpectedFile.append("extensions");
|
||||
gExpectedFile.append("addon1@tests.mozilla.org.xpi");
|
||||
restartManager();
|
||||
do_check_eq(gCacheFlushCount, 1);
|
||||
gExpectedFile = null;
|
||||
gCacheFlushCount = 0;
|
||||
|
||||
do_check_true(a1 != null);
|
||||
a1.uninstall();
|
||||
do_check_false(gCacheFlushed);
|
||||
do_execute_soon(run_test_3);
|
||||
});
|
||||
});
|
||||
@ -81,8 +83,6 @@ function run_test_2() {
|
||||
|
||||
// Tests that the cache is flushed when installing a restartless add-on
|
||||
function run_test_3() {
|
||||
restartManager();
|
||||
|
||||
AddonManager.getInstallForFile(do_get_addon("test_cacheflush2"), function(aInstall) {
|
||||
aInstall.addListener({
|
||||
onInstallStarted: function(aInstall) {
|
||||
@ -94,8 +94,9 @@ function run_test_3() {
|
||||
},
|
||||
|
||||
onInstallEnded: function(aInstall) {
|
||||
do_check_true(gCacheFlushed);
|
||||
gCacheFlushed = false;
|
||||
do_check_eq(gCacheFlushCount, 1);
|
||||
gExpectedFile = null;
|
||||
gCacheFlushCount = 0;
|
||||
|
||||
do_execute_soon(run_test_4);
|
||||
}
|
||||
@ -114,8 +115,9 @@ function run_test_4() {
|
||||
gExpectedFile.append("addon2@tests.mozilla.org.xpi");
|
||||
|
||||
a2.uninstall();
|
||||
do_check_true(gCacheFlushed);
|
||||
gCacheFlushed = false;
|
||||
do_check_eq(gCacheFlushCount, 2);
|
||||
gExpectedFile = null;
|
||||
gCacheFlushCount = 0;
|
||||
|
||||
do_execute_soon(do_test_finished);
|
||||
});
|
||||
|
@ -29,6 +29,7 @@ skip-if = os == "android"
|
||||
[test_bootstrap.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_bootstrap_resource.js]
|
||||
[test_bug299716.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
@ -148,7 +149,6 @@ fail-if = os == "android"
|
||||
[test_bug753900.js]
|
||||
[test_bug757663.js]
|
||||
[test_bug953156.js]
|
||||
[test_cacheflush.js]
|
||||
[test_checkcompatibility.js]
|
||||
[test_checkCompatibility_themeOverride.js]
|
||||
[test_childprocess.js]
|
||||
|
@ -10,6 +10,7 @@ support-files =
|
||||
|
||||
[test_addon_path_service.js]
|
||||
[test_asyncBlocklistLoad.js]
|
||||
[test_cacheflush.js]
|
||||
[test_DeferredSave.js]
|
||||
[test_isReady.js]
|
||||
[test_metadata_update.js]
|
||||
|
@ -137,7 +137,7 @@ static const ManifestDirective kParsingTable[] = {
|
||||
nullptr, &nsChromeRegistry::ManifestOverride, nullptr
|
||||
},
|
||||
{
|
||||
"resource", 2, true, true, false, false,
|
||||
"resource", 2, true, true, true, false,
|
||||
nullptr, &nsChromeRegistry::ManifestResource, nullptr
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user