#include <stdio.h> #include <stdlib.h> #include <string.h>
// mozilla specific headers #include "nsEmbedAPI.h" #include "nsCOMPtr.h" #include "nsStringAPI.h" #include "nsEmbedString.h" #include "nsComponentManagerUtils.h" #include "nsIDOMKeyEvent.h" #include "nsIDOMMouseEvent.h" #include "nsIDOMUIEvent.h" #include "nsXPCOMGlue.h" #include "nsCWebBrowser.h" #include "nsIWebBrowserChrome.h" #include "nsIWebBrowser.h" #include "nsIWebNavigation.h" #include "nsILocalFile.h" int main(int argc,char **argv) { nsresult rv; printf("hello world\n"); static const GREVersionRange greVersion = { "1.9a", PR_TRUE, "2", PR_TRUE }; char xpcomPath[256]; rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0,xpcomPath, sizeof(xpcomPath)); if (NS_FAILED(rv)) { fprintf(stderr, "Couldn't find a compatible GRE.\n"); return 1; } rv = XPCOMGlueStartup(xpcomPath); if (NS_FAILED(rv)) { fprintf(stderr, "Couldn't start XPCOM."); return 1; } char *lastSlash = strrchr(xpcomPath, '/'); if (lastSlash) *lastSlash = '\0'; setenv("MOZILLA_FIVE_HOME", xpcomPath, 0); char *home_path; char *full_path; home_path = getenv("HOME"); if (!home_path) { fprintf(stderr, "Failed to get HOME\n"); return 1; } const char * grePath = getenv("MOZILLA_FIVE_HOME"); nsCOMPtr<nsILocalFile> greDir = nsnull; //char* grePath1 ="/home/brightman/mozilla/dist/bin"; //static const PRUnichar grePath[] = {'/', 'h', 'o', 'm', 'e', '/', 'b', 'r', 'i', 'g', 'h', 't', 'm', 'a', 'n', '/', 'm', 'o', 'z', 'i', 'l', 'l', 'a','/', 'd', 'i', 's', 't', '/', 'b', 'i', 'n', '\0' }; //nsEmbedString((const PRUnichar *)grePath1); rv = NS_NewLocalFile(nsEmbedString((const PRUnichar *)grePath),PR_TRUE,getter_AddRefs(greDir)); if (NS_FAILED(rv)){ fprintf(stdout, "Couldn't set greDir.(rv = 0x%08x)\n",rv); exit(1); } rv = NS_InitEmbedding(greDir,nsnull); if(NS_FAILED(rv)){ fprintf(stdout, "Couldn't start XPCOM.(rv = 0x%08x)\n",rv); exit(1); } //gtk_init(&argc, &argv); nsCOMPtr<nsIWebBrowser> nsWebBrowser; nsCOMPtr<nsIWebNavigation> nsNav; nsWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID,&rv); if(NS_FAILED(rv)){ fprintf(stdout, "Couldn't create nsIWebBrowser.\n"); nsWebBrowser = nsnull; return 1; } nsNav = do_QueryInterface(nsWebBrowser,&rv); if(NS_FAILED(rv)){ fprintf(stdout, "Couldn't create nsINav.\n"); return 1; } printf("start load url\n"); char *url = "http://www.baidu.com"; rv = nsNav->LoadURI((const PRUnichar*)(url), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull); if (NS_FAILED(rv)) { printf("LoadURI FAILED (rv = 0x%08x)\n", rv); } } else { printf("LoadURI SUCCEEDED (rv = 0x%08x)\n", rv); } } [EMAIL PROTECTED]:/backup/brightman/mozilla/embedding/examples$ ./test hello world WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file nsTraceRefcntImpl.cpp, line 914 ###!!! ASSERTION: iconv failed: 'Error', file nsNativeCharsetUtils.cpp, line 572 WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file nsTraceRefcntImpl.cpp, line 914 WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file nsTraceRefcntImpl.cpp, line 914 WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file nsTraceRefcntImpl.cpp, line 968 WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file nsTraceRefcntImpl.cpp, line 914 WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file nsTraceRefcntImpl.cpp, line 968 ###!!! ASSERTION: Failed to write xpti manifest!: 'Error', file xptiInterfaceInfoManager.cpp, line 1940 ###!!! ASSERTION: Failed to write xpti manifest!: 'Error', file xptiInterfaceInfoManager.cpp, line 1940 *** Registering components in: nsI18nModule *** Registering components in: nsImageLib2Module *** Registering components in: mozStorageModule *** Registering components in: BrowserDirProvider *** Registering components in: nsXPIntlModule *** Registering components in: nsComposerModule *** Registering components in: nsRDFModule *** Registering components in: nsLayoutModule *** Registering components in: xpconnect_test *** Registering components in: nsSampleModule *** Registering components in: nsFindComponent *** Registering components in: nsParserModule *** Registering components in: nsCJVMManagerModule *** Registering components in: nsAuthModule *** Registering components in: nsSoftwareUpdate *** Registering components in: satchel *** Registering components in: nsBrowserCompsModule *** Registering components in: RemoteServiceModule *** Registering components in: nsUniversalCharDetModule *** Registering components in: nsGfxModule *** Registering components in: Browser_Embedding_Module *** Registering components in: nsAutoConfigModule *** Registering components in: nsSystemPrefModule *** Registering components in: mozSpellCheckerModule *** Registering components in: application *** Registering components in: xpconnect *** Registering components in: nsXMLExtrasModule *** Registering components in: nsSecurityManagerModule *** Registering components in: nsTestDynamicModule *** Registering components in: nsPermissionsModule *** Registering components in: BOOT *** Registering components in: necko *** Registering components in: nsAccessibilityModule *** Registering components in: nsChardetModule *** Registering components in: nsWidgetGtk2Module *** Registering components in: tkAutoCompleteModule *** Registering components in: PKI *** Registering components in: nsPrefModule *** Registering components in: nsTransactionManagerModule *** Registering components in: CommandLineModule *** Registering components in: JavaScript_Debugger *** Registering components in: nsPluginModule *** Registering components in: nsUCvMathModule *** Registering components in: nsCookieModule *** Registering components in: nsFileViewModule *** Registering components in: NSS *** Registering components in: MyService *** Registering components in: docshell_provider *** Registering components in: nsChromeModule *** Registering components in: nsJarModule *** Registering components in: nsToolkitCompsModule *** Registering components in: nsWindowDataSourceModule *** Registering components in: nsUConvModule *** Registering components in: appshell *** Registering components in: embedcomponents *** Registering components in: nsPlacesModule *** registering nsMicrosummaryService.js: [ Microsummary Service ] *** registering nsTryToClose.js: [ tryToClose Service ] *** registering nsHandlerService.js: [ Handler Service ] ************************************************************ * Call to xpconnect wrapped JSObject produced this error: * [Exception... "'[JavaScript Error: "Components.classes['@mozilla.org/ xre/app-info;1'] has no properties" {file: "file:///home/usr/local/lib/ firefox-3.0a8pre/components/nsBrowserContentHandler.js" line: 738}]' when calling method: [nsIModule::registerSelf]" nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)" location: "<unknown>" data: yes] ************************************************************ *** registering nsDownloadManagerUI.js: [ Used to show the Download Manager's UI to the user ] *** registering FeedProcessor.js: [ Feed Processor, Feed Result, Feed, Feed Entry, Feed Text Construct, Feed Generator, Feed Person ] *** registering nsContentPrefService.js: [ Content Pref Service, Hostname Grouper ] *** registering nsBrowserGlue.js: [ Firefox Browser Glue Service ] *** registering nsPlacesTransactionsService.js: [ Places Transaction Manager ] *** registering storage-Legacy.js: [ LoginManagerStorage_legacy ] *** registering nsBlocklistService.js: [ Blocklist Service ] *** registering nsTaggingService.js: [ Places Tagging Service ] *** registering nsContentDispatchChooser.js: [ Used to handle different types of content ] *** registering nsWebHandlerApp.js: [ A web handler for protocols and content ] *** Deferring registration of sample JS components *** registering nsSetDefaultBrowser.js: [ Default Browser Cmdline Handler ] *** registering nsLoginManagerPrompter.js: [ LoginManagerPromptFactory, LoginManagerPrompter ] *** registering nsExtensionManager.js: [ Extension Manager, Extension Manager Data Source, Update Item ] *** registering nsSearchSuggestions.js: [ Remote Search Suggestions ] *** registering nsLoginManager.js: [ LoginManager ] *** registering nsLoginInfo.js: [ LoginInfo ] *** registering fuelApplication.js: [ Application ] *** Registering sample JS components ************************************************************ * Call to xpconnect wrapped JSObject produced this error: * [Exception... "'[JavaScript Error: "Components.classes['@mozilla.org/ xre/app-info;1'] has no properties" {file: "file:///home/usr/local/lib/ firefox-3.0a8pre/components/nsBrowserContentHandler.js" line: 738}]' when calling method: [nsIModule::registerSelf]" nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)" location: "<unknown>" data: yes] ************************************************************ ************************************************************ * Call to xpconnect wrapped JSObject produced this error: * [Exception... "'[JavaScript Error: "Components.classes['@mozilla.org/ xre/app-info;1'] has no properties" {file: "file:///home/usr/local/lib/ firefox-3.0a8pre/components/fuelApplication.js" line: 1132}]' when calling method: [nsIFactory::createInstance]" nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)" location: "<unknown>" data: yes] ************************************************************ WARNING: Cannot create startup observer : service,@mozilla.org/fuel/ application;1: file nsAppStartupNotifier.cpp, line 113 ************************************************************ * Call to xpconnect wrapped JSObject produced this error: * [Exception... "'[JavaScript Error: "Cc['@mozilla.org/xre/app-info;1'] has no properties" {file: "file:///home/usr/local/lib/firefox-3.0a8pre/ components/nsBlocklistService.js" line: 226}]' when calling method: [nsIFactory::createInstance]" nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)" location: "<unknown>" data: yes] ************************************************************ WARNING: Cannot create startup observer : service,@mozilla.org/ extensions/blocklist;1: file nsAppStartupNotifier.cpp, line 113 ************************************************************ * Call to xpconnect wrapped JSObject produced this error: * [Exception... "'[JavaScript Error: "Cc['@mozilla.org/xre/app-info;1'] has no properties" {file: "file:///home/usr/local/lib/firefox-3.0a8pre/ components/nsExtensionManager.js" line: 2167}]' when calling method: [nsIFactory::createInstance]" nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)" location: "<unknown>" data: yes] ************************************************************ WARNING: Cannot create startup observer : service,@mozilla.org/ extensions/manager;1: file nsAppStartupNotifier.cpp, line 113 ************************************************************ * Call to xpconnect wrapped JSObject produced this error: * [Exception... "'[JavaScript Error: "Components.classes['@mozilla.org/ xre/app-info;1'] has no properties" {file: "file:///home/usr/local/lib/ firefox-3.0a8pre/components/nsUpdateService.js" line: 1005}]' when calling method: [nsIFactory::createInstance]" nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)" location: "<unknown>" data: yes] ************************************************************ WARNING: Cannot create startup observer : service,@mozilla.org/updates/ update-service;1: file nsAppStartupNotifier.cpp, line 113 start load url WARNING: NS_ENSURE_TRUE(mDocShell) failed: file nsWebBrowser.cpp, line 694 LoadURI FAILED (rv = 0x8000ffff) nsStringStats => mAllocCount: 6357 => mReallocCount: 8 => mFreeCount: 5680 -- LEAKED 677 !!! => mShareCount: 6999 => mAdoptCount: 216 => mAdoptFreeCount: 214 -- LEAKED 2 !!! _______________________________________________ dev-embedding mailing list dev-embedding@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-embedding