Skip to content

Commit

Permalink
bug 770771 - Implement WebappRT test framework on Windows; r=adw
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Castelluccio committed Jul 13, 2012
1 parent c800bfb commit 21c5f0e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
6 changes: 6 additions & 0 deletions testing/testsuite-targets.mk
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ endif

ifeq ($(OS_ARCH),Darwin)
webapprt_stub_path = $(TARGET_DIST)/$(MOZ_MACBUNDLE_NAME)/Contents/MacOS/webapprt-stub$(BIN_SUFFIX)
endif
ifeq ($(OS_ARCH),WINNT)
webapprt_stub_path = $(TARGET_DIST)/bin/webapprt-stub$(BIN_SUFFIX)
endif

ifdef webapprt_stub_path
webapprt-test-content:
$(RUN_MOCHITEST) --webapprt-content --appname $(webapprt_stub_path)
$(CHECK_TEST_ERROR)
Expand Down
2 changes: 2 additions & 0 deletions webapprt/CommandLineHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ CommandLineHandler.prototype = {
if (!inTestMode) {
startUp(inTestMode);
} else {
DOMApplicationRegistry.allAppsLaunchable = true;

// startUp() accesses WebappRT.config, which in test mode is not valid
// until WebappRT.jsm observes an app installation.
Services.obs.addObserver(function onInstall(subj, topic, data) {
Expand Down
42 changes: 31 additions & 11 deletions webapprt/win/webapprt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace {
wchar_t backupFilePath[MAXPATHLEN];
wchar_t iconPath[MAXPATHLEN];
char profile[MAXPATHLEN];
bool isProfileOverridden = false;
int* pargc;
char*** pargv;

Expand Down Expand Up @@ -277,8 +278,10 @@ namespace {
rv = webShellAppData.create(rtINI);
NS_ENSURE_SUCCESS(rv, false);

SetAllocatedString(webShellAppData->profile, profile);
SetAllocatedString(webShellAppData->name, profile);
if (!isProfileOverridden) {
SetAllocatedString(webShellAppData->profile, profile);
SetAllocatedString(webShellAppData->name, profile);
}

nsCOMPtr<nsIFile> directory;
rv = XRE_GetFileFromPath(rtPath, getter_AddRefs(directory));
Expand Down Expand Up @@ -441,6 +444,21 @@ main(int argc, char* argv[])
return 255;
}

// Check if the runtime was executed with the "-profile" argument
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-profile")) {
isProfileOverridden = true;
break;
}
}

// First attempt at loading Firefox binaries:
// Check if the webapprt is in the same directory as the Firefox binary.
// This is the case during WebappRT chrome and content tests.
if (AttemptLoadFromDir(buffer)) {
return 0;
}

// Set up appIniPath with path to webapp.ini.
// This should be in the same directory as the running executable.
char appIniPath[MAXPATHLEN];
Expand All @@ -466,18 +484,20 @@ main(int argc, char* argv[])
return 255;
}

// Get profile dir from webapp.ini
if (NS_FAILED(parser.GetString("Webapp",
"Profile",
profile,
MAXPATHLEN))) {
Output("Unable to retrieve profile from web app INI file");
return 255;
if (!isProfileOverridden) {
// Get profile dir from webapp.ini
if (NS_FAILED(parser.GetString("Webapp",
"Profile",
profile,
MAXPATHLEN))) {
Output("Unable to retrieve profile from web app INI file");
return 255;
}
}

char firefoxDir[MAXPATHLEN];

// First attempt at loading Firefox binaries:
// Second attempt at loading Firefox binaries:
// Get the location of Firefox from our webapp.ini

// XXX: This string better be UTF-8...
Expand All @@ -491,7 +511,7 @@ main(int argc, char* argv[])
}
}

// Second attempt at loading Firefox binaries:
// Third attempt at loading Firefox binaries:
// Get the location of Firefox from the registry
if (GetFirefoxDirFromRegistry(firefoxDir)) {
if (AttemptLoadFromDir(firefoxDir)) {
Expand Down

0 comments on commit 21c5f0e

Please sign in to comment.