gecko-dev/toolkit/webapps/tests/test_hosted_launch_no_registry.xul
Marco Castelluccio 416979553c Bug 1029674 - Fix installation of apps with custom origin. r=myk,keeler
--HG--
rename : toolkit/webapps/tests/test_packaged_launch.xul => toolkit/webapps/tests/test_custom_origin.xul
2014-07-04 15:23:16 +02:00

104 lines
2.9 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=981249
-->
<window title="Mozilla Bug 981249"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="head.js"/>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=981249"
target="_blank">Mozilla Bug 981249</a>
</body>
<script type="application/javascript">
<![CDATA[
/** Test for Bug 981249 **/
"use strict";
SimpleTest.waitForExplicitFinish();
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NativeApp.jsm");
Cu.import("resource://gre/modules/WebappOSUtils.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
let manifest = {
name: "test_desktop_hosted_launch_no_registry",
launch_path: "/chrome/toolkit/webapps/tests/app.sjs?appreq",
};
let app = {
name: "test_desktop_hosted_launch_no_registry",
manifestURL: "http://127.0.0.1:8888/sample_no_registry.manifest",
manifest: manifest,
origin: "http://127.0.0.1:8888/",
categories: [],
installOrigin: "http://127.0.0.1:8888/",
receipts: [],
installTime: Date.now(),
};
let testAppInfo = new TestAppInfo(app);
let runTest = Task.async(function*() {
// Get to a clean state before the test
yield testAppInfo.cleanup();
SimpleTest.registerCleanupFunction(() => testAppInfo.cleanup());
setDryRunPref();
let nativeApp = new NativeApp(app, manifest, app.categories);
ok(nativeApp, "NativeApp object created");
testAppInfo.profileDir = nativeApp.createProfile();
ok(testAppInfo.profileDir && testAppInfo.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) {
yield setMacRootInstallDir(OS.Path.join(OS.Constants.Path.homeDir, "Applications"));
}
// Install application
info("Test installation");
yield nativeApp.install(app, manifest);
while (!WebappOSUtils.isLaunchable(app)) {
yield wait(1000);
}
ok(true, "App launchable");
let exeFile = getFile(testAppInfo.exePath);
ok(exeFile.isExecutable(), "webapprt executable is executable");
let appClosed = false;
testAppInfo.appProcess.init(exeFile)
testAppInfo.appProcess.runAsync([], 0, () => appClosed = true);
while (!(yield wasAppSJSAccessed()) && !appClosed) {
yield wait(1000);
}
ok(!appClosed, "App was launched and is still running");
SimpleTest.finish();
});
runTest().catch((e) => {
ok(false, "Error during test: " + e);
SimpleTest.finish();
});
]]>
</script>
</window>