Implementing and registering own nsIPromptService does not work anymore when embedding

RESOLVED INCOMPLETE

Status

()

RESOLVED INCOMPLETE
8 years ago
2 years ago

People

(Reporter: antoine.viau, Unassigned)

Tracking

({embed, regression})

unspecified
x86
All
embed, regression
Points:
---

Firefox Tracking Flags

(blocking2.0 -)

Details

Attachments

(1 attachment)

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.94 Safari/534.13
Build Identifier: 4.0b11

Until 4.0b7 the basic way to register and implement nsIPromptService worked very well. Snippet extracted from ActiveX (and MDC) : 

#define NS_PROMPTSERVICE_CID {0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}} 	
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
nsCOMPtr<nsIFactory> promptFactory;
NS_NewPromptServiceFactory(getter_AddRefs(promptFactory));
nsCOMPtr<nsIComponentRegistrar> registrar;
NS_GetComponentRegistrar(getter_AddRefs(registrar));
registrar->RegisterFactory(kPromptServiceCID,"PromptService",NS_PROMPTSERVICE_CONTRACTID,promptFactory);

No error value is returned.
All JS calls to dialogs (alert, prompt...) are managed by WindowCreator.

Reproducible: Always
(Reporter)

Updated

8 years ago
Keywords: embed
OS: Windows XP → All
dolske?  How did this setup change?
(Reporter)

Comment 2

8 years ago
Sorry, I missclicked... Here some more :
MDC documentation about implementing and registering nsIPromptService is here :
https://developer.mozilla.org/en/Mozilla_Embedding_FAQ/How_do_I...#How_do_I_display_my_own_message.2c_alert_and_prompt_boxes.3f
(and quite outdated)

The usual workflow is : 
 - Write a PromptFactory which implements nsIFactory (CreateInstance, LockInstance) and will build a PromptService
 - Write the PromptService which implements nsIPromptService
 - After initialization, create PromptFactory
 - Register PromptService through ComponentRegistrar / RegisterFactory

This used to work perfectly. But now, the PromptFactory.CreateInstance is never called. So, the PromptService is never used. 
When JS calls alert(), prompt(), etc. the call is managed by WindowCreator if present, else it just goes to assertion "attempted to open a new window with no WindowCreator" in nsWindowWatcher.

Is there still a way to display my own alert(), prompt() ?
Or any way to display the FF dialogs when embedding ?
This looks like a bad embedding regression to me...
Status: UNCONFIRMED → NEW
blocking2.0: --- → ?
Ever confirmed: true
Keywords: regression

Comment 4

8 years ago
I'm not going to block Firefox ship on embedding issues.
blocking2.0: ? → -
(Reporter)

Comment 5

8 years ago
I am working on a very simple embedding test app. Something liter than WinEmbed. I post code today.
Benjamin, do we even understand why this broke?  I'm fine with not blocking if we know this is restricted to certain embedding use cases, but I think we need to determine the actual impact here.

Comment 7

8 years ago
Why do you think it matters? I don't think that Firefox extensions overriding the prompt service is something I'd block on, and otherwise I really don't think it's important to stop ship even if we don't understand exactly what's going on.
I believe there are in fact extensions overriding the prompt service to do various custom stuff...

But yes, if we think this is limited to the promptservice I guess this shouldn't really block...
(Reporter)

Comment 9

8 years ago
Created attachment 511531 [details]
PromptService when embedding : basic test

This is a very basic app based on winEmbed. It just embeds the browser in one window, and registers  a hand-made prompt service. It works like a charm with 4.0b7 but it won't with 4.0b11.
I am currenty working on beta 8-9-10.
BTW : is there any documentation about using the default prompt service in an embed app ? I have been searching for years ! That is why I use my own prompt service and I'd love to use the default one.
(Reporter)

Comment 10

8 years ago
I confirm that the problem occurs at 4.0b8+
Could anyone tell me how to use the default PromptService implementation in embedding ? A piece of code to include in my basic app given in attachment would be great ! Thank you.
Bug 563274 overhauled how prompting is handled in Gecko. Overriding it should be fairly similar to how it worked in the past (we didn't have to massively change interfaces as I had first feared), but there are probably some details that have changed, intentional or not.

Without any details on troubleshooting from your end, it's hard to say what the problem is.

Perhaps looking at what /toolkit/components/prompts/src/nsPrompter.js implements will help.
Also, FWIW, we happen to have an override of the default prompting bits in the tree as part of a test... See /dom/tests/mochitest/bugs/test_bug61098.html
Fennec overrides the PromptService too. Still working for us.
(Reporter)

Comment 14

8 years ago
More details : 
My code has been written for Windows. Debug mode. Tested on XP and 7.
Just to know what it does : 
 - the embedding process is based on winEmbed. So is just a Chrome object which implements nsIInterfaceRequestor, nsIWebBrowerChrome, nsIEmbeddingSiteWindow.

 - a prompt service factory is created and registered through the ComponentRegistrar :
nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory)
{
	CPromptServiceFactory *result = new CPromptServiceFactory;
	NS_ADDREF(result);
	*aFactory = result;
	return NS_OK;
}
#define NS_PROMPTSERVICE_CID {0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
static NS_DEFINE_CID(kPromptServiceCID,NS_PROMPTSERVICE_CID);
nsCOMPtr<nsIFactory> promptFactory ;
nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory);
nsCOMPtr<nsIComponentRegistrar> compReg;
NS_GetComponentRegistrar(getter_AddRefs(compReg));
NS_NewPromptServiceFactory(getter_AddRefs(promptFactory));
compReg->RegisterFactory(kPromptServiceCID, "Prompt Service",NS_PROMPTSERVICE_CONTRACTID, promptFactory);

 - The CPromptService implements nsIPromptService.

What's happening ?
Before 4.0b8, it just worked. I wrote a basic HTML page which call an alert() on the onload body event. My own alert is called.
But since 4.0b8, the CPromptServiceFactory.CreateInstance is never called. So, my prompt service implementations is never created. And when an alert() is called in an HTML document,  we got an assertion in nswindowwatcher.cpp, method nsWindowWatcher::OpenWindowJSInternal, line 691 (4.0b11) that says ""attempted to open a new window with no WindowCreator".

I might be using the wrong way to "play" with prompt services, but I just followed some (old) documentations.

Comment 15

2 years ago
Marking a bunch of bugs in the "Embedding: APIs" component INCOMPLETE in preparation to archive that component. If I have done this incorrectly, please reopen the bugs and move them to a more correct component as we don't have "embedding" APIs any more.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.