зеркало из https://github.com/mozilla/gecko-dev.git
Bug 993690 - Enable toolkit/webapps tests on Mac by installing apps in a directory that doesn't require admin privileges. r=myk
This commit is contained in:
Родитель
1e81d62a84
Коммит
85e439f9ec
|
@ -30,6 +30,13 @@ function NativeApp(aApp, aManifest, aCategories, aRegistryDir) {
|
|||
|
||||
NativeApp.prototype = {
|
||||
__proto__: CommonNativeApp.prototype,
|
||||
/*
|
||||
* The _rootInstallDir property is the path of the directory where we install
|
||||
* apps. In production code, it's "/Applications". In tests, it's
|
||||
* "~/Applications" because on build machines we don't have enough privileges
|
||||
* to write to the global "/Applications" directory.
|
||||
*/
|
||||
_rootInstallDir: LOCAL_APP_DIR,
|
||||
|
||||
/**
|
||||
* Creates a native installation of the web app in the OS
|
||||
|
@ -50,16 +57,16 @@ NativeApp.prototype = {
|
|||
|
||||
this._setData(aManifest);
|
||||
|
||||
let localAppDir = getFile(LOCAL_APP_DIR);
|
||||
let localAppDir = getFile(this._rootInstallDir);
|
||||
if (!localAppDir.isWritable()) {
|
||||
throw("Not enough privileges to install apps");
|
||||
}
|
||||
|
||||
let destinationName = yield getAvailableFileName([ LOCAL_APP_DIR ],
|
||||
|
||||
let destinationName = yield getAvailableFileName([ this._rootInstallDir ],
|
||||
this.appNameAsFilename,
|
||||
".app");
|
||||
|
||||
let installDir = OS.Path.join(LOCAL_APP_DIR, destinationName);
|
||||
let installDir = OS.Path.join(this._rootInstallDir, destinationName);
|
||||
|
||||
let dir = getFile(TMP_DIR, this.appNameAsFilename + ".app");
|
||||
dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
|
||||
|
|
|
@ -6,14 +6,12 @@ support-files =
|
|||
data/app/manifest.webapp
|
||||
|
||||
[test_hosted.xul]
|
||||
skip-if = os == "mac"
|
||||
[test_packaged.xul]
|
||||
skip-if = os == "mac"
|
||||
[test_hosted_launch.xul]
|
||||
skip-if = os == "mac" || asan
|
||||
skip-if = asan
|
||||
[test_hosted_launch_no_registry.xul]
|
||||
skip-if = os == "mac" || asan
|
||||
skip-if = asan
|
||||
[test_packaged_launch.xul]
|
||||
skip-if = os == "mac" || asan
|
||||
skip-if = asan
|
||||
[test_packaged_launch_no_registry.xul]
|
||||
skip-if = os == "mac" || asan
|
||||
skip-if = asan
|
||||
|
|
|
@ -7,6 +7,11 @@ Cu.import("resource://gre/modules/osfile.jsm");
|
|||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
|
||||
const LINUX = navigator.platform.startsWith("Linux");
|
||||
const MAC = navigator.platform.startsWith("Mac");
|
||||
const WIN = navigator.platform.startsWith("Win");
|
||||
const MAC_106 = navigator.userAgent.contains("Mac OS X 10.6");
|
||||
|
||||
function checkFiles(files) {
|
||||
return Task.spawn(function*() {
|
||||
for (let file of files) {
|
||||
|
@ -55,3 +60,20 @@ function getFile() {
|
|||
file.initWithPath(OS.Path.join.apply(OS.Path, arguments));
|
||||
return file;
|
||||
}
|
||||
|
||||
function setDryRunPref() {
|
||||
let old_dry_run;
|
||||
try {
|
||||
old_dry_run = Services.prefs.getBoolPref("browser.mozApps.installer.dry_run");
|
||||
} catch (ex) {}
|
||||
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
if (old_dry_run === undefined) {
|
||||
Services.prefs.clearUserPref("browser.mozApps.installer.dry_run");
|
||||
} else {
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", old_dry_run);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ let updatedFiles;
|
|||
|
||||
let cleanup;
|
||||
|
||||
if (navigator.platform.startsWith("Linux")) {
|
||||
if (LINUX) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "." + WebappOSUtils.getUniqueName(app));
|
||||
|
||||
let xdg_data_home = Cc["@mozilla.org/process/environment;1"].
|
||||
|
@ -99,7 +99,7 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(desktopINI, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Win")) {
|
||||
} else if (WIN) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.winAppDataDir, WebappOSUtils.getUniqueName(app));
|
||||
|
||||
let desktopShortcut = OS.Path.join(OS.Constants.Path.desktopDir, "Sample hosted app.lnk");
|
||||
|
@ -165,8 +165,8 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Mac")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.macLocalApplicationsDir, "Sample hosted app.app");
|
||||
} else if (MAC) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "Sample hosted app.app");
|
||||
let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
|
||||
WebappOSUtils.getUniqueName(app));
|
||||
|
||||
|
@ -205,27 +205,14 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
};
|
||||
}
|
||||
|
||||
let old_dry_run;
|
||||
try {
|
||||
old_dry_run = Services.prefs.getBoolPref("browser.mozApps.installer.dry_run");
|
||||
} catch (ex) {}
|
||||
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
if (old_dry_run === undefined) {
|
||||
Services.prefs.clearUserPref("browser.mozApps.installer.dry_run");
|
||||
} else {
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", old_dry_run);
|
||||
}
|
||||
|
||||
cleanup();
|
||||
});
|
||||
|
||||
Task.spawn(function() {
|
||||
let runTest = Task.async(function*() {
|
||||
// Get to a clean state before the test
|
||||
yield cleanup();
|
||||
|
||||
SimpleTest.registerCleanupFunction(cleanup);
|
||||
|
||||
setDryRunPref();
|
||||
|
||||
let nativeApp = new NativeApp(app, manifest, app.categories);
|
||||
ok(nativeApp, "NativeApp object created");
|
||||
|
||||
|
@ -241,6 +228,13 @@ Task.spawn(function() {
|
|||
ok(profileDir && profileDir.exists(), "Profile directory created");
|
||||
ok((yield OS.File.exists(profilesIni)), "profiles.ini file created");
|
||||
|
||||
// On Mac build servers, we don't have enough privileges to write to /Applications,
|
||||
// so we install apps in a user-owned directory.
|
||||
if (MAC) {
|
||||
nativeApp._rootInstallDir = OS.Path.join(OS.Constants.Path.homeDir, "Applications");
|
||||
yield OS.File.makeDir(nativeApp._rootInstallDir, { ignoreExisting: true });
|
||||
}
|
||||
|
||||
// Install application
|
||||
info("Test installation");
|
||||
yield nativeApp.install(manifest);
|
||||
|
@ -301,12 +295,21 @@ Task.spawn(function() {
|
|||
ok(!(yield OS.File.exists(OS.Path.join(installPath, "update"))), "Update directory removed");
|
||||
ok((yield checkDateHigherThan(updatedFiles, installTime)), "Modification date higher");
|
||||
|
||||
SimpleTest.finish();
|
||||
}).then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
// The test doesn't work yet on Mac OS X 10.6 machines.
|
||||
// See bug 993690.
|
||||
if (MAC_106) {
|
||||
todo(false, "The test doesn't work on Mac OS X 10.6 machines");
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
runTest().then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
|
|
@ -54,7 +54,7 @@ let appProcess = Cc["@mozilla.org/process/util;1"].
|
|||
|
||||
let cleanup;
|
||||
|
||||
if (navigator.platform.startsWith("Linux")) {
|
||||
if (LINUX) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "." + WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "webapprt-stub");
|
||||
|
||||
|
@ -83,7 +83,7 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(desktopINI, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Win")) {
|
||||
} else if (WIN) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.winAppDataDir, WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "test_desktop_hosted_launch.exe");
|
||||
|
||||
|
@ -123,8 +123,8 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Mac")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.macLocalApplicationsDir, "test_desktop_hosted_launch.app");
|
||||
} else if (MAC) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_hosted_launch.app");
|
||||
exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
|
||||
|
||||
let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
|
||||
|
@ -147,23 +147,6 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
};
|
||||
}
|
||||
|
||||
let old_dry_run;
|
||||
try {
|
||||
old_dry_run = Services.prefs.getBoolPref("browser.mozApps.installer.dry_run");
|
||||
} catch (ex) {}
|
||||
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
if (old_dry_run === undefined) {
|
||||
Services.prefs.clearUserPref("browser.mozApps.installer.dry_run");
|
||||
} else {
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", old_dry_run);
|
||||
}
|
||||
|
||||
cleanup();
|
||||
});
|
||||
|
||||
function wasAppSJSAccessed() {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
|
@ -183,16 +166,27 @@ function wasAppSJSAccessed() {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
Task.spawn(function*() {
|
||||
let runTest = Task.async(function*() {
|
||||
// Get to a clean state before the test
|
||||
yield cleanup();
|
||||
|
||||
SimpleTest.registerCleanupFunction(cleanup);
|
||||
|
||||
setDryRunPref();
|
||||
|
||||
let nativeApp = new NativeApp(app, manifest, app.categories);
|
||||
ok(nativeApp, "NativeApp object created");
|
||||
|
||||
profileDir = nativeApp.createProfile();
|
||||
ok(profileDir && profileDir.exists(), "Profile directory created");
|
||||
|
||||
// On Mac build servers, we don't have enough privileges to write to /Applications,
|
||||
// so we install apps in a user-owned directory.
|
||||
if (MAC) {
|
||||
nativeApp._rootInstallDir = OS.Path.join(OS.Constants.Path.homeDir, "Applications");
|
||||
yield OS.File.makeDir(nativeApp._rootInstallDir, { ignoreExisting: true });
|
||||
}
|
||||
|
||||
// Install application
|
||||
info("Test installation");
|
||||
yield nativeApp.install(manifest);
|
||||
|
@ -215,12 +209,21 @@ Task.spawn(function*() {
|
|||
}
|
||||
ok(!appClosed, "App was launched and is still running");
|
||||
|
||||
SimpleTest.finish();
|
||||
}).then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
// The test doesn't work yet on Mac OS X 10.6 machines.
|
||||
// See bug 993690.
|
||||
if (MAC_106) {
|
||||
todo(false, "The test doesn't work on Mac OS X 10.6 machines");
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
runTest().then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
|
|
@ -54,7 +54,7 @@ let appProcess = Cc["@mozilla.org/process/util;1"].
|
|||
|
||||
let cleanup;
|
||||
|
||||
if (navigator.platform.startsWith("Linux")) {
|
||||
if (LINUX) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "." + WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "webapprt-stub");
|
||||
|
||||
|
@ -83,7 +83,7 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(desktopINI, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Win")) {
|
||||
} else if (WIN) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.winAppDataDir, WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "test_desktop_hosted_launch_no_registry.exe");
|
||||
|
||||
|
@ -123,8 +123,8 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Mac")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.macLocalApplicationsDir, "test_desktop_hosted_launch_no_registry.app");
|
||||
} else if (MAC) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_hosted_launch_no_registry.app");
|
||||
exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
|
||||
|
||||
let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
|
||||
|
@ -147,23 +147,6 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
};
|
||||
}
|
||||
|
||||
let old_dry_run;
|
||||
try {
|
||||
old_dry_run = Services.prefs.getBoolPref("browser.mozApps.installer.dry_run");
|
||||
} catch (ex) {}
|
||||
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
if (old_dry_run === undefined) {
|
||||
Services.prefs.clearUserPref("browser.mozApps.installer.dry_run");
|
||||
} else {
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", old_dry_run);
|
||||
}
|
||||
|
||||
cleanup();
|
||||
});
|
||||
|
||||
function wasAppSJSAccessed() {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
|
@ -183,16 +166,27 @@ function wasAppSJSAccessed() {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
Task.spawn(function*() {
|
||||
let runTest = Task.async(function*() {
|
||||
// Get to a clean state before the test
|
||||
yield cleanup();
|
||||
|
||||
SimpleTest.registerCleanupFunction(cleanup);
|
||||
|
||||
setDryRunPref();
|
||||
|
||||
let nativeApp = new NativeApp(app, manifest, app.categories);
|
||||
ok(nativeApp, "NativeApp object created");
|
||||
|
||||
profileDir = nativeApp.createProfile();
|
||||
ok(profileDir && profileDir.exists(), "Profile directory created");
|
||||
|
||||
// On Mac build servers, we don't have enough privileges to write to /Applications,
|
||||
// so we install apps in a user-owned directory.
|
||||
if (MAC) {
|
||||
nativeApp._rootInstallDir = OS.Path.join(OS.Constants.Path.homeDir, "Applications");
|
||||
yield OS.File.makeDir(nativeApp._rootInstallDir, { ignoreExisting: true });
|
||||
}
|
||||
|
||||
// Install application
|
||||
info("Test installation");
|
||||
yield nativeApp.install(manifest);
|
||||
|
@ -215,12 +209,21 @@ Task.spawn(function*() {
|
|||
}
|
||||
ok(!appClosed, "App was launched and is still running");
|
||||
|
||||
SimpleTest.finish();
|
||||
}).then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
// The test doesn't work yet on Mac OS X 10.6 machines.
|
||||
// See bug 993690.
|
||||
if (MAC_106) {
|
||||
todo(false, "The test doesn't work on Mac OS X 10.6 machines");
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
runTest().then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
|
|
@ -60,7 +60,7 @@ let updatedFiles;
|
|||
|
||||
let cleanup;
|
||||
|
||||
if (navigator.platform.startsWith("Linux")) {
|
||||
if (LINUX) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "." + WebappOSUtils.getUniqueName(app));
|
||||
|
||||
let xdg_data_home = Cc["@mozilla.org/process/environment;1"].
|
||||
|
@ -108,7 +108,7 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(desktopINI, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Win")) {
|
||||
} else if (WIN) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.winAppDataDir, WebappOSUtils.getUniqueName(app));
|
||||
|
||||
let desktopShortcut = OS.Path.join(OS.Constants.Path.desktopDir, "Sample packaged app.lnk");
|
||||
|
@ -177,8 +177,8 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Mac")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.macLocalApplicationsDir, "Sample packaged app.app");
|
||||
} else if (MAC) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "Sample packaged app.app");
|
||||
let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
|
||||
WebappOSUtils.getUniqueName(app));
|
||||
|
||||
|
@ -220,27 +220,14 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
};
|
||||
}
|
||||
|
||||
let old_dry_run;
|
||||
try {
|
||||
old_dry_run = Services.prefs.getBoolPref("browser.mozApps.installer.dry_run");
|
||||
} catch (ex) {}
|
||||
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
if (old_dry_run === undefined) {
|
||||
Services.prefs.clearUserPref("browser.mozApps.installer.dry_run");
|
||||
} else {
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", old_dry_run);
|
||||
}
|
||||
|
||||
cleanup();
|
||||
});
|
||||
|
||||
Task.spawn(function() {
|
||||
let runTest = Task.async(function*() {
|
||||
// Get to a clean state before the test
|
||||
yield cleanup();
|
||||
|
||||
SimpleTest.registerCleanupFunction(cleanup);
|
||||
|
||||
setDryRunPref();
|
||||
|
||||
let zipFile = yield OS.File.open(zipPath, { create: true });
|
||||
yield zipFile.close();
|
||||
|
||||
|
@ -259,6 +246,13 @@ Task.spawn(function() {
|
|||
ok(profileDir && profileDir.exists(), "Profile directory created");
|
||||
ok((yield OS.File.exists(profilesIni)), "profiles.ini file created");
|
||||
|
||||
// On Mac build servers, we don't have enough privileges to write to /Applications,
|
||||
// so we install apps in a user-owned directory.
|
||||
if (MAC) {
|
||||
nativeApp._rootInstallDir = OS.Path.join(OS.Constants.Path.homeDir, "Applications");
|
||||
yield OS.File.makeDir(nativeApp._rootInstallDir, { ignoreExisting: true });
|
||||
}
|
||||
|
||||
// Install application
|
||||
info("Test installation");
|
||||
yield nativeApp.install(manifest, zipPath);
|
||||
|
@ -327,12 +321,21 @@ Task.spawn(function() {
|
|||
ok(!(yield OS.File.exists(OS.Path.join(installPath, "update"))), "Update directory removed");
|
||||
ok((yield checkDateHigherThan(updatedFiles, installTime)), "Modification date higher");
|
||||
|
||||
SimpleTest.finish();
|
||||
}).then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
// The test doesn't work yet on Mac OS X 10.6 machines.
|
||||
// See bug 993690.
|
||||
if (MAC_106) {
|
||||
todo(false, "The test doesn't work on Mac OS X 10.6 machines");
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
runTest().then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
|
|
@ -64,7 +64,7 @@ let appProcess = Cc["@mozilla.org/process/util;1"].
|
|||
|
||||
let cleanup;
|
||||
|
||||
if (navigator.platform.startsWith("Linux")) {
|
||||
if (LINUX) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "." + WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "webapprt-stub");
|
||||
|
||||
|
@ -93,7 +93,7 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(desktopINI, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Win")) {
|
||||
} else if (WIN) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.winAppDataDir, WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "test_desktop_packaged_launch.exe");
|
||||
|
||||
|
@ -133,8 +133,8 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Mac")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.macLocalApplicationsDir, "test_desktop_packaged_launch.app");
|
||||
} else if (MAC) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_packaged_launch.app");
|
||||
exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
|
||||
|
||||
let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
|
||||
|
@ -157,23 +157,6 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
};
|
||||
}
|
||||
|
||||
let old_dry_run;
|
||||
try {
|
||||
old_dry_run = Services.prefs.getBoolPref("browser.mozApps.installer.dry_run");
|
||||
} catch (ex) {}
|
||||
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
if (old_dry_run === undefined) {
|
||||
Services.prefs.clearUserPref("browser.mozApps.installer.dry_run");
|
||||
} else {
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", old_dry_run);
|
||||
}
|
||||
|
||||
cleanup();
|
||||
});
|
||||
|
||||
function buildAppPackage() {
|
||||
let zipFile = getFile(OS.Constants.Path.profileDir, "sample.zip");
|
||||
|
||||
|
@ -211,10 +194,14 @@ function wasAppSJSAccessed() {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
Task.spawn(function() {
|
||||
let runTest = Task.async(function*() {
|
||||
// Get to a clean state before the test
|
||||
yield cleanup();
|
||||
|
||||
SimpleTest.registerCleanupFunction(cleanup);
|
||||
|
||||
setDryRunPref();
|
||||
|
||||
let zipPath = buildAppPackage();
|
||||
|
||||
let nativeApp = new NativeApp(app, manifest, app.categories);
|
||||
|
@ -223,6 +210,13 @@ Task.spawn(function() {
|
|||
profileDir = nativeApp.createProfile();
|
||||
ok(profileDir && profileDir.exists(), "Profile directory created");
|
||||
|
||||
// On Mac build servers, we don't have enough privileges to write to /Applications,
|
||||
// so we install apps in a user-owned directory.
|
||||
if (MAC) {
|
||||
nativeApp._rootInstallDir = OS.Path.join(OS.Constants.Path.homeDir, "Applications");
|
||||
yield OS.File.makeDir(nativeApp._rootInstallDir, { ignoreExisting: true });
|
||||
}
|
||||
|
||||
// Install application
|
||||
info("Test installation");
|
||||
yield nativeApp.install(manifest, zipPath);
|
||||
|
@ -245,12 +239,21 @@ Task.spawn(function() {
|
|||
}
|
||||
ok(!appClosed, "App was launched and is still running");
|
||||
|
||||
SimpleTest.finish();
|
||||
}).then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
// The test doesn't work yet on Mac OS X 10.6 machines.
|
||||
// See bug 993690.
|
||||
if (MAC_106) {
|
||||
todo(false, "The test doesn't work on Mac OS X 10.6 machines");
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
runTest().then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
|
|
@ -64,7 +64,7 @@ let appProcess = Cc["@mozilla.org/process/util;1"].
|
|||
|
||||
let cleanup;
|
||||
|
||||
if (navigator.platform.startsWith("Linux")) {
|
||||
if (LINUX) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "." + WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "webapprt-stub");
|
||||
|
||||
|
@ -93,7 +93,7 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(desktopINI, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Win")) {
|
||||
} else if (WIN) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.winAppDataDir, WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "test_desktop_packaged_launch_no_registry.exe");
|
||||
|
||||
|
@ -133,8 +133,8 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
yield OS.File.remove(startMenuShortcut, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Mac")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.macLocalApplicationsDir, "test_desktop_packaged_launch_no_registry.app");
|
||||
} else if (MAC) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "Applications", "test_desktop_packaged_launch_no_registry.app");
|
||||
exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
|
||||
|
||||
let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
|
||||
|
@ -157,23 +157,6 @@ if (navigator.platform.startsWith("Linux")) {
|
|||
};
|
||||
}
|
||||
|
||||
let old_dry_run;
|
||||
try {
|
||||
old_dry_run = Services.prefs.getBoolPref("browser.mozApps.installer.dry_run");
|
||||
} catch (ex) {}
|
||||
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
if (old_dry_run === undefined) {
|
||||
Services.prefs.clearUserPref("browser.mozApps.installer.dry_run");
|
||||
} else {
|
||||
Services.prefs.setBoolPref("browser.mozApps.installer.dry_run", old_dry_run);
|
||||
}
|
||||
|
||||
cleanup();
|
||||
});
|
||||
|
||||
function buildAppPackage() {
|
||||
let zipFile = getFile(OS.Constants.Path.profileDir, "sample.zip");
|
||||
|
||||
|
@ -211,10 +194,14 @@ function wasAppSJSAccessed() {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
Task.spawn(function() {
|
||||
let runTest = Task.async(function*() {
|
||||
// Get to a clean state before the test
|
||||
yield cleanup();
|
||||
|
||||
SimpleTest.registerCleanupFunction(cleanup);
|
||||
|
||||
setDryRunPref();
|
||||
|
||||
let zipPath = buildAppPackage();
|
||||
|
||||
let nativeApp = new NativeApp(app, manifest, app.categories);
|
||||
|
@ -223,6 +210,13 @@ Task.spawn(function() {
|
|||
profileDir = nativeApp.createProfile();
|
||||
ok(profileDir && profileDir.exists(), "Profile directory created");
|
||||
|
||||
// On Mac build servers, we don't have enough privileges to write to /Applications,
|
||||
// so we install apps in a user-owned directory.
|
||||
if (MAC) {
|
||||
nativeApp._rootInstallDir = OS.Path.join(OS.Constants.Path.homeDir, "Applications");
|
||||
yield OS.File.makeDir(nativeApp._rootInstallDir, { ignoreExisting: true });
|
||||
}
|
||||
|
||||
// Install application
|
||||
info("Test installation");
|
||||
yield nativeApp.install(manifest, zipPath);
|
||||
|
@ -245,12 +239,21 @@ Task.spawn(function() {
|
|||
}
|
||||
ok(!appClosed, "App was launched and is still running");
|
||||
|
||||
SimpleTest.finish();
|
||||
}).then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
// The test doesn't work yet on Mac OS X 10.6 machines.
|
||||
// See bug 993690.
|
||||
if (MAC_106) {
|
||||
todo(false, "The test doesn't work on Mac OS X 10.6 machines");
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
runTest().then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
|
Загрузка…
Ссылка в новой задаче