Buggy code:
if ( rc != ( XPCOM . NS_OK ) ) Mozilla . error ( rc ) ; if ( ( result [ 0 ] ) == 0 ) Mozilla . error ( NS_ERROR_NO_INTERFACE ) ; localFile . Release ( ) ; nsIFile prefFile = new nsIFile ( result [ 0 ] ) ; result [ 0 ] = 0 ; buffer = MozillaDelegate . wcsToMbcs ( null , NS_PREFSERVICE_CONTRACTID , true ) ; rc = serviceManager . GetServiceByContractID ( buffer , NS_IPREFSERVICE_IID , result ) ; if ( rc != ( XPCOM . NS_OK ) ) Mozilla . error ( rc ) ; if ( ( result [ 0 ] ) == 0 ) Mozilla . error ( NS_NOINTERFACE ) ; nsIPrefService prefService = new nsIPrefService ( result [ 0 ] ) ; result [ 0 ] = 0 ; rc = prefService . SavePrefFile ( prefFile . getAddress ( ) ) ; prefService . Release ( ) ; prefFile . Release ( ) ; } serviceManager . Release ( ) ; if ( Mozilla . XPCOMWasGlued ) { display . asyncExec ( new Runnable ( ) { public void run ( ) { XPCOM . XPCOMGlueShutdown ( ) ; } } ) ; Mozilla . XPCOMWasGlued = false ; } if ( Mozilla . XPCOMInitWasGlued ) { XPCOMInit . XPCOMGlueShutdown ( ) ; Mozilla . XPCOMInitWasGlued = false ; } Mozilla . Initialized = false ; } } ) ; } ( Mozilla . BrowserCount ) ++ ; int rc = XPCOM . NS_GetComponentManager ( result ) ; if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( rc ) ; } if ( ( result [ 0 ] ) == 0 ) { browser . dispose ( ) ; Mozilla . error ( NS_NOINTERFACE ) ; } nsIComponentManager componentManager = new nsIComponentManager ( result [ 0 ] ) ; result [ 0 ] = 0 ; nsID NS_IWEBBROWSER_CID = new nsID ( "F1EAC761-87E9-11d3-AF80-00A024FFC08C" ) ; rc = componentManager . CreateInstance ( NS_IWEBBROWSER_CID , 0 , NS_IWEBBROWSER_IID , result ) ; if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( rc ) ; } if ( ( result [ 0 ] ) == 0 ) { browser . dispose ( ) ; Mozilla . error ( NS_NOINTERFACE ) ; } webBrowser = new nsIWebBrowser ( result [ 0 ] ) ; result [ 0 ] = 0 ; createCOMInterfaces ( ) ; AddRef ( ) ; rc = webBrowser . SetContainerWindow ( webBrowserChrome . getAddress ( ) ) ; if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( rc ) ; } rc = webBrowser . QueryInterface ( NS_IBASEWINDOW_IID , result ) ; if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( rc ) ; } if ( ( result [ 0 ] ) == 0 ) { browser . dispose ( ) ; Mozilla . error ( NS_ERROR_NO_INTERFACE ) ; } nsIBaseWindow baseWindow = new nsIBaseWindow ( result [ 0 ] ) ; result [ 0 ] = 0 ; Rectangle rect = browser . getClientArea ( ) ; if ( rect . isEmpty ( ) ) { rect . width = 1 ; rect . height = 1 ; } embedHandle = delegate . getHandle ( ) ; rc = baseWindow . InitWindow ( embedHandle , 0 , 0 , 0 , rect . width , rect . height ) ; if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( NS_ERROR_FAILURE ) ; } <START_BUG> rc = baseWindow . Create ( ) ; <END_BUG> if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( NS_ERROR_FAILURE ) ; } rc = baseWindow . SetVisibility ( 1 ) ; if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( NS_ERROR_FAILURE ) ; } baseWindow . Release ( ) ; if ( ! ( Mozilla . PerformedVersionCheck ) ) { Mozilla . PerformedVersionCheck = true ; rc = componentManager . QueryInterface ( NS_ICOMPONENTREGISTRAR_IID , result ) ; if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( rc ) ; } if ( ( result [ 0 ] ) == 0 ) { browser . dispose ( ) ; Mozilla . error ( NS_NOINTERFACE ) ; } nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar ( result [ 0 ] ) ; result [ 0 ] = 0 ; HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory ( ) ; dialogFactory . AddRef ( ) ; byte [ ] aContractID = MozillaDelegate . wcsToMbcs ( null , NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID , true ) ; byte [ ] aClassName = MozillaDelegate . wcsToMbcs ( null , "Helper<seq2seq4repair_space>App<seq2seq4repair_space>Launcher<seq2seq4repair_space>Dialog" , true ) ; rc = componentRegistrar . RegisterFactory ( NS_HELPERAPPLAUNCHERDIALOG_CID , aClassName , aContractID , dialogFactory . getAddress ( ) ) ; if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( rc ) ; } dialogFactory . Release ( ) ; rc = webBrowser . QueryInterface ( NS_IINTERFACEREQUESTOR_IID , result ) ; if ( rc != ( XPCOM . NS_OK ) ) { browser . dispose ( ) ; Mozilla . error ( NS_ERROR_FAILURE ) ; } if ( ( result [ 0 ] ) == 0 ) { browser . dispose ( ) ; Mozilla . error ( NS_ERROR_NO_INTERFACE ) ; } nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor ( result [ 0 ] ) ; result [ 0 ] = 0 ; rc = interfaceRequestor . GetInterface ( NS_IDOCSHELL_IID , result ) ;

Fix:
rc = delegate . createBaseWindow ( baseWindow ) ;