mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1036751 - Test webapp runtime executable update. r=myk
--HG-- rename : toolkit/webapps/tests/test_hosted_launch.xul => toolkit/webapps/tests/test_webapp_runtime_executable_update.xul
This commit is contained in:
parent
4330519678
commit
592964fca3
@ -9,7 +9,7 @@ EXTRA_PP_JS_MODULES += [
|
||||
'WebappOSUtils.jsm',
|
||||
]
|
||||
|
||||
MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
|
||||
TEST_DIRS += ['tests']
|
||||
|
||||
if CONFIG['MOZ_BUILD_APP'] == 'mobile/android':
|
||||
DEFINES['MOZ_FENNEC'] = True
|
||||
|
7
toolkit/webapps/tests/Makefile.in
Normal file
7
toolkit/webapps/tests/Makefile.in
Normal file
@ -0,0 +1,7 @@
|
||||
# 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/.
|
||||
|
||||
PROGRAMS_DEST = $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
7
toolkit/webapps/tests/TestWebappRT.cpp
Normal file
7
toolkit/webapps/tests/TestWebappRT.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
/* 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/. */
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
return 42;
|
||||
}
|
@ -29,3 +29,4 @@ skip-if = asan
|
||||
skip-if = asan
|
||||
[test_hosted_icons.xul]
|
||||
[test_packaged_icons.xul]
|
||||
[test_webapp_runtime_executable_update.xul]
|
||||
|
@ -155,6 +155,8 @@ function TestAppInfo(aApp, aIsPackaged) {
|
||||
|
||||
this.iconFile = OS.Path.join(this.installPath, "icon.png");
|
||||
|
||||
this.webappINI = OS.Path.join(this.installPath, "webapp.ini");
|
||||
|
||||
let xdg_data_home = Cc["@mozilla.org/process/environment;1"].
|
||||
getService(Ci.nsIEnvironment).
|
||||
get("XDG_DATA_HOME");
|
||||
@ -167,7 +169,7 @@ function TestAppInfo(aApp, aIsPackaged) {
|
||||
|
||||
this.installedFiles = [
|
||||
OS.Path.join(this.installPath, "webapp.json"),
|
||||
OS.Path.join(this.installPath, "webapp.ini"),
|
||||
this.webappINI,
|
||||
this.iconFile,
|
||||
this.exePath,
|
||||
desktopINI,
|
||||
@ -179,7 +181,7 @@ function TestAppInfo(aApp, aIsPackaged) {
|
||||
];
|
||||
this.updatedFiles = [
|
||||
OS.Path.join(this.installPath, "webapp.json"),
|
||||
OS.Path.join(this.installPath, "webapp.ini"),
|
||||
this.webappINI,
|
||||
this.iconFile,
|
||||
desktopINI,
|
||||
];
|
||||
@ -215,6 +217,8 @@ function TestAppInfo(aApp, aIsPackaged) {
|
||||
|
||||
this.iconFile = OS.Path.join(this.installPath, "chrome", "icons", "default", "default.ico");
|
||||
|
||||
this.webappINI = OS.Path.join(this.installPath, "webapp.ini");
|
||||
|
||||
let desktopShortcut = OS.Path.join(OS.Constants.Path.desktopDir,
|
||||
aApp.name + ".lnk");
|
||||
let startMenuShortcut = OS.Path.join(OS.Constants.Path.winStartMenuProgsDir,
|
||||
@ -222,7 +226,7 @@ function TestAppInfo(aApp, aIsPackaged) {
|
||||
|
||||
this.installedFiles = [
|
||||
OS.Path.join(this.installPath, "webapp.json"),
|
||||
OS.Path.join(this.installPath, "webapp.ini"),
|
||||
this.webappINI,
|
||||
OS.Path.join(this.installPath, "uninstall", "shortcuts_log.ini"),
|
||||
OS.Path.join(this.installPath, "uninstall", "uninstall.log"),
|
||||
OS.Path.join(this.installPath, "uninstall", "webapp-uninstaller.exe"),
|
||||
@ -241,7 +245,7 @@ function TestAppInfo(aApp, aIsPackaged) {
|
||||
];
|
||||
this.updatedFiles = [
|
||||
OS.Path.join(this.installPath, "webapp.json"),
|
||||
OS.Path.join(this.installPath, "webapp.ini"),
|
||||
this.webappINI,
|
||||
OS.Path.join(this.installPath, "uninstall", "shortcuts_log.ini"),
|
||||
OS.Path.join(this.installPath, "uninstall", "uninstall.log"),
|
||||
this.iconFile,
|
||||
@ -312,13 +316,15 @@ function TestAppInfo(aApp, aIsPackaged) {
|
||||
|
||||
this.iconFile = OS.Path.join(this.installPath, "Contents", "Resources", "appicon.icns");
|
||||
|
||||
this.webappINI = OS.Path.join(this.installPath, "Contents", "MacOS", "webapp.ini");
|
||||
|
||||
let appProfileDir = OS.Path.join(OS.Constants.Path.macUserLibDir,
|
||||
"Application Support",
|
||||
this.uniqueName);
|
||||
|
||||
this.installedFiles = [
|
||||
OS.Path.join(this.installPath, "Contents", "Info.plist"),
|
||||
OS.Path.join(this.installPath, "Contents", "MacOS", "webapp.ini"),
|
||||
this.webappINI,
|
||||
OS.Path.join(appProfileDir, "webapp.json"),
|
||||
this.iconFile,
|
||||
this.exePath,
|
||||
@ -331,7 +337,7 @@ function TestAppInfo(aApp, aIsPackaged) {
|
||||
];
|
||||
this.updatedFiles = [
|
||||
OS.Path.join(this.installPath, "Contents", "Info.plist"),
|
||||
OS.Path.join(this.installPath, "Contents", "MacOS", "webapp.ini"),
|
||||
this.webappINI,
|
||||
OS.Path.join(appProfileDir, "webapp.json"),
|
||||
this.iconFile,
|
||||
];
|
||||
|
9
toolkit/webapps/tests/moz.build
Normal file
9
toolkit/webapps/tests/moz.build
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
|
||||
SOURCES += ['TestWebappRT.cpp' ]
|
||||
SIMPLE_PROGRAMS += ['TestWebappRT']
|
158
toolkit/webapps/tests/test_webapp_runtime_executable_update.xul
Normal file
158
toolkit/webapps/tests/test_webapp_runtime_executable_update.xul
Normal file
@ -0,0 +1,158 @@
|
||||
<?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=1036751
|
||||
-->
|
||||
<window title="Mozilla Bug 1036751"
|
||||
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=1036751"
|
||||
target="_blank">Mozilla Bug 1036751</a>
|
||||
</body>
|
||||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
/** Test for Bug 1036751 **/
|
||||
|
||||
"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 testAppInfo = new TestAppInfo(app);
|
||||
|
||||
function runProcess() {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
testAppInfo.appProcess.runAsync([], 0, (aSubject, aTopic) => {
|
||||
if (aTopic == "process-finished") {
|
||||
deferred.resolve(aSubject.exitValue);
|
||||
} else if (aTopic == "process-failed") {
|
||||
deferred.reject(aSubject.exitValue);
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
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 fakeInstallDir;
|
||||
if (MAC) {
|
||||
fakeInstallDir = getFile(testAppInfo.installPath, "Contents", "MacOS");
|
||||
} else {
|
||||
fakeInstallDir = getFile(OS.Constants.Path.profileDir, "fakeInstallDir");
|
||||
fakeInstallDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
|
||||
}
|
||||
|
||||
let fakeAppIniFile = fakeInstallDir.clone();
|
||||
fakeAppIniFile.append("application.ini");
|
||||
|
||||
let iniFile = getFile(testAppInfo.webappINI);
|
||||
|
||||
let iniWriter = Cc["@mozilla.org/xpcom/ini-processor-factory;1"].
|
||||
getService(Ci.nsIINIParserFactory).
|
||||
createINIParser(iniFile).
|
||||
QueryInterface(Ci.nsIINIParserWriter);
|
||||
iniWriter.setString("WebappRT", "InstallDir", fakeInstallDir.path);
|
||||
iniWriter.writeFile();
|
||||
|
||||
let appIniWriter = Cc["@mozilla.org/xpcom/ini-processor-factory;1"].
|
||||
getService(Ci.nsIINIParserFactory).
|
||||
createINIParser(fakeAppIniFile).
|
||||
QueryInterface(Ci.nsIINIParserWriter);
|
||||
appIniWriter.setString("App", "BuildID", "aBuildID");
|
||||
appIniWriter.writeFile();
|
||||
|
||||
let exeName = "webapprt-stub";
|
||||
if (WIN) {
|
||||
exeName += ".exe";
|
||||
}
|
||||
|
||||
let stubExeName = "TestWebappRT";
|
||||
if (WIN) {
|
||||
stubExeName += ".exe";
|
||||
}
|
||||
|
||||
let exeFile = getFile(testAppInfo.exePath);
|
||||
|
||||
let stubExeFile = getFile(getTestFilePath(stubExeName));
|
||||
stubExeFile.copyTo(fakeInstallDir, exeName);
|
||||
|
||||
if (MAC) {
|
||||
stubExeFile.copyTo(getFile(testAppInfo.installPath, "Contents", "MacOS"), "firefox-bin");
|
||||
}
|
||||
|
||||
testAppInfo.appProcess.init(exeFile);
|
||||
|
||||
if (WIN) {
|
||||
is((yield runProcess()), 0, "Webapp runtime executable has been replaced");
|
||||
}
|
||||
is((yield runProcess()), 42, "Webapp runtime executable has been replaced");
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
runTest().catch((e) => {
|
||||
ok(false, "Error during test: " + e);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
Loading…
Reference in New Issue
Block a user