mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 981249 - Test app launch. r=myk
--HG-- rename : toolkit/webapps/tests/test_hosted.xul => toolkit/webapps/tests/test_hosted_launch.xul rename : toolkit/webapps/tests/test_packaged.xul => toolkit/webapps/tests/test_packaged_launch.xul
This commit is contained in:
parent
9e58fd9ab5
commit
2982bfa483
@ -94,5 +94,21 @@
|
||||
"manifestURL": "https://aprivileged.com/manifest.webapp",
|
||||
"description": "https://aprivileged.com Privileged App ",
|
||||
"appStatus": 2
|
||||
},
|
||||
{
|
||||
"name": "test_desktop_hosted_launch",
|
||||
"csp": "",
|
||||
"origin": "http://127.0.0.1:8888/",
|
||||
"manifestURL": "http://127.0.0.1:8888/sample.manifest",
|
||||
"description": "Hosted app",
|
||||
"appStatus": 1
|
||||
},
|
||||
{
|
||||
"name": "test_desktop_packaged_launch",
|
||||
"csp": "",
|
||||
"origin": "app://test_desktop_packaged_launch",
|
||||
"manifestURL": "http://127.0.0.1:8888/sample.manifest",
|
||||
"description": "Packaged App",
|
||||
"appStatus": 2
|
||||
}
|
||||
]
|
||||
|
33
toolkit/webapps/tests/app.sjs
Normal file
33
toolkit/webapps/tests/app.sjs
Normal file
@ -0,0 +1,33 @@
|
||||
function getQuery(request) {
|
||||
let query = {};
|
||||
|
||||
request.queryString.split('&').forEach(function(val) {
|
||||
let [name, value] = val.split('=');
|
||||
query[name] = unescape(value);
|
||||
});
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
function handleRequest(request, response) {
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
|
||||
let query = getQuery(request);
|
||||
|
||||
if ("appreq" in query) {
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
response.write("Hello world!");
|
||||
|
||||
setState("appreq", "done");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ("testreq" in query) {
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
|
||||
response.write(getState("appreq"));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
@ -1,8 +1,15 @@
|
||||
[DEFAULT]
|
||||
support-files =
|
||||
head.js
|
||||
app.sjs
|
||||
data/app/index.html
|
||||
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
|
||||
[test_packaged_launch.xul]
|
||||
skip-if = os == "mac" || asan
|
||||
|
10
toolkit/webapps/tests/data/app/index.html
Normal file
10
toolkit/webapps/tests/data/app/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test app</title>
|
||||
</head>
|
||||
<body>
|
||||
Test app:
|
||||
<iframe src="http://127.0.0.1:8888/chrome/toolkit/webapps/tests/app.sjs?appreq"></iframe>
|
||||
</body>
|
||||
</html>
|
5
toolkit/webapps/tests/data/app/manifest.webapp
Normal file
5
toolkit/webapps/tests/data/app/manifest.webapp
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Test app",
|
||||
"description": "A test application",
|
||||
"launch_path": "/index.html"
|
||||
}
|
@ -48,3 +48,10 @@ function wait(time) {
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// Helper to create a nsIFile from a set of path components
|
||||
function getFile() {
|
||||
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
||||
file.initWithPath(OS.Path.join.apply(OS.Path, arguments));
|
||||
return file;
|
||||
}
|
||||
|
@ -249,6 +249,7 @@ Task.spawn(function() {
|
||||
}
|
||||
ok(true, "App launchable");
|
||||
ok((yield checkFiles(installedFiles)), "Files correctly written");
|
||||
is(WebappOSUtils.getInstallPath(app), installPath, "getInstallPath == installPath");
|
||||
|
||||
let stat = yield OS.File.stat(installPath);
|
||||
let installTime = stat.lastModificationDate;
|
||||
|
226
toolkit/webapps/tests/test_hosted_launch.xul
Normal file
226
toolkit/webapps/tests/test_hosted_launch.xul
Normal file
@ -0,0 +1,226 @@
|
||||
<?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",
|
||||
launch_path: "/chrome/toolkit/webapps/tests/app.sjs?appreq",
|
||||
};
|
||||
|
||||
let app = {
|
||||
name: "test_desktop_hosted_launch",
|
||||
manifestURL: "http://127.0.0.1:8888/sample.manifest",
|
||||
manifest: manifest,
|
||||
origin: "http://127.0.0.1:8888/",
|
||||
categories: [],
|
||||
installOrigin: "http://127.0.0.1:8888/",
|
||||
receipts: [],
|
||||
installTime: Date.now(),
|
||||
};
|
||||
|
||||
let profileDir;
|
||||
let installPath;
|
||||
let exePath;
|
||||
let appProcess = Cc["@mozilla.org/process/util;1"].
|
||||
createInstance(Ci.nsIProcess);
|
||||
|
||||
let cleanup;
|
||||
|
||||
if (navigator.platform.startsWith("Linux")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "." + WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "webapprt-stub");
|
||||
|
||||
let xdg_data_home = Cc["@mozilla.org/process/environment;1"].
|
||||
getService(Ci.nsIEnvironment).
|
||||
get("XDG_DATA_HOME");
|
||||
if (!xdg_data_home) {
|
||||
xdg_data_home = OS.Path.join(OS.Constants.Path.homeDir, ".local", "share");
|
||||
}
|
||||
|
||||
let desktopINI = OS.Path.join(xdg_data_home, "applications",
|
||||
"owa-" + WebappOSUtils.getUniqueName(app) + ".desktop");
|
||||
|
||||
cleanup = function() {
|
||||
return Task.spawn(function*() {
|
||||
if (appProcess.isRunning) {
|
||||
appProcess.kill();
|
||||
}
|
||||
|
||||
if (profileDir) {
|
||||
yield OS.File.removeDir(profileDir.parent.path, { ignoreAbsent: true });
|
||||
}
|
||||
|
||||
yield OS.File.removeDir(installPath, { ignoreAbsent: true });
|
||||
|
||||
yield OS.File.remove(desktopINI, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Win")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.winAppDataDir, WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "test_desktop_hosted_launch.exe");
|
||||
|
||||
let desktopShortcut = OS.Path.join(OS.Constants.Path.desktopDir, "test_desktop_hosted_launch.lnk");
|
||||
let startMenuShortcut = OS.Path.join(OS.Constants.Path.winStartMenuProgsDir, "test_desktop_hosted_launch.lnk");
|
||||
|
||||
cleanup = function() {
|
||||
return Task.spawn(function*() {
|
||||
if (appProcess.isRunning) {
|
||||
appProcess.kill();
|
||||
}
|
||||
|
||||
let uninstallKey;
|
||||
try {
|
||||
uninstallKey = Cc["@mozilla.org/windows-registry-key;1"].
|
||||
createInstance(Ci.nsIWindowsRegKey);
|
||||
uninstallKey.open(uninstallKey.ROOT_KEY_CURRENT_USER,
|
||||
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
|
||||
uninstallKey.ACCESS_WRITE);
|
||||
if (uninstallKey.hasChild(WebappOSUtils.getUniqueName(app))) {
|
||||
uninstallKey.removeChild(WebappOSUtils.getUniqueName(app));
|
||||
}
|
||||
} catch (e) {
|
||||
} finally {
|
||||
if (uninstallKey) {
|
||||
uninstallKey.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (profileDir) {
|
||||
yield OS.File.removeDir(profileDir.parent.parent.path, { ignoreAbsent: true });
|
||||
}
|
||||
|
||||
yield OS.File.removeDir(installPath, { ignoreAbsent: true });
|
||||
|
||||
yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
|
||||
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");
|
||||
exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
|
||||
|
||||
let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
|
||||
WebappOSUtils.getUniqueName(app));
|
||||
|
||||
cleanup = function() {
|
||||
return Task.spawn(function*() {
|
||||
if (appProcess.isRunning) {
|
||||
appProcess.kill();
|
||||
}
|
||||
|
||||
if (profileDir) {
|
||||
yield OS.File.removeDir(profileDir.parent.path, { ignoreAbsent: true });
|
||||
}
|
||||
|
||||
yield OS.File.removeDir(installPath, { ignoreAbsent: true });
|
||||
|
||||
yield OS.File.removeDir(appProfileDir, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.addEventListener("load", function() {
|
||||
let ret = (xhr.responseText == "done") ? true : false;
|
||||
deferred.resolve(ret);
|
||||
});
|
||||
|
||||
xhr.addEventListener("error", aError => deferred.reject(aError));
|
||||
xhr.addEventListener("abort", aError => deferred.reject(aError));
|
||||
|
||||
xhr.open('GET', 'http://test/chrome/toolkit/webapps/tests/app.sjs?testreq', true);
|
||||
xhr.send();
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
Task.spawn(function*() {
|
||||
// Get to a clean state before the test
|
||||
yield cleanup();
|
||||
|
||||
let nativeApp = new NativeApp(app, manifest, app.categories);
|
||||
ok(nativeApp, "NativeApp object created");
|
||||
|
||||
profileDir = nativeApp.createProfile();
|
||||
ok(profileDir && profileDir.exists(), "Profile directory created");
|
||||
|
||||
// Install application
|
||||
info("Test installation");
|
||||
yield nativeApp.install(manifest);
|
||||
while (!WebappOSUtils.isLaunchable(app)) {
|
||||
yield wait(1000);
|
||||
}
|
||||
ok(true, "App launchable");
|
||||
|
||||
let exeFile = getFile(exePath);
|
||||
|
||||
ok(exeFile.isExecutable(), "webapprt executable is executable");
|
||||
|
||||
let appClosed = false;
|
||||
|
||||
appProcess.init(exeFile)
|
||||
appProcess.runAsync([], 0, () => appClosed = true);
|
||||
|
||||
while (!(yield wasAppSJSAccessed()) && !appClosed) {
|
||||
yield wait(1000);
|
||||
}
|
||||
ok(!appClosed, "App was launched and is still running");
|
||||
|
||||
SimpleTest.finish();
|
||||
}).then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
@ -267,6 +267,7 @@ Task.spawn(function() {
|
||||
}
|
||||
ok(true, "App launchable");
|
||||
ok((yield checkFiles(installedFiles)), "Files correctly written");
|
||||
is(WebappOSUtils.getInstallPath(app), installPath, "getInstallPath == installPath");
|
||||
|
||||
let stat = yield OS.File.stat(installPath);
|
||||
let installTime = stat.lastModificationDate;
|
||||
|
256
toolkit/webapps/tests/test_packaged_launch.xul
Normal file
256
toolkit/webapps/tests/test_packaged_launch.xul
Normal file
@ -0,0 +1,256 @@
|
||||
<?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="chrome://mochikit/content/chrome-harness.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");
|
||||
|
||||
const PR_RDWR = 0x04;
|
||||
const PR_CREATE_FILE = 0x08;
|
||||
const PR_TRUNCATE = 0x20;
|
||||
|
||||
let manifest = {
|
||||
name: "test_desktop_packaged_launch",
|
||||
version: "0.1a",
|
||||
size: 777,
|
||||
package_path: "/data/app.zip",
|
||||
launch_path: "/index.html",
|
||||
};
|
||||
|
||||
let app = {
|
||||
name: "test_desktop_packaged_launch",
|
||||
manifestURL: "http://127.0.0.1:8888/sample.manifest",
|
||||
manifest: manifest,
|
||||
updateManifest: manifest,
|
||||
origin: "app://test_desktop_packaged_launch/",
|
||||
categories: [],
|
||||
installOrigin: "http://127.0.0.1:8888/",
|
||||
receipts: [],
|
||||
installTime: Date.now(),
|
||||
};
|
||||
|
||||
let profileDir;
|
||||
let installPath;
|
||||
let exePath;
|
||||
let appProcess = Cc["@mozilla.org/process/util;1"].
|
||||
createInstance(Ci.nsIProcess);
|
||||
|
||||
let cleanup;
|
||||
|
||||
if (navigator.platform.startsWith("Linux")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.homeDir, "." + WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "webapprt-stub");
|
||||
|
||||
let xdg_data_home = Cc["@mozilla.org/process/environment;1"].
|
||||
getService(Ci.nsIEnvironment).
|
||||
get("XDG_DATA_HOME");
|
||||
if (!xdg_data_home) {
|
||||
xdg_data_home = OS.Path.join(OS.Constants.Path.homeDir, ".local", "share");
|
||||
}
|
||||
|
||||
let desktopINI = OS.Path.join(xdg_data_home, "applications",
|
||||
"owa-" + WebappOSUtils.getUniqueName(app) + ".desktop");
|
||||
|
||||
cleanup = function() {
|
||||
return Task.spawn(function*() {
|
||||
if (appProcess.isRunning) {
|
||||
appProcess.kill();
|
||||
}
|
||||
|
||||
if (profileDir) {
|
||||
yield OS.File.removeDir(profileDir.parent.path, { ignoreAbsent: true });
|
||||
}
|
||||
|
||||
yield OS.File.removeDir(installPath, { ignoreAbsent: true });
|
||||
|
||||
yield OS.File.remove(desktopINI, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
} else if (navigator.platform.startsWith("Win")) {
|
||||
installPath = OS.Path.join(OS.Constants.Path.winAppDataDir, WebappOSUtils.getUniqueName(app));
|
||||
exePath = OS.Path.join(installPath, "test_desktop_packaged_launch.exe");
|
||||
|
||||
let desktopShortcut = OS.Path.join(OS.Constants.Path.desktopDir, "test_desktop_packaged_launch.lnk");
|
||||
let startMenuShortcut = OS.Path.join(OS.Constants.Path.winStartMenuProgsDir, "test_desktop_packaged_launch.lnk");
|
||||
|
||||
cleanup = function() {
|
||||
return Task.spawn(function*() {
|
||||
if (appProcess.isRunning) {
|
||||
appProcess.kill();
|
||||
}
|
||||
|
||||
let uninstallKey;
|
||||
try {
|
||||
uninstallKey = Cc["@mozilla.org/windows-registry-key;1"].
|
||||
createInstance(Ci.nsIWindowsRegKey);
|
||||
uninstallKey.open(uninstallKey.ROOT_KEY_CURRENT_USER,
|
||||
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
|
||||
uninstallKey.ACCESS_WRITE);
|
||||
if (uninstallKey.hasChild(WebappOSUtils.getUniqueName(app))) {
|
||||
uninstallKey.removeChild(WebappOSUtils.getUniqueName(app));
|
||||
}
|
||||
} catch (e) {
|
||||
} finally {
|
||||
if (uninstallKey) {
|
||||
uninstallKey.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (profileDir) {
|
||||
yield OS.File.removeDir(profileDir.parent.parent.path, { ignoreAbsent: true });
|
||||
}
|
||||
|
||||
yield OS.File.removeDir(installPath, { ignoreAbsent: true });
|
||||
|
||||
yield OS.File.remove(desktopShortcut, { ignoreAbsent: true });
|
||||
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");
|
||||
exePath = OS.Path.join(installPath, "Contents", "MacOS", "webapprt");
|
||||
|
||||
let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir, "Application Support",
|
||||
WebappOSUtils.getUniqueName(app));
|
||||
|
||||
cleanup = function() {
|
||||
return Task.spawn(function*() {
|
||||
if (appProcess.isRunning) {
|
||||
appProcess.kill();
|
||||
}
|
||||
|
||||
if (profileDir) {
|
||||
yield OS.File.removeDir(profileDir.parent.path, { ignoreAbsent: true });
|
||||
}
|
||||
|
||||
yield OS.File.removeDir(installPath, { ignoreAbsent: true });
|
||||
|
||||
yield OS.File.removeDir(appProfileDir, { ignoreAbsent: true });
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
let zipWriter = Cc["@mozilla.org/zipwriter;1"].createInstance(Ci.nsIZipWriter);
|
||||
zipWriter.open(zipFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
|
||||
zipWriter.addEntryFile("index.html",
|
||||
Ci.nsIZipWriter.COMPRESSION_NONE,
|
||||
getFile(getTestFilePath("data/app/index.html")),
|
||||
false);
|
||||
zipWriter.addEntryFile("manifest.webapp",
|
||||
Ci.nsIZipWriter.COMPRESSION_NONE,
|
||||
getFile(getTestFilePath("data/app/manifest.webapp")),
|
||||
false);
|
||||
zipWriter.close();
|
||||
|
||||
return zipFile.path;
|
||||
}
|
||||
|
||||
function wasAppSJSAccessed() {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.addEventListener("load", function() {
|
||||
let ret = (xhr.responseText == "done") ? true : false;
|
||||
deferred.resolve(ret);
|
||||
});
|
||||
|
||||
xhr.addEventListener("error", aError => deferred.reject(aError));
|
||||
xhr.addEventListener("abort", aError => deferred.reject(aError));
|
||||
|
||||
xhr.open('GET', 'http://test/chrome/toolkit/webapps/tests/app.sjs?testreq', true);
|
||||
xhr.send();
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
Task.spawn(function() {
|
||||
// Get to a clean state before the test
|
||||
yield cleanup();
|
||||
|
||||
let zipPath = buildAppPackage();
|
||||
|
||||
let nativeApp = new NativeApp(app, manifest, app.categories);
|
||||
ok(nativeApp, "NativeApp object created");
|
||||
|
||||
profileDir = nativeApp.createProfile();
|
||||
ok(profileDir && profileDir.exists(), "Profile directory created");
|
||||
|
||||
// Install application
|
||||
info("Test installation");
|
||||
yield nativeApp.install(manifest, zipPath);
|
||||
while (!WebappOSUtils.isLaunchable(app)) {
|
||||
yield wait(1000);
|
||||
}
|
||||
ok(true, "App launchable");
|
||||
|
||||
let exeFile = getFile(exePath);
|
||||
|
||||
ok(exeFile.isExecutable(), "webapprt executable is executable");
|
||||
|
||||
let appClosed = false;
|
||||
|
||||
appProcess.init(exeFile)
|
||||
appProcess.runAsync([], 0, () => appClosed = true);
|
||||
|
||||
while (!(yield wasAppSJSAccessed()) && !appClosed) {
|
||||
yield wait(1000);
|
||||
}
|
||||
ok(!appClosed, "App was launched and is still running");
|
||||
|
||||
SimpleTest.finish();
|
||||
}).then(null, function(e) {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
@ -43,7 +43,10 @@ CommandLineHandler.prototype = {
|
||||
null);
|
||||
// Load the module to start up the app
|
||||
Cu.import("resource://webapprt/modules/Startup.jsm");
|
||||
startup(window);
|
||||
startup(window).then(null, function (aError) {
|
||||
dump("Error: " + aError + "\n");
|
||||
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -146,5 +146,5 @@ this.startup = function(window) {
|
||||
}
|
||||
|
||||
WebappRT.startUpdateService();
|
||||
}).then(null, Cu.reportError.bind(Cu));
|
||||
});
|
||||
}
|
||||
|
@ -30,8 +30,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "appsService",
|
||||
|
||||
this.WebappRT = {
|
||||
get launchURI() {
|
||||
let manifest = this.localeManifest;
|
||||
return manifest.fullLaunchPath();
|
||||
return this.localeManifest.fullLaunchPath();
|
||||
},
|
||||
|
||||
get localeManifest() {
|
||||
|
Loading…
Reference in New Issue
Block a user