1 const Cc
= Components
.classes
;
2 const Ci
= Components
.interfaces
;
4 var authPromptRequestReceived
;
6 const tPFCID
= Components
.ID("{749e62f4-60ae-4569-a8a2-de78b649660f}");
7 const tPFContract
= "@mozilla.org/passwordmanager/authpromptfactory;1";
12 * Implements nsIPromptFactory
14 var TestPromptFactory
= {
15 QueryInterface
: function tPF_qi(iid
) {
16 if (iid
.equals(Ci
.nsISupports
) ||
17 iid
.equals(Ci
.nsIFactory
) ||
18 iid
.equals(Ci
.nsIPromptFactory
))
20 throw Components
.results
.NS_ERROR_NO_INTERFACE
;
23 createInstance
: function tPF_ci(outer
, iid
) {
25 throw Components
.results
.NS_ERROR_NO_AGGREGATION
;
26 return this.QueryInterface(iid
);
29 lockFactory
: function tPF_lockf(lock
) {
30 throw Components
.results
.NS_ERROR_NOT_IMPLEMENTED
;
33 getPrompt
: function tPF_getPrompt(aWindow
, aIID
) {
34 if (aIID
.equals(Ci
.nsIAuthPrompt
) ||
35 aIID
.equals(Ci
.nsIAuthPrompt2
)) {
36 authPromptRequestReceived
= true;
40 throw Components
.results
.NS_ERROR_NO_INTERFACE
;
42 }; // end of TestPromptFactory implementation
48 Components
.manager
.nsIComponentRegistrar
.registerFactory(tPFCID
,
49 "TestPromptFactory", tPFContract
, TestPromptFactory
);
51 // Make sure that getting both nsIAuthPrompt and nsIAuthPrompt2 works
52 // (these should work independently of whether the application has
54 var ww
= Cc
["@mozilla.org/embedcomp/window-watcher;1"].getService();
56 authPromptRequestReceived
= false;
58 do_check_neq(ww
.nsIPromptFactory
.getPrompt(null, Ci
.nsIAuthPrompt
), null);
60 do_check_true(authPromptRequestReceived
);
62 authPromptRequestReceived
= false;
64 do_check_neq(ww
.nsIPromptFactory
.getPrompt(null, Ci
.nsIAuthPrompt2
), null);
66 do_check_true(authPromptRequestReceived
);